#include "HyperTwistTraining/HyperTwistTrainingCoachLibrary.h"

#include "HyperTwistTraining/HyperTwistTrainingCatalogLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingLibrary.h"

namespace HyperTwistTrainingCoachLibraryInternal
{
	EHyperTwistCoachPriority PriorityFromScore(const float Score);
	FString DescribeCoachMemorySourceLabel(const FString& SourceLabel);

	EHyperTwistTrainingCoachGuidanceLane GuidanceLaneFromSourceLabel(const FString& SourceLabel)
	{
		if (SourceLabel == TEXT("primary-brief"))
		{
			return EHyperTwistTrainingCoachGuidanceLane::Recommended;
		}
		if (SourceLabel == TEXT("follow-up-brief"))
		{
			return EHyperTwistTrainingCoachGuidanceLane::FollowUp;
		}

		return EHyperTwistTrainingCoachGuidanceLane::None;
	}

	bool IsDashboardHandoffGuidanceSource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-"));
	}

	bool IsDeferredFirstContinuationSource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-deferred-first-"))
			|| SourceLabel.StartsWith(TEXT("dashboard-handoff-deferred-first-"))
			|| SourceLabel == TEXT("recommendation-history-deferred-first-follow-up");
	}

	bool IsDeferredOverflowDashboardHandoffSource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-deferred-overflow-"))
			|| IsDeferredFirstContinuationSource(SourceLabel);
	}

	bool IsMethodDrillDashboardHandoffSource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-"))
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-narrow-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-narrow-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-narrow-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-broad-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-broad-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-broad-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-recommended");
	}

	bool IsMethodDrillRecoveryMemorySource(const FString& SourceLabel)
	{
		return IsMethodDrillDashboardHandoffSource(SourceLabel)
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-strong")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-weak")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-packet-strong")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-packet-weak")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-posture-strong")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-posture-weak")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-memory-strong")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-memory-weak")
			|| SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-structure-narrow")
			|| SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-structure-broad")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-narrow")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-broad")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned")
			|| SourceLabel
				== TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-outcome")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned")
			|| SourceLabel
				== TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-outcome")
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-"))
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-"));
	}

	bool IsMethodDrillRecoveryPacketSource(const FString& SourceLabel)
	{
		return SourceLabel.Contains(TEXT("method-drill-recovery-packet-"));
	}

	bool IsMethodDrillFollowUpPacketSource(const FString& SourceLabel)
	{
		return SourceLabel.Contains(TEXT("method-drill-follow-up-packet-"));
	}

	bool IsNarrowMethodDrillFollowUpPacketStructureSource(const FString& SourceLabel)
	{
		return SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-structure-narrow");
	}

	bool IsBroadMethodDrillFollowUpPacketStructureSource(const FString& SourceLabel)
	{
		return SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-structure-broad");
	}

	bool IsStrongMethodDrillFollowUpPacketMemorySource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-follow-up-packet-strong-"))
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-recommended")
			|| SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-strong")
			|| IsNarrowMethodDrillFollowUpPacketStructureSource(SourceLabel);
	}

	bool IsWeakMethodDrillFollowUpPacketMemorySource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-follow-up-packet-weak-"))
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-recommended")
			|| SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-weak")
			|| IsBroadMethodDrillFollowUpPacketStructureSource(SourceLabel);
	}

	bool IsStrongMethodDrillRecoveryMemorySource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-strong-"))
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-packet-strong-"))
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-posture-strong-"))
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-"))
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-queued")
			|| SourceLabel
				== TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-reliable-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-follow-up")
			|| SourceLabel
				== TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-reliable-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-recommended")
			|| SourceLabel
				== TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-reliable-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-tight-trusted-recommended")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-strong")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-packet-strong")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-posture-strong")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-memory-strong")
			|| IsNarrowMethodDrillFollowUpPacketStructureSource(SourceLabel)
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-narrow")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned")
			|| SourceLabel
				== TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-outcome");
	}

	bool IsWeakMethodDrillRecoveryMemorySource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-weak-"))
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-packet-weak-"))
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-posture-weak-"))
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-"))
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-queued")
			|| SourceLabel
				== TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-reliable-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-queued")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-follow-up")
			|| SourceLabel
				== TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-reliable-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-recommended")
			|| SourceLabel
				== TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-reliable-recommended")
			|| SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-structure-plan-broad-trusted-recommended")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-weak")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-packet-weak")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-posture-weak")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-memory-weak")
			|| IsBroadMethodDrillFollowUpPacketStructureSource(SourceLabel)
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-broad")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable")
			|| SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned")
			|| SourceLabel
				== TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-outcome");
	}

	FString DescribeRetainedMethodDrillRecoveryStanceLabel(const FString& SourceLabel)
	{
		if (IsStrongMethodDrillRecoveryMemorySource(SourceLabel))
		{
			return TEXT("strong retained drill-recovery continuation");
		}
		if (IsWeakMethodDrillRecoveryMemorySource(SourceLabel))
		{
			return TEXT("weak retained drill-recovery redirect");
		}
		return TEXT("none");
	}

	EHyperTwistTrainingCoachHandoffKind MethodDrillRecoveryPacketHandoffKindFromSourceLabel(
		const FString& SourceLabel)
	{
		if (SourceLabel.EndsWith(TEXT("-queued")))
		{
			return EHyperTwistTrainingCoachHandoffKind::Queue;
		}
		if (SourceLabel.EndsWith(TEXT("-follow-up")))
		{
			return EHyperTwistTrainingCoachHandoffKind::FollowUp;
		}
		if (SourceLabel.EndsWith(TEXT("-recommended")))
		{
			return EHyperTwistTrainingCoachHandoffKind::Recommended;
		}

		return EHyperTwistTrainingCoachHandoffKind::None;
	}

	EHyperTwistTrainingCoachHandoffKind MethodDrillFollowUpPacketHandoffKindFromSourceLabel(
		const FString& SourceLabel,
		const EHyperTwistTrainingCoachHandoffKind FallbackKind)
	{
		const EHyperTwistTrainingCoachHandoffKind ParsedKind =
			MethodDrillRecoveryPacketHandoffKindFromSourceLabel(SourceLabel);
		return ParsedKind != EHyperTwistTrainingCoachHandoffKind::None
			? ParsedKind
			: FallbackKind;
	}

	FString DescribeMethodDrillRecoveryPacketLane(
		const EHyperTwistTrainingCoachHandoffKind HandoffKind)
	{
		switch (HandoffKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			return TEXT("queue-entry");
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			return TEXT("follow-up-packet");
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			return TEXT("recommended-brief");
		default:
			return TEXT("none");
		}
	}

	FString DescribeMethodDrillFollowUpPacketLane(
		const EHyperTwistTrainingCoachHandoffKind HandoffKind)
	{
		switch (HandoffKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			return TEXT("queue-entry");
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			return TEXT("follow-up-packet");
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			return TEXT("recommended-brief");
		default:
			return TEXT("none");
		}
	}

	FString DescribeCoachHandoffKind(const EHyperTwistTrainingCoachHandoffKind HandoffKind)
	{
		switch (HandoffKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			return TEXT("queue");
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			return TEXT("follow-up");
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			return TEXT("recommended");
		default:
			return TEXT("none");
		}
	}

	FString DescribeCoachEligibilityKind(
		const EHyperTwistTrainingCoachEligibilityKind EligibilityKind
	)
	{
		switch (EligibilityKind)
		{
		case EHyperTwistTrainingCoachEligibilityKind::PrimaryAction:
			return TEXT("primary coach continuation");
		case EHyperTwistTrainingCoachEligibilityKind::Promote:
			return TEXT("deferred promotion");
		case EHyperTwistTrainingCoachEligibilityKind::Defer:
			return TEXT("defer control");
		case EHyperTwistTrainingCoachEligibilityKind::ActiveRunBlocked:
			return TEXT("active-run block");
		case EHyperTwistTrainingCoachEligibilityKind::QueueSuppressed:
			return TEXT("queue suppression");
		case EHyperTwistTrainingCoachEligibilityKind::NoEligibleAction:
			return TEXT("no eligible action");
		default:
			return TEXT("none");
		}
	}

	FString DescribeCoachQueuePostureKind(
		const EHyperTwistTrainingCoachQueuePostureKind PostureKind)
	{
		switch (PostureKind)
		{
		case EHyperTwistTrainingCoachQueuePostureKind::Continue:
			return TEXT("continue");
		case EHyperTwistTrainingCoachQueuePostureKind::Defer:
			return TEXT("defer");
		case EHyperTwistTrainingCoachQueuePostureKind::Promote:
			return TEXT("promote");
		default:
			return TEXT("none");
		}
	}

	FString DescribeGuidanceLane(const EHyperTwistTrainingCoachGuidanceLane Lane)
	{
		switch (Lane)
		{
		case EHyperTwistTrainingCoachGuidanceLane::FollowUp:
			return TEXT("follow-up");
		case EHyperTwistTrainingCoachGuidanceLane::Recommended:
			return TEXT("recommended");
		default:
			return TEXT("none");
		}
	}

	FString DescribeCoachFocusTargetLabel(
		const FString& FocusDeckId,
		const FString& FocusMethodSegmentId)
	{
		if (!FocusDeckId.IsEmpty() && !FocusMethodSegmentId.IsEmpty())
		{
			return FString::Printf(
				TEXT("deck %s | method %s"),
				*FocusDeckId,
				*FocusMethodSegmentId
			);
		}
		if (!FocusDeckId.IsEmpty())
		{
			return FString::Printf(TEXT("deck %s"), *FocusDeckId);
		}
		if (!FocusMethodSegmentId.IsEmpty())
		{
			return FString::Printf(TEXT("method %s"), *FocusMethodSegmentId);
		}

		return TEXT("no focused coach target");
	}

	FString DescribeGameplayCoachSourceLabel(const FString& SourceLabel)
	{
		if (SourceLabel.IsEmpty())
		{
			return TEXT("n/a");
		}
		if (SourceLabel.StartsWith(TEXT("coach-panel-")))
		{
			return TEXT("panel-surface coach action routing");
		}
		if (SourceLabel.StartsWith(TEXT("coach-session-actor-")))
		{
			return TEXT("session-actor coach action routing");
		}

		return DescribeCoachMemorySourceLabel(SourceLabel);
	}

	FString ExtractDelimitedStatusFieldValue(
		const FString& StatusLine,
		const FString& Prefix
	)
	{
		if (StatusLine.IsEmpty())
		{
			return FString();
		}

		TArray<FString> Segments;
		StatusLine.ParseIntoArray(Segments, TEXT("|"), true);
		for (const FString& Segment : Segments)
		{
			const FString TrimmedSegment = Segment.TrimStartAndEnd();
			if (TrimmedSegment.StartsWith(Prefix))
			{
				return TrimmedSegment.RightChop(Prefix.Len()).TrimStartAndEnd();
			}
		}

		return FString();
	}

	FString DescribePrimaryCoachActionLabel(
		const FHyperTwistTrainingCoachPanelState& PanelState,
		const EHyperTwistTrainingCoachHandoffKind ActionKind
	)
	{
		if (!PanelState.PrimaryActionLabel.IsEmpty())
		{
			return PanelState.PrimaryActionLabel;
		}

		switch (ActionKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			return TEXT("continue_queue");
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			return TEXT("start_follow_up");
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			return TEXT("start_recommended");
		default:
			return TEXT("refresh");
		}
	}

	FString DescribePrimaryCoachAvailabilityLine(
		const FHyperTwistTrainingCoachPanelState& PanelState,
		const EHyperTwistTrainingCoachHandoffKind ActionKind
	)
	{
		switch (ActionKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			return !PanelState.QueueStatusLine.IsEmpty()
				? PanelState.QueueStatusLine
				: TEXT("Queued coach run ready");
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			return !PanelState.SecondaryLine.IsEmpty()
				? PanelState.SecondaryLine
				: TEXT("Follow-up coach run ready");
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			return !PanelState.SecondaryLine.IsEmpty()
				? PanelState.SecondaryLine
				: TEXT("Recommended coach run ready");
		default:
			if (PanelState.bHasActiveRun)
			{
				return TEXT("A training run is already active");
			}
			if (!PanelState.QueueSuppressionLine.IsEmpty())
			{
				return PanelState.QueueSuppressionLine;
			}
			return !PanelState.SecondaryLine.IsEmpty()
				? PanelState.SecondaryLine
				: TEXT("No coach action ready");
		}
	}

	FString DescribePrimaryCoachDetailLine(
		const FHyperTwistTrainingCoachPanelState& PanelState,
		const EHyperTwistTrainingCoachHandoffKind ActionKind
	)
	{
		if (!PanelState.LaunchBudgetReasonLine.IsEmpty())
		{
			return PanelState.LaunchBudgetReasonLine;
		}
		if (ActionKind == EHyperTwistTrainingCoachHandoffKind::Queue
			&& !PanelState.QueueSuppressionLine.IsEmpty())
		{
			return PanelState.QueueSuppressionLine;
		}

		return PanelState.ReviewPolicyDetailLine;
	}

	const FHyperTwistTrainingCoachSessionQueueStateEntry* FindQueueEntryById(
		const FHyperTwistTrainingCoachSessionQueueState& QueueState,
		const FString& EntryId
	)
	{
		if (EntryId.IsEmpty())
		{
			return nullptr;
		}

		for (const FHyperTwistTrainingCoachSessionQueueStateEntry& Entry : QueueState.Entries)
		{
			if (Entry.EntryId == EntryId)
			{
				return &Entry;
			}
		}

		return nullptr;
	}

	float ScoreDeferredEntryForPromotion(
		const FHyperTwistTrainingCoachSessionQueueStateEntry& Entry,
		const FHyperTwistTrainingCoachPanelState& CoachPanelState
	)
	{
		float Score = FMath::Clamp(Entry.PriorityScore * 0.02f, 0.0f, 2.0f);
		if (!CoachPanelState.PreferredGuidanceSourceLabel.IsEmpty()
			&& Entry.SourceLabel == CoachPanelState.PreferredGuidanceSourceLabel)
		{
			Score += 2.0f;
		}

		switch (CoachPanelState.PreferredGuidanceLane)
		{
		case EHyperTwistTrainingCoachGuidanceLane::FollowUp:
			if (Entry.bRequiresFollowUp || Entry.SourceLabel == TEXT("follow-up-brief"))
			{
				Score += 8.0f;
			}
			if (Entry.bRequiresArchiveRetentionTuning || Entry.SourceLabel == TEXT("archive-policy"))
			{
				Score -= 4.0f;
			}
			break;
		case EHyperTwistTrainingCoachGuidanceLane::Recommended:
			if (Entry.SourceLabel == TEXT("primary-brief"))
			{
				Score += 7.0f;
			}
			if (Entry.bRequiresArchiveRetentionTuning || Entry.SourceLabel == TEXT("archive-policy"))
			{
				Score -= 1.5f;
			}
			break;
		default:
			break;
		}

		if (Entry.bPinned)
		{
			Score += 0.5f;
		}

		return Score;
	}

	const FHyperTwistTrainingCoachSessionQueueStateEntry* FindPreferredDeferredQueueEntry(
		const FHyperTwistTrainingCoachSessionQueueState& QueueState,
		const FHyperTwistTrainingCoachPanelState& CoachPanelState
	)
	{
		const FHyperTwistTrainingCoachSessionQueueStateEntry* BestDeferredEntry = nullptr;
		float BestDeferredScore = TNumericLimits<float>::Lowest();
		for (const FHyperTwistTrainingCoachSessionQueueStateEntry& Entry : QueueState.Entries)
		{
			if (Entry.EntryState != EHyperTwistTrainingCoachSessionQueueEntryState::Deferred)
			{
				continue;
			}

			const float EntryScore = ScoreDeferredEntryForPromotion(Entry, CoachPanelState);
			const bool bShouldReplaceBest = BestDeferredEntry == nullptr
				|| EntryScore > BestDeferredScore
				|| (FMath::IsNearlyEqual(EntryScore, BestDeferredScore)
					&& (Entry.SlotIndex < BestDeferredEntry->SlotIndex
						|| (Entry.SlotIndex == BestDeferredEntry->SlotIndex
							&& Entry.PriorityScore > BestDeferredEntry->PriorityScore)));
			if (bShouldReplaceBest)
			{
				BestDeferredEntry = &Entry;
				BestDeferredScore = EntryScore;
			}
		}

		return BestDeferredEntry;
	}

	FString DescribeCoachQueueDeferAvailabilityLine(
		const FHyperTwistTrainingCoachPanelState& PanelState,
		const FHyperTwistTrainingCoachSessionQueueStateEntry* ActiveQueueEntry
	)
	{
		if (ActiveQueueEntry != nullptr)
		{
			return !ActiveQueueEntry->Headline.IsEmpty()
				? FString::Printf(
					TEXT("Displayed queue entry ready to defer: %s"),
					*ActiveQueueEntry->Headline
				)
				: (!PanelState.QueueStatusLine.IsEmpty()
					? PanelState.QueueStatusLine
					: TEXT("Displayed queue entry ready to defer"));
		}

		if (!PanelState.QueueSuppressionLine.IsEmpty())
		{
			return PanelState.QueueSuppressionLine;
		}

		return PanelState.bHasQueueWork
			? TEXT("No displayed queue entry ready to defer")
			: TEXT("No queue entry ready to defer");
	}

	FString DescribeCoachQueuePromoteAvailabilityLine(
		const FHyperTwistTrainingCoachPanelState& PanelState,
		const FHyperTwistTrainingCoachSessionQueueStateEntry* DeferredQueueEntry
	)
	{
		if (DeferredQueueEntry != nullptr)
		{
			return !DeferredQueueEntry->Headline.IsEmpty()
				? FString::Printf(
					TEXT("Deferred queue recovery ready: %s"),
					*DeferredQueueEntry->Headline
				)
				: TEXT("Deferred queue entry ready to promote");
		}

		if (!PanelState.QueueSuppressionLine.IsEmpty())
		{
			return PanelState.QueueSuppressionLine;
		}

		return PanelState.bHasDeferredQueueWork
			? TEXT("No deferred queue entry ready to promote")
			: TEXT("No deferred queue entry ready to promote");
	}

	bool IsQueueRecoveryMemorySource(const FString& SourceLabel)
	{
		return SourceLabel.StartsWith(TEXT("coach-memory-queue-"))
			|| IsDashboardHandoffGuidanceSource(SourceLabel)
			|| IsMethodDrillRecoveryMemorySource(SourceLabel);
	}

	bool IsAlignedTightFollowUpGuidanceSourceLabel(const FString& SourceLabel)
	{
		return SourceLabel == TEXT("recommendation-history-aligned-tight-follow-up-outcome")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-outcome")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel == TEXT("coach-memory-aligned-follow-up-packet-structure-tight-follow-up")
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-aligned-follow-up-packet-tight-"))
			|| SourceLabel.StartsWith(
				TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-"))
			|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-tight-queued")
			|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-tight-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-tight-recommended")
			|| SourceLabel.StartsWith(
				TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-"));
	}

	bool IsAlignedBroadRecommendedGuidanceSourceLabel(const FString& SourceLabel)
	{
		return SourceLabel == TEXT("recommendation-history-aligned-broad-recommended-outcome")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-outcome")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
					TEXT("-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable")
			|| SourceLabel
				== TEXT("coach-memory-aligned-follow-up-packet-structure-broad-recommended")
			|| SourceLabel.StartsWith(TEXT("coach-memory-dashboard-aligned-follow-up-packet-broad-"))
			|| SourceLabel.StartsWith(
				TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-"))
			|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-broad-queued")
			|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-broad-follow-up")
			|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-broad-recommended")
			|| SourceLabel.StartsWith(
				TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-"));
	}

	FString DescribeCoachMemorySourceLabel(const FString& SourceLabel)
	{
		if (SourceLabel == TEXT("coach-memory-dashboard-deferred-first-follow-up"))
		{
			return TEXT("accepted deferred-first follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-deferred-first-recommended"))
		{
			return TEXT("accepted deferred-first recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-deferred-first-queued"))
		{
			return TEXT("accepted deferred-first queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-deferred-overflow-follow-up"))
		{
			return TEXT("accepted deferred-overflow follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-deferred-overflow-recommended"))
		{
			return TEXT("accepted deferred-overflow recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-deferred-overflow-queued"))
		{
			return TEXT("accepted deferred-overflow queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-follow-up"))
		{
			return TEXT("accepted follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-recommended"))
		{
			return TEXT("accepted recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-queued"))
		{
			return TEXT("accepted queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-queued"))
		{
			return TEXT("accepted drill-driven queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-follow-up"))
		{
			return TEXT("accepted drill-driven follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recommended"))
		{
			return TEXT("accepted drill-driven recommended handoff history");
		}
		if (IsAlignedTightFollowUpGuidanceSourceLabel(SourceLabel))
		{
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome acceptance history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch completion dependability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned tight follow-up-packet branch dependability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability-reliable"))
			{
				return TEXT("reliable exact accepted aligned tight follow-up-packet branch dependability reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-reliable-exact-branch-dependability"))
			{
				return TEXT("reliable exact accepted aligned tight follow-up-packet branch dependability history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-outcome-reliable-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-outcome-reliable-reliable-")))
			{
				return TEXT("reliable exact accepted aligned tight follow-up-packet branch reliability history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-outcome-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-outcome-reliable-")))
			{
				return TEXT("reliable exact accepted aligned tight follow-up-packet branch acceptance history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-outcome-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-outcome-")))
			{
				return TEXT("reliable exact accepted aligned tight follow-up-packet launched-plan outcome history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-reliable-outcome-reliable-")))
			{
				return TEXT("reliable exact accepted aligned tight follow-up-packet branch history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-reliable-outcome-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-reliable-outcome-")))
			{
				return TEXT("reliable accepted aligned tight follow-up-packet launched-plan outcome history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-reliable-")))
			{
				return TEXT("reliable accepted aligned tight follow-up-packet trust");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-tight-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-tight-")))
			{
				return TEXT("accepted aligned tight follow-up-packet outcome trust");
			}
			if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-aligned-follow-up-packet-tight-"))
				|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-tight-queued")
				|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-tight-follow-up")
				|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-tight-recommended"))
			{
				return TEXT("accepted aligned tight follow-up-packet handoff history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-tight-follow-up-packet-outcome"))
			{
				return TEXT("accepted aligned tight follow-up-packet outcome history");
			}
			return SourceLabel
					== TEXT("coach-memory-aligned-follow-up-packet-structure-tight-follow-up")
				? TEXT("aligned tight retained follow-up-packet structure history")
				: TEXT("aligned tight launched-plan follow-up outcome history");
		}
		if (IsAlignedBroadRecommendedGuidanceSourceLabel(SourceLabel))
		{
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome completion history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome acceptance history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability outcome history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch completion dependability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable-reliable"))
			{
				return TEXT("higher-order reliable exact accepted aligned broad recommended-packet branch dependability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability-reliable"))
			{
				return TEXT("reliable exact accepted aligned broad recommended-packet branch dependability reliability history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-reliable-exact-branch-dependability"))
			{
				return TEXT("reliable exact accepted aligned broad recommended-packet branch dependability history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-outcome-reliable-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-outcome-reliable-reliable-")))
			{
				return TEXT("reliable exact accepted aligned broad recommended-packet branch reliability history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-outcome-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-outcome-reliable-")))
			{
				return TEXT("reliable exact accepted aligned broad recommended-packet branch acceptance history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-outcome-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-outcome-")))
			{
				return TEXT("reliable exact accepted aligned broad recommended-packet launched-plan outcome history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-reliable-outcome-reliable-")))
			{
				return TEXT("reliable exact accepted aligned broad recommended-packet branch history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-reliable-outcome-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-reliable-outcome-")))
			{
				return TEXT("reliable accepted aligned broad recommended-packet launched-plan outcome history");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-reliable-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-reliable-")))
			{
				return TEXT("reliable accepted aligned broad recommended-packet trust");
			}
			if (SourceLabel.StartsWith(
					TEXT("coach-memory-dashboard-accepted-aligned-follow-up-packet-broad-"))
				|| SourceLabel.StartsWith(
					TEXT("dashboard-handoff-accepted-aligned-follow-up-packet-broad-")))
			{
				return TEXT("accepted aligned broad recommended-packet outcome trust");
			}
			if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-aligned-follow-up-packet-broad-"))
				|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-broad-queued")
				|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-broad-follow-up")
				|| SourceLabel == TEXT("dashboard-handoff-aligned-follow-up-packet-broad-recommended"))
			{
				return TEXT("accepted aligned broad recommended-packet handoff history");
			}
			if (SourceLabel
				== TEXT("recommendation-history-accepted-aligned-broad-recommended-packet-outcome"))
			{
				return TEXT("accepted aligned broad recommended-packet outcome history");
			}
			return SourceLabel
					== TEXT("coach-memory-aligned-follow-up-packet-structure-broad-recommended")
				? TEXT("aligned broad retained recommended-packet structure history")
				: TEXT("aligned broad launched-plan recommended outcome history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-strong-queued"))
		{
			return TEXT("accepted strong drill-recovery-memory queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-packet-strong-queued"))
		{
			return TEXT("accepted strong drill-recovery-packet queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-strong-follow-up"))
		{
			return TEXT("accepted strong drill-recovery-memory follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-packet-strong-follow-up"))
		{
			return TEXT("accepted strong drill-recovery-packet follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-strong-recommended"))
		{
			return TEXT("accepted strong drill-recovery-memory recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-packet-strong-recommended"))
		{
			return TEXT("accepted strong drill-recovery-packet recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-posture-strong-queued"))
		{
			return TEXT("accepted strong retained drill-recovery-posture queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-posture-strong-follow-up"))
		{
			return TEXT("accepted strong retained drill-recovery-posture follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-posture-strong-recommended"))
		{
			return TEXT("accepted strong retained drill-recovery-posture recommended handoff history");
		}
		if (SourceLabel
			== TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-queued"))
		{
			return TEXT("accepted aligned reliable trusted tight drill-recovery-plan queued handoff history");
		}
		if (SourceLabel
			== TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-follow-up"))
		{
			return TEXT("accepted aligned reliable trusted tight drill-recovery-plan follow-up handoff history");
		}
		if (SourceLabel
			== TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-recommended"))
		{
			return TEXT("accepted aligned reliable trusted tight drill-recovery-plan recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-reliable-queued"))
		{
			return TEXT("accepted reliable trusted tight drill-recovery-plan queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-reliable-follow-up"))
		{
			return TEXT("accepted reliable trusted tight drill-recovery-plan follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-reliable-recommended"))
		{
			return TEXT("accepted reliable trusted tight drill-recovery-plan recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-queued"))
		{
			return TEXT("accepted trusted tight drill-recovery-plan queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-follow-up"))
		{
			return TEXT("accepted trusted tight drill-recovery-plan follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-recommended"))
		{
			return TEXT("accepted trusted tight drill-recovery-plan recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-weak-queued"))
		{
			return TEXT("accepted weak drill-recovery-memory queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-packet-weak-queued"))
		{
			return TEXT("accepted weak drill-recovery-packet queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-weak-follow-up"))
		{
			return TEXT("accepted weak drill-recovery-memory follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-packet-weak-follow-up"))
		{
			return TEXT("accepted weak drill-recovery-packet follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-weak-recommended"))
		{
			return TEXT("accepted weak drill-recovery-memory recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-packet-weak-recommended"))
		{
			return TEXT("accepted weak drill-recovery-packet recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-posture-weak-queued"))
		{
			return TEXT("accepted weak retained drill-recovery-posture queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-posture-weak-follow-up"))
		{
			return TEXT("accepted weak retained drill-recovery-posture follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-posture-weak-recommended"))
		{
			return TEXT("accepted weak retained drill-recovery-posture recommended handoff history");
		}
		if (SourceLabel
			== TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-queued"))
		{
			return TEXT("accepted aligned reliable trusted broad drill-recovery-plan queued handoff history");
		}
		if (SourceLabel
			== TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-follow-up"))
		{
			return TEXT("accepted aligned reliable trusted broad drill-recovery-plan follow-up handoff history");
		}
		if (SourceLabel
			== TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-recommended"))
		{
			return TEXT("accepted aligned reliable trusted broad drill-recovery-plan recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-reliable-queued"))
		{
			return TEXT("accepted reliable trusted broad drill-recovery-plan queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-reliable-follow-up"))
		{
			return TEXT("accepted reliable trusted broad drill-recovery-plan follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-reliable-recommended"))
		{
			return TEXT("accepted reliable trusted broad drill-recovery-plan recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-queued"))
		{
			return TEXT("accepted trusted broad drill-recovery-plan queued handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-follow-up"))
		{
			return TEXT("accepted trusted broad drill-recovery-plan follow-up handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-recommended"))
		{
			return TEXT("accepted trusted broad drill-recovery-plan recommended handoff history");
		}
		if (SourceLabel == TEXT("coach-memory-queue-follow-up"))
		{
			return TEXT("queue follow-up recovery memory");
		}
		if (SourceLabel == TEXT("coach-memory-queue-recommended"))
		{
			return TEXT("queue recommended recovery memory");
		}
		if (SourceLabel == TEXT("dashboard-handoff-queued"))
		{
			return TEXT("accepted queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-deferred-first-queued"))
		{
			return TEXT("accepted deferred-first queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-follow-up"))
		{
			return TEXT("accepted follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-deferred-first-follow-up"))
		{
			return TEXT("accepted deferred-first follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-recommended"))
		{
			return TEXT("accepted recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-deferred-first-recommended"))
		{
			return TEXT("accepted deferred-first recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-queued"))
		{
			return TEXT("accepted drill-driven queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up"))
		{
			return TEXT("accepted drill-driven follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recommended"))
		{
			return TEXT("accepted drill-driven recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-queued"))
		{
			return TEXT("accepted strong drill-follow-up-packet queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-follow-up"))
		{
			return TEXT("accepted strong drill-follow-up-packet follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-strong-recommended"))
		{
			return TEXT("accepted strong drill-follow-up-packet recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-queued"))
		{
			return TEXT("accepted weak drill-follow-up-packet queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-follow-up"))
		{
			return TEXT("accepted weak drill-follow-up-packet follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-follow-up-packet-weak-recommended"))
		{
			return TEXT("accepted weak drill-follow-up-packet recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-queued"))
		{
			return TEXT("accepted strong drill-recovery-memory queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-queued"))
		{
			return TEXT("accepted strong drill-recovery-packet queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-follow-up"))
		{
			return TEXT("accepted strong drill-recovery-memory follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-follow-up"))
		{
			return TEXT("accepted strong drill-recovery-packet follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-strong-recommended"))
		{
			return TEXT("accepted strong drill-recovery-memory recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-strong-recommended"))
		{
			return TEXT("accepted strong drill-recovery-packet recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-queued"))
		{
			return TEXT("accepted strong retained drill-recovery-posture queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-follow-up"))
		{
			return TEXT("accepted strong retained drill-recovery-posture follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-strong-recommended"))
		{
			return TEXT("accepted strong retained drill-recovery-posture recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-queued"))
		{
			return TEXT("accepted weak drill-recovery-memory queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-queued"))
		{
			return TEXT("accepted weak drill-recovery-packet queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-follow-up"))
		{
			return TEXT("accepted weak drill-recovery-memory follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-follow-up"))
		{
			return TEXT("accepted weak drill-recovery-packet follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-weak-recommended"))
		{
			return TEXT("accepted weak drill-recovery-memory recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-packet-weak-recommended"))
		{
			return TEXT("accepted weak drill-recovery-packet recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-queued"))
		{
			return TEXT("accepted weak retained drill-recovery-posture queued dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-follow-up"))
		{
			return TEXT("accepted weak retained drill-recovery-posture follow-up dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-handoff-method-drill-recovery-posture-weak-recommended"))
		{
			return TEXT("accepted weak retained drill-recovery-posture recommended dashboard handoff");
		}
		if (SourceLabel == TEXT("dashboard-guidance-outcome-deferred-overflow-queued"))
		{
			return TEXT("accepted deferred-overflow queued outcome handoff");
		}
		if (SourceLabel == TEXT("dashboard-guidance-outcome-deferred-overflow-follow-up"))
		{
			return TEXT("accepted deferred-overflow follow-up outcome handoff");
		}
		if (SourceLabel == TEXT("dashboard-guidance-outcome-deferred-overflow-recommended"))
		{
			return TEXT("accepted deferred-overflow recommended outcome handoff");
		}
		if (SourceLabel == TEXT("queue-history-promote-pressure"))
		{
			return TEXT("queue promote-pressure history");
		}
		if (SourceLabel == TEXT("queue-history-launch-pressure"))
		{
			return TEXT("queue launch-pressure history");
		}
		if (SourceLabel == TEXT("queue-history-balanced-pressure"))
		{
			return TEXT("balanced queue-recovery history");
		}
		if (SourceLabel == TEXT("recommendation-history-broadened-launch"))
		{
			return TEXT("successful broadened-launch history");
		}
		if (SourceLabel == TEXT("recommendation-history-tightened-launch"))
		{
			return TEXT("successful tightened-launch history");
		}
		if (SourceLabel == TEXT("recommendation-history-deferred-tightened-launch"))
		{
			return TEXT("successful deferred tightened-launch history");
		}
		if (SourceLabel == TEXT("recommendation-history-deferred-first-follow-up"))
		{
			return TEXT("successful deferred-first follow-up packet history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-follow-up-strong"))
		{
			return TEXT("successful method-drill follow-up history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-strong"))
		{
			return TEXT("successful drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-structure-narrow"))
		{
			return TEXT("successful narrow drill-follow-up-packet structure history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-follow-up-packet-strong-queued"))
		{
			return TEXT("successful queued drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-follow-up-packet-strong-follow-up"))
		{
			return TEXT("successful follow-up drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-follow-up-packet-strong-recommended"))
		{
			return TEXT("successful recommended drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-follow-up-weak"))
		{
			return TEXT("weak method-drill follow-up history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-weak"))
		{
			return TEXT("weak drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-follow-up-packet-structure-broad"))
		{
			return TEXT("successful broad drill-follow-up-packet redirect history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-follow-up-packet-weak-queued"))
		{
			return TEXT("weak queued drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-follow-up-packet-weak-follow-up"))
		{
			return TEXT("weak follow-up drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-dashboard-method-drill-follow-up-packet-weak-recommended"))
		{
			return TEXT("weak recommended drill-follow-up-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-strong"))
		{
			return TEXT("successful drill-driven recovery history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-weak"))
		{
			return TEXT("weak drill-driven recovery history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-memory-strong"))
		{
			return TEXT("successful retained drill-recovery-memory history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-narrow"))
		{
			return TEXT("successful narrow drill-recovery-structure history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight"))
		{
			return TEXT("successful tight drill-recovery-plan history");
		}
		if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-reliable-")))
		{
			return TEXT("accepted reliable trusted tight drill-recovery-plan dashboard handoff");
		}
		if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-trusted-")))
		{
			return TEXT("accepted trusted tight drill-recovery-plan dashboard handoff");
		}
		if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-tight-")))
		{
			return TEXT("accepted tight drill-recovery-plan dashboard handoff");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted"))
		{
			return TEXT("trusted tight drill-recovery-plan history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable"))
		{
			return TEXT("reliable trusted tight drill-recovery-plan history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned"))
		{
			return TEXT("aligned reliable trusted tight drill-recovery-plan history");
		}
		if (SourceLabel
			== TEXT("coach-memory-method-drill-recovery-structure-plan-tight-trusted-reliable-aligned-outcome"))
		{
			return TEXT("successful aligned reliable trusted tight drill-recovery-plan handoff outcome history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-packet-strong"))
		{
			return TEXT("successful retained drill-recovery-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-memory-weak"))
		{
			return TEXT("weak retained drill-recovery-memory history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-broad"))
		{
			return TEXT("successful broad drill-recovery-structure redirect history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad"))
		{
			return TEXT("successful broad drill-recovery-plan redirect history");
		}
		if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-reliable-")))
		{
			return TEXT("accepted reliable trusted broad drill-recovery-plan dashboard handoff");
		}
		if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-trusted-")))
		{
			return TEXT("accepted trusted broad drill-recovery-plan dashboard handoff");
		}
		if (SourceLabel.StartsWith(TEXT("coach-memory-dashboard-method-drill-recovery-structure-plan-broad-")))
		{
			return TEXT("accepted broad drill-recovery-plan dashboard handoff");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted"))
		{
			return TEXT("trusted broad drill-recovery-plan redirect history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable"))
		{
			return TEXT("reliable trusted broad drill-recovery-plan redirect history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned"))
		{
			return TEXT("aligned reliable trusted broad drill-recovery-plan redirect history");
		}
		if (SourceLabel
			== TEXT("coach-memory-method-drill-recovery-structure-plan-broad-trusted-reliable-aligned-outcome"))
		{
			return TEXT("successful aligned reliable trusted broad drill-recovery-plan redirect outcome history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-packet-weak"))
		{
			return TEXT("weak retained drill-recovery-packet history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-posture-strong"))
		{
			return TEXT("successful retained drill-recovery-posture history");
		}
		if (SourceLabel == TEXT("coach-memory-method-drill-recovery-posture-weak"))
		{
			return TEXT("weak retained drill-recovery-posture history");
		}

		return SourceLabel.IsEmpty() ? TEXT("none") : SourceLabel;
	}

	FString DescribeLaunchBudgetBiasLabel(const int32 LaunchBudgetBias)
	{
		if (LaunchBudgetBias > 0)
		{
			return TEXT("broaden");
		}
		if (LaunchBudgetBias < 0)
		{
			return TEXT("tighten");
		}

		return TEXT("neutral");
	}

	FString DescribeLaunchBudgetScopeLabel(
		const bool bBroadenedLaunchBudget,
		const bool bTightenedLaunchBudget)
	{
		if (bBroadenedLaunchBudget)
		{
			return TEXT("broadened");
		}
		if (bTightenedLaunchBudget)
		{
			return TEXT("tightened");
		}

		return TEXT("stable");
	}

	float ResolveDeferredLaunchRecoveryPressure(const FHyperTwistCoachBrief& FollowUpBrief)
	{
		if (!FollowUpBrief.bNeedsDeferredLaunchRecovery || FollowUpBrief.DeferredLaunchCaseCount <= 0)
		{
			return 0.0f;
		}

		return FMath::Clamp(
			6.0f
			+ (static_cast<float>(FollowUpBrief.DeferredLaunchCaseCount) * 2.0f)
			+ (FollowUpBrief.bHasTightenedLaunchOverflow ? 4.0f : 0.0f)
			+ (FollowUpBrief.bNeedsCoachReview ? 3.0f : 0.0f),
			0.0f,
			18.0f
		);
	}

	TArray<FString> MergeFocusCaseIds(
		const TArray<FString>& PrimaryCaseIds,
		const TArray<FString>& SecondaryCaseIds)
	{
		TArray<FString> MergedCaseIds = PrimaryCaseIds;
		for (const FString& CaseId : SecondaryCaseIds)
		{
			if (!CaseId.IsEmpty() && !MergedCaseIds.Contains(CaseId))
			{
				MergedCaseIds.Add(CaseId);
			}
		}

		return MergedCaseIds;
	}

	float ResolvePreferredGuidanceLanePressure(
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot)
	{
		if (CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::None)
		{
			return 0.0f;
		}

		if (CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp)
		{
			return FMath::Clamp(
				4.0f
				+ static_cast<float>(CoachMemorySnapshot.FollowUpGuidanceContinueBias)
				+ (static_cast<float>(CoachMemorySnapshot.SuppressedPrimaryQueuePressureCount) * 1.5f)
				+ (static_cast<float>(CoachMemorySnapshot.FollowUpReadyCoachSequenceCount) * 1.5f)
				+ (static_cast<float>(CoachMemorySnapshot.ScheduleBlockedFollowUpEventCount) * 2.0f),
				0.0f,
				12.0f
			);
		}

		return FMath::Clamp(
			4.0f
			+ static_cast<float>(CoachMemorySnapshot.RecommendedGuidanceContinueBias)
			+ (static_cast<float>(CoachMemorySnapshot.SuppressedFollowUpQueuePressureCount) * 1.5f)
			+ (static_cast<float>(CoachMemorySnapshot.RepeatRecommendationSequenceCount) * 1.5f)
			+ (CoachMemorySnapshot.bHasRepeatRecommendationPressure ? 4.0f : 0.0f),
			0.0f,
			12.0f
		);
	}

	float ResolveDeferredFirstFollowUpPacketPressure(
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot)
	{
		const bool bPreferredGuidanceSource =
			IsDeferredFirstContinuationSource(
				CoachMemorySnapshot.PreferredGuidanceSourceLabel
			);
		const bool bPreferredHandoffSource =
			IsDeferredFirstContinuationSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		if (CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount <= 0
			&& !bPreferredGuidanceSource
			&& !bPreferredHandoffSource)
		{
			return 0.0f;
		}

		return FMath::Clamp(
			(static_cast<float>(CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount) * 1.5f)
			+ (bPreferredGuidanceSource ? 2.0f : 0.0f)
			+ (bPreferredHandoffSource ? 2.0f : 0.0f),
			0.0f,
			8.0f
		);
	}

	float ResolveMethodDrillFollowUpContinuationPressure(
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot)
	{
		const bool bPreferredGuidanceSource =
			CoachMemorySnapshot.PreferredGuidanceSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-strong")
			|| CoachMemorySnapshot.PreferredGuidanceSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-packet-strong")
			|| CoachMemorySnapshot.PreferredGuidanceSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-packet-structure-narrow");
		const bool bPreferredHandoffSource =
			CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-strong")
			|| CoachMemorySnapshot.PreferredCoachHandoffSourceLabel.StartsWith(
				TEXT("coach-memory-dashboard-method-drill-follow-up-packet-strong-"));
		if (CoachMemorySnapshot.MethodDrillFollowUpHistoryCount <= 0
			&& !bPreferredGuidanceSource
			&& !bPreferredHandoffSource)
		{
			return 0.0f;
		}

		const bool bStrongHistoryDominant =
			CoachMemorySnapshot.StrongMethodDrillFollowUpHistoryCount
				>= CoachMemorySnapshot.WeakMethodDrillFollowUpHistoryCount
			&& CoachMemorySnapshot.MethodDrillFollowUpAverageOutcomeScore >= 60.0f;
		if (!bStrongHistoryDominant && !bPreferredGuidanceSource && !bPreferredHandoffSource)
		{
			return 0.0f;
		}

		return FMath::Clamp(
			(static_cast<float>(CoachMemorySnapshot.StrongMethodDrillFollowUpHistoryCount) * 1.25f)
			+ (static_cast<float>(CoachMemorySnapshot.MethodDrillFollowUpHistoryCount) * 0.35f)
			+ (bPreferredGuidanceSource ? 2.0f : 0.0f)
			+ (bPreferredHandoffSource ? 2.0f : 0.0f),
			0.0f,
			8.0f
		);
	}

	float ResolveMethodDrillFollowUpRedirectPressure(
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot)
	{
		const bool bPreferredGuidanceSource =
			CoachMemorySnapshot.PreferredGuidanceSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-weak")
			|| CoachMemorySnapshot.PreferredGuidanceSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-packet-weak")
			|| CoachMemorySnapshot.PreferredGuidanceSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-packet-structure-broad");
		const bool bPreferredHandoffSource =
			CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
				== TEXT("coach-memory-method-drill-follow-up-weak")
			|| CoachMemorySnapshot.PreferredCoachHandoffSourceLabel.StartsWith(
				TEXT("coach-memory-dashboard-method-drill-follow-up-packet-weak-"));
		if (CoachMemorySnapshot.MethodDrillFollowUpHistoryCount <= 0
			&& !bPreferredGuidanceSource
			&& !bPreferredHandoffSource)
		{
			return 0.0f;
		}

		const bool bWeakHistoryDominant =
			CoachMemorySnapshot.WeakMethodDrillFollowUpHistoryCount
				> CoachMemorySnapshot.StrongMethodDrillFollowUpHistoryCount
			&& CoachMemorySnapshot.MethodDrillFollowUpAverageOutcomeScore <= 55.0f;
		if (!bWeakHistoryDominant && !bPreferredGuidanceSource && !bPreferredHandoffSource)
		{
			return 0.0f;
		}

		return FMath::Clamp(
			(static_cast<float>(CoachMemorySnapshot.WeakMethodDrillFollowUpHistoryCount) * 1.5f)
			+ (static_cast<float>(CoachMemorySnapshot.MethodDrillFollowUpHistoryCount) * 0.25f)
			+ (bPreferredGuidanceSource ? 2.0f : 0.0f)
			+ (bPreferredHandoffSource ? 2.0f : 0.0f),
			0.0f,
			8.0f
		);
	}

	float ResolveMethodDrillFollowUpQueueBias(
		const FString& SourceLabel,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const bool bHasCompetingGuidanceEntry)
	{
		const float ContinuationPressure =
			ResolveMethodDrillFollowUpContinuationPressure(CoachMemorySnapshot);
		const float RedirectPressure =
			ResolveMethodDrillFollowUpRedirectPressure(CoachMemorySnapshot);
		if (FMath::IsNearlyZero(ContinuationPressure)
			&& FMath::IsNearlyZero(RedirectPressure))
		{
			return 0.0f;
		}

		if (SourceLabel == TEXT("follow-up-brief"))
		{
			return FMath::Clamp(
				ContinuationPressure - (RedirectPressure * 0.75f),
				-5.0f,
				6.0f
			);
		}
		if (SourceLabel == TEXT("primary-brief") && bHasCompetingGuidanceEntry)
		{
			return FMath::Clamp(
				RedirectPressure - (ContinuationPressure * 0.55f),
				-4.0f,
				5.0f
			);
		}

		return 0.0f;
	}

	float ResolvePreferredGuidanceQueueBias(
		const FString& SourceLabel,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const bool bHasCompetingGuidanceEntry)
	{
		if (CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::None)
		{
			return 0.0f;
		}

		const EHyperTwistTrainingCoachGuidanceLane EntryLane = GuidanceLaneFromSourceLabel(SourceLabel);
		if (EntryLane == EHyperTwistTrainingCoachGuidanceLane::None)
		{
			return 0.0f;
		}

		const float ClampedBoost = ResolvePreferredGuidanceLanePressure(CoachMemorySnapshot);
		if (EntryLane == CoachMemorySnapshot.PreferredGuidanceLane)
		{
			return ClampedBoost;
		}

		return bHasCompetingGuidanceEntry
			? -FMath::Clamp(ClampedBoost * 0.5f, 0.0f, 4.0f)
			: 0.0f;
	}

	float ResolveArchiveCompetitionQueueBias(
		const FString& SourceLabel,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const FHyperTwistTrainingCoachArchivePolicySummary& ArchivePolicySummary,
		const bool bHasFollowUpEntry,
		const bool bHasArchiveEntry)
	{
		if (!bHasFollowUpEntry
			|| !bHasArchiveEntry
			|| CoachMemorySnapshot.PreferredGuidanceLane != EHyperTwistTrainingCoachGuidanceLane::FollowUp)
		{
			return 0.0f;
		}

		const float FollowUpPressure = FMath::Clamp(
			ResolvePreferredGuidanceLanePressure(CoachMemorySnapshot),
			0.0f,
			10.0f
		);
		const float ArchiveResistance = FMath::Clamp(
			(ArchivePolicySummary.bNeedsArchiveRetentionTuning ? 2.0f : 0.0f)
			+ (ArchivePolicySummary.bHasActiveArchivePressure ? 1.5f : 0.0f)
			+ (static_cast<float>(ArchivePolicySummary.ReopenRiskArchivedCaseCount) * 0.35f)
			+ (static_cast<float>(ArchivePolicySummary.EscalationRetainedCaseCount) * 0.2f)
			+ FMath::Clamp(ArchivePolicySummary.ArchiveRetentionTuningScore * 0.08f, 0.0f, 4.0f),
			0.0f,
			8.0f
		);

		const float FollowUpBoost = FMath::Clamp(
			(FollowUpPressure * 0.55f)
			+ (CoachMemorySnapshot.bHasBlockedFollowUpScheduleFriction ? 1.0f : 0.0f)
			- (ArchiveResistance * 0.2f),
			0.0f,
			5.0f
		);
		const float ArchivePenalty = FMath::Clamp(
			(FollowUpPressure * 0.4f)
			+ (CoachMemorySnapshot.bHasBlockedFollowUpScheduleFriction ? 1.25f : 0.0f)
			- (ArchiveResistance * 0.3f),
			0.0f,
			4.0f
		);

		if (SourceLabel == TEXT("follow-up-brief"))
		{
			return FollowUpBoost;
		}
		if (SourceLabel == TEXT("archive-policy"))
		{
			return -ArchivePenalty;
		}

		return 0.0f;
	}

	float ResolvePreferredRecoveryActionQueueBias(
		const FString& SourceLabel,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const bool bHasCompetingGuidanceEntry,
		const bool bHasArchiveEntry)
	{
		if (!CoachMemorySnapshot.bNeedsScheduleFrictionRecovery
			|| CoachMemorySnapshot.PreferredQueueRecoveryAction == EHyperTwistTrainingQueueRecoveryAction::None)
		{
			return 0.0f;
		}

		const EHyperTwistTrainingCoachGuidanceLane EntryLane = GuidanceLaneFromSourceLabel(SourceLabel);
		const bool bMatchesPreferredLane =
			EntryLane != EHyperTwistTrainingCoachGuidanceLane::None
			&& EntryLane == CoachMemorySnapshot.PreferredGuidanceLane;

		if (CoachMemorySnapshot.PreferredQueueRecoveryAction
			== EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred)
		{
			if (bMatchesPreferredLane)
			{
				return 5.0f;
			}
			if (SourceLabel == TEXT("archive-policy") && bHasArchiveEntry)
			{
				return -2.5f;
			}
			if (bHasCompetingGuidanceEntry && EntryLane != EHyperTwistTrainingCoachGuidanceLane::None)
			{
				return -2.0f;
			}

			return 0.0f;
		}

		if (CoachMemorySnapshot.PreferredQueueRecoveryAction
			== EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery)
		{
			if (bMatchesPreferredLane)
			{
				return 2.5f;
			}
			if (SourceLabel == TEXT("archive-policy") && bHasArchiveEntry && bHasCompetingGuidanceEntry)
			{
				return -1.5f;
			}
			if (bHasCompetingGuidanceEntry && EntryLane != EHyperTwistTrainingCoachGuidanceLane::None)
			{
				return -0.75f;
			}
		}

		return 0.0f;
	}

	float ResolveDeferredLaunchCompetitionQueueBias(
		const FString& SourceLabel,
		const FHyperTwistCoachBrief& FollowUpBrief,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const bool bHasCompetingGuidanceEntry,
		const bool bHasArchiveEntry)
	{
		const float DeferredLaunchPressure = ResolveDeferredLaunchRecoveryPressure(FollowUpBrief);
		if (DeferredLaunchPressure <= 0.0f)
		{
			return 0.0f;
		}

		float FollowUpBoost = FMath::Clamp(
			(DeferredLaunchPressure * 0.6f)
			+ (bHasCompetingGuidanceEntry ? 1.5f : 0.0f)
			+ (FollowUpBrief.bHasTightenedLaunchOverflow ? 1.5f : 0.0f),
			0.0f,
			9.0f
		);
		float PrimaryPenalty = FMath::Clamp(
			(DeferredLaunchPressure * 0.4f)
			+ (bHasCompetingGuidanceEntry ? 1.0f : 0.0f),
			0.0f,
			6.0f
		);
		float ArchivePenalty = FMath::Clamp(
			(DeferredLaunchPressure * 0.22f)
			+ (FollowUpBrief.bHasTightenedLaunchOverflow ? 0.5f : 0.0f),
			0.0f,
			3.0f
		);
		const float DeferredFirstPacketPressure = ResolveDeferredFirstFollowUpPacketPressure(
			CoachMemorySnapshot
		);
		if (DeferredFirstPacketPressure > 0.0f)
		{
			const bool bFollowUpPreferredLane =
				CoachMemorySnapshot.PreferredGuidanceLane
					== EHyperTwistTrainingCoachGuidanceLane::FollowUp;
			FollowUpBoost = FMath::Clamp(
				FollowUpBoost
					+ (DeferredFirstPacketPressure * 0.7f)
					+ (bFollowUpPreferredLane ? 1.0f : 0.0f),
				0.0f,
				12.0f
			);
			PrimaryPenalty = FMath::Clamp(
				PrimaryPenalty + (DeferredFirstPacketPressure * 0.55f),
				0.0f,
				8.0f
			);
			ArchivePenalty = FMath::Clamp(
				ArchivePenalty + (DeferredFirstPacketPressure * 0.2f),
				0.0f,
				4.0f
			);
		}

		if (SourceLabel == TEXT("follow-up-brief"))
		{
			return FollowUpBoost;
		}
		if (SourceLabel == TEXT("primary-brief") && bHasCompetingGuidanceEntry)
		{
			return -PrimaryPenalty;
		}
		if (SourceLabel == TEXT("archive-policy")
			&& bHasArchiveEntry
			&& FollowUpBrief.bHasTightenedLaunchOverflow)
		{
			return -ArchivePenalty;
		}

		return 0.0f;
	}

	bool ShouldCreatePrimaryQueueEntry(
		const FHyperTwistCoachBrief& CurrentBrief,
		const FHyperTwistCoachBrief& FollowUpBrief,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const bool bHasFollowUpEntry,
		FString* OutSuppressionReason = nullptr)
	{
		if (OutSuppressionReason != nullptr)
		{
			OutSuppressionReason->Reset();
		}
		if (CurrentBrief.UserId.IsEmpty())
		{
			return false;
		}
		if (!bHasFollowUpEntry)
		{
			return true;
		}
		const bool bNeedsDeferredLaunchCompetition =
			FollowUpBrief.bNeedsDeferredLaunchRecovery && FollowUpBrief.DeferredLaunchCaseCount > 0;
		const float DeferredFirstPacketPressure = ResolveDeferredFirstFollowUpPacketPressure(
			CoachMemorySnapshot
		);
		const FString DeferredFirstHistorySourceLabel =
			HyperTwistTrainingCoachLibraryInternal::IsDeferredFirstContinuationSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			)
				? HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
					CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
				)
				: (HyperTwistTrainingCoachLibraryInternal::IsDeferredFirstContinuationSource(
					CoachMemorySnapshot.PreferredGuidanceSourceLabel
				)
					? HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
						CoachMemorySnapshot.PreferredGuidanceSourceLabel
					)
					: TEXT("successful deferred-first continuation history"));
		const bool bDeferredFirstFollowUpHistoryPreferred = DeferredFirstPacketPressure > 0.0f;
		const float MethodDrillContinuationPressure =
			ResolveMethodDrillFollowUpContinuationPressure(CoachMemorySnapshot);
		const float MethodDrillRedirectPressure =
			ResolveMethodDrillFollowUpRedirectPressure(CoachMemorySnapshot);
		const bool bScheduleRecoveryPrefersFollowUp =
			CoachMemorySnapshot.bNeedsScheduleFrictionRecovery
			&& CoachMemorySnapshot.PreferredQueueRecoveryAction
				== EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred
			&& CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp;
		if (!bScheduleRecoveryPrefersFollowUp
			&& !bNeedsDeferredLaunchCompetition
			&& !bDeferredFirstFollowUpHistoryPreferred
			&& FMath::IsNearlyZero(MethodDrillContinuationPressure)
			&& FMath::IsNearlyZero(MethodDrillRedirectPressure))
		{
			return true;
		}

		const float DeferredLaunchPressure = ResolveDeferredLaunchRecoveryPressure(FollowUpBrief);
		const float RecommendedRetentionScore =
			CurrentBrief.PriorityScore
			+ static_cast<float>(CoachMemorySnapshot.RecommendedGuidanceContinueBias)
			+ (MethodDrillRedirectPressure * 1.5f);
		const float FollowUpPressureScore =
			FollowUpBrief.PriorityScore
			+ static_cast<float>(CoachMemorySnapshot.FollowUpGuidanceContinueBias)
			+ (static_cast<float>(CoachMemorySnapshot.SuppressedPrimaryQueuePressureCount) * 2.0f)
			+ (FollowUpBrief.bNeedsCoachReview ? 8.0f : 0.0f)
			+ DeferredLaunchPressure
			+ DeferredFirstPacketPressure
			+ (MethodDrillContinuationPressure * 1.5f);
		const float RecommendedRetentionThreshold =
			bDeferredFirstFollowUpHistoryPreferred ? 10.0f : 8.0f;
		const bool bShouldCreate =
			RecommendedRetentionScore >= FollowUpPressureScore + RecommendedRetentionThreshold;
		if (!bShouldCreate && OutSuppressionReason != nullptr)
		{
			if (bNeedsDeferredLaunchCompetition && bDeferredFirstFollowUpHistoryPreferred)
			{
				*OutSuppressionReason = FString::Printf(
					TEXT("Recommended queue creation was suppressed because %s is reinforcing narrowed continuation while tightened-budget deferred coach work remains unresolved (recommended %.1f vs follow-up %.1f, deferredLaunchCases=%d, deferredFirstHistory=%d)."),
					*DeferredFirstHistorySourceLabel,
					RecommendedRetentionScore,
					FollowUpPressureScore,
					FollowUpBrief.DeferredLaunchCaseCount,
					CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount
				);
			}
			else if (bNeedsDeferredLaunchCompetition)
			{
				*OutSuppressionReason = FString::Printf(
					TEXT("Recommended queue creation was suppressed because tightened-budget deferred coach work is still unresolved (recommended %.1f vs follow-up %.1f, deferredLaunchCases=%d)."),
					RecommendedRetentionScore,
					FollowUpPressureScore,
					FollowUpBrief.DeferredLaunchCaseCount
				);
			}
			else if (bDeferredFirstFollowUpHistoryPreferred)
			{
				*OutSuppressionReason = FString::Printf(
					TEXT("Recommended queue creation was suppressed because %s is reinforcing narrowed continuation before broader recommendation work resumes (recommended %.1f vs follow-up %.1f, deferredFirstHistory=%d)."),
					*DeferredFirstHistorySourceLabel,
					RecommendedRetentionScore,
					FollowUpPressureScore,
					CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount
				);
			}
			else if (MethodDrillContinuationPressure > MethodDrillRedirectPressure)
			{
				*OutSuppressionReason = FString::Printf(
					TEXT("Recommended queue creation was suppressed because successful method-drill follow-up history is reinforcing narrow continuation before broader recommendation work resumes (recommended %.1f vs follow-up %.1f, drillHistory=%d, avgDrillOutcome=%.1f)."),
					RecommendedRetentionScore,
					FollowUpPressureScore,
					CoachMemorySnapshot.MethodDrillFollowUpHistoryCount,
					CoachMemorySnapshot.MethodDrillFollowUpAverageOutcomeScore
				);
			}
			else
			{
				*OutSuppressionReason = FString::Printf(
					TEXT("Recommended queue creation was suppressed because follow-up recovery is preferred for promote-deferred recovery (recommended %.1f vs follow-up %.1f)."),
					RecommendedRetentionScore,
					FollowUpPressureScore
				);
			}
		}
		return bShouldCreate;
	}

	bool ShouldCreateFollowUpQueueEntry(
		const FHyperTwistCoachBrief& CurrentBrief,
		const FHyperTwistCoachBrief& FollowUpBrief,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		FString* OutSuppressionReason = nullptr)
	{
		if (OutSuppressionReason != nullptr)
		{
			OutSuppressionReason->Reset();
		}
		if (FollowUpBrief.UserId.IsEmpty() || FollowUpBrief.FocusCaseIds.Num() <= 0)
		{
			return false;
		}
		if (FollowUpBrief.bNeedsDeferredLaunchRecovery && FollowUpBrief.DeferredLaunchCaseCount > 0)
		{
			return true;
		}
		const float MethodDrillContinuationPressure =
			ResolveMethodDrillFollowUpContinuationPressure(CoachMemorySnapshot);
		const float MethodDrillRedirectPressure =
			ResolveMethodDrillFollowUpRedirectPressure(CoachMemorySnapshot);
		const bool bRecommendedLaunchRecoveryGate =
			CoachMemorySnapshot.bNeedsScheduleFrictionRecovery
			&& CoachMemorySnapshot.PreferredQueueRecoveryAction
				== EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery
			&& CoachMemorySnapshot.PreferredGuidanceLane
				== EHyperTwistTrainingCoachGuidanceLane::Recommended;
		if (!bRecommendedLaunchRecoveryGate && FMath::IsNearlyZero(MethodDrillRedirectPressure))
		{
			return true;
		}
		if (FollowUpBrief.bNeedsCoachReview || FollowUpBrief.FocusCaseIds.Num() > 2)
		{
			return true;
		}

		const float RecommendedPressureScore =
			CurrentBrief.PriorityScore
			+ static_cast<float>(CoachMemorySnapshot.RecommendedGuidanceContinueBias)
			+ (static_cast<float>(CoachMemorySnapshot.SuppressedFollowUpQueuePressureCount) * 2.0f)
			+ (CoachMemorySnapshot.bHasRepeatRecommendationPressure ? 4.0f : 0.0f)
			+ (MethodDrillRedirectPressure * 1.5f);
		const float FollowUpRetentionScore =
			FollowUpBrief.PriorityScore
			+ static_cast<float>(CoachMemorySnapshot.FollowUpGuidanceContinueBias)
			+ (MethodDrillContinuationPressure * 1.25f);
		const bool bShouldCreate = FollowUpRetentionScore >= RecommendedPressureScore + 8.0f;
		if (!bShouldCreate && OutSuppressionReason != nullptr)
		{
			if (MethodDrillRedirectPressure > MethodDrillContinuationPressure)
			{
				*OutSuppressionReason = FString::Printf(
					TEXT("Follow-up queue creation was suppressed because weak method-drill follow-up history is pushing control back toward broader recommended work (follow-up %.1f vs recommended %.1f, drillHistory=%d, avgDrillOutcome=%.1f)."),
					FollowUpRetentionScore,
					RecommendedPressureScore,
					CoachMemorySnapshot.MethodDrillFollowUpHistoryCount,
					CoachMemorySnapshot.MethodDrillFollowUpAverageOutcomeScore
				);
			}
			else
			{
				*OutSuppressionReason = FString::Printf(
					TEXT("Follow-up queue creation was suppressed because recommended-lane launch recovery is preferred (follow-up %.1f vs recommended %.1f)."),
					FollowUpRetentionScore,
					RecommendedPressureScore
				);
			}
		}
		return bShouldCreate;
	}

	float ResolvePreferredGuidanceSignalBias(
		const EHyperTwistTrainingCoachGuidanceLane SignalLane,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const bool bHasCompetingGuidancePressure)
	{
		if (CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::None
			|| SignalLane == EHyperTwistTrainingCoachGuidanceLane::None)
		{
			return 0.0f;
		}

		const float ClampedBoost = FMath::Clamp(
			ResolvePreferredGuidanceLanePressure(CoachMemorySnapshot),
			0.0f,
			8.0f
		);
		if (SignalLane == CoachMemorySnapshot.PreferredGuidanceLane)
		{
			return ClampedBoost;
		}

		return bHasCompetingGuidancePressure
			? -FMath::Clamp(ClampedBoost * 0.35f, 0.0f, 3.0f)
			: 0.0f;
	}

	void ApplyGuidancePreferenceToSignal(
		FHyperTwistCoachSignal& Signal,
		const EHyperTwistTrainingCoachGuidanceLane SignalLane,
		const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
		const bool bHasCompetingGuidancePressure)
	{
		const float ScoreBias = ResolvePreferredGuidanceSignalBias(
			SignalLane,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		if (FMath::IsNearlyZero(ScoreBias))
		{
			return;
		}

		Signal.Score = FMath::Clamp(Signal.Score + ScoreBias, 0.0f, 100.0f);
		Signal.Priority = PriorityFromScore(Signal.Score);
		Signal.bNeedsImmediateAttention = Signal.Priority == EHyperTwistCoachPriority::Critical;
	}

	EHyperTwistCoachPriority PriorityFromScore(const float Score)
	{
		if (Score >= 85.0f)
		{
			return EHyperTwistCoachPriority::Critical;
		}
		if (Score >= 65.0f)
		{
			return EHyperTwistCoachPriority::Elevated;
		}
		if (Score >= 40.0f)
		{
			return EHyperTwistCoachPriority::Advisory;
		}

		return EHyperTwistCoachPriority::Informational;
	}

	FHyperTwistCoachSignal MakeSignal(
		const FString& SignalId,
		const EHyperTwistCoachFocusLane FocusLane,
		const float Score,
		const FString& Headline,
		const FString& Detail,
		const EHyperTwistTrainingDeliveryMode SuggestedMode,
		const EHyperTwistTrainingSelectionPolicy SuggestedSelectionPolicy)
	{
		FHyperTwistCoachSignal Signal;
		Signal.SignalId = SignalId;
		Signal.FocusLane = FocusLane;
		Signal.Score = Score;
		Signal.Priority = PriorityFromScore(Score);
		Signal.Headline = Headline;
		Signal.Detail = Detail;
		Signal.SuggestedMode = SuggestedMode;
		Signal.SuggestedSelectionPolicy = SuggestedSelectionPolicy;
		Signal.bNeedsImmediateAttention = Signal.Priority == EHyperTwistCoachPriority::Critical;
		return Signal;
	}

	void SortSignals(TArray<FHyperTwistCoachSignal>& Signals)
	{
		Signals.Sort([](const FHyperTwistCoachSignal& Left, const FHyperTwistCoachSignal& Right)
		{
			if (!FMath::IsNearlyEqual(Left.Score, Right.Score))
			{
				return Left.Score > Right.Score;
			}

			return Left.SignalId < Right.SignalId;
		});
	}

	bool ShouldPreferRecognitionReplayReview(
		const FHyperTwistReplayReviewAnalytics& ReplayReviewAnalytics,
		const FHyperTwistRecognitionReplaySummary& RecognitionReplaySummary)
	{
		return RecognitionReplaySummary.EpisodeCount > 0
			&& (RecognitionReplaySummary.AmbiguousEpisodeCount > 0
				|| ReplayReviewAnalytics.RecognitionCorrectionCount > 0
				|| (RecognitionReplaySummary.AverageCommitConfidence >= 0.0f
					&& RecognitionReplaySummary.AverageCommitConfidence < 0.7f));
	}

	void ApplyPrimarySignalToBrief(
		FHyperTwistCoachBrief& Brief,
		const FHyperTwistCoachSignal& PrimarySignal)
	{
		Brief.Priority = PrimarySignal.Priority;
		Brief.FocusLane = PrimarySignal.FocusLane;
		Brief.PriorityScore = PrimarySignal.Score;
		Brief.Headline = PrimarySignal.Headline;
		Brief.PrimaryActionLabel = PrimarySignal.SignalId;
		Brief.SuggestedMode = PrimarySignal.SuggestedMode;
		Brief.SuggestedSelectionPolicy = PrimarySignal.SuggestedSelectionPolicy;
		if (!PrimarySignal.SuggestedDeckId.IsEmpty())
		{
			Brief.FocusDeckId = PrimarySignal.SuggestedDeckId;
		}
		if (!PrimarySignal.SuggestedMethodSegmentId.IsEmpty())
		{
			Brief.FocusMethodSegmentId = PrimarySignal.SuggestedMethodSegmentId;
		}
		Brief.FocusCaseIds = PrimarySignal.SuggestedCaseIds;
	}

	FString BuildCountDetail(const FString& Prefix, const int32 PrimaryCount, const int32 SecondaryCount)
	{
		return FString::Printf(TEXT("%s: %d / %d"), *Prefix, PrimaryCount, SecondaryCount);
	}
}

TArray<FHyperTwistCoachSignal> UHyperTwistTrainingCoachLibrary::DeriveCoachSignals(
	const FHyperTwistTrainingSessionSummary& SessionSummary,
	const FHyperTwistTrainingDeckScopedStats& DeckScopedStats,
	const FHyperTwistTrainingLearnerDeckStateSummary& LearnerDeckStateSummary,
	const FHyperTwistTrainingLearnerProfile& LearnerProfile,
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistTrainingReviewProgramSummary& ReviewProgramSummary,
	const FHyperTwistReplayReviewAnalytics& ReplayReviewAnalytics,
	const FHyperTwistRecognitionReplaySummary& RecognitionReplaySummary)
{
	TArray<FHyperTwistCoachSignal> Signals;
	const bool bHasRecommendedGuidancePressure =
		CoachMemorySnapshot.bHasRepeatRecommendationPressure
		|| CoachMemorySnapshot.RepeatRecommendationSequenceCount > 0
		|| CoachMemorySnapshot.RecommendedGuidanceContinueBias > 0
		|| CoachMemorySnapshot.RecurringCoachCaseIds.Num() > 0;
	const bool bHasFollowUpGuidancePressure =
		CoachMemorySnapshot.FollowUpReadyCoachSequenceCount > 0
		|| CoachMemorySnapshot.ScheduleBlockedFollowUpEventCount > 0
		|| CoachMemorySnapshot.FollowUpGuidanceContinueBias > 0
		|| CoachMemorySnapshot.EscalatedCoachSequenceCount > 0
		|| CoachMemorySnapshot.EscalationCaseIds.Num() > 0;
	const bool bHasCompetingGuidancePressure =
		bHasRecommendedGuidancePressure && bHasFollowUpGuidancePressure;

	if (CoachMemorySnapshot.EscalatedCoachSequenceCount > 0
		|| CoachMemorySnapshot.EscalationCaseIds.Num() > 0)
	{
		const float Score = 96.0f
			+ FMath::Min(static_cast<float>(CoachMemorySnapshot.EscalatedCoachSequenceCount) * 4.0f, 8.0f)
			+ FMath::Min(static_cast<float>(CoachMemorySnapshot.EscalationCaseIds.Num()), 6.0f);
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("coach_escalation"),
			EHyperTwistCoachFocusLane::Accuracy,
			Score,
			TEXT("Escalation is needed for unresolved coaching cases"),
			FString::Printf(
				TEXT("escalatedSequences=%d, escalationCases=%d, followUpReady=%d"),
				CoachMemorySnapshot.EscalatedCoachSequenceCount,
				CoachMemorySnapshot.EscalationCaseIds.Num(),
				CoachMemorySnapshot.FollowUpReadyCoachSequenceCount),
			EHyperTwistTrainingDeliveryMode::CoachReviewed,
			EHyperTwistTrainingSelectionPolicy::Scripted);
		Signal.SuggestedDeckId = CoachMemorySnapshot.FocusDeckId;
		Signal.SuggestedMethodSegmentId = CoachMemorySnapshot.FocusMethodSegmentId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.EscalationCaseIds.Num() > 0
			? CoachMemorySnapshot.EscalationCaseIds
			: CoachMemorySnapshot.PersistentCoachWeakCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::FollowUp,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if (CoachMemorySnapshot.bHasRepeatRecommendationPressure
		&& CoachMemorySnapshot.RecurringCoachCaseIds.Num() > 0)
	{
		const float Score = 78.0f
			+ FMath::Min(static_cast<float>(CoachMemorySnapshot.RepeatRecommendationSequenceCount) * 3.0f, 9.0f)
			+ FMath::Min(static_cast<float>(CoachMemorySnapshot.RecurringCoachCaseIds.Num()), 6.0f);
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("repeat_recommendation"),
			EHyperTwistCoachFocusLane::Stability,
			Score,
			TEXT("Recurring coach cases need consolidation"),
			FString::Printf(
				TEXT("repeatSequences=%d, recurringCases=%d, dominantMode=%d"),
				CoachMemorySnapshot.RepeatRecommendationSequenceCount,
				CoachMemorySnapshot.RecurringCoachCaseIds.Num(),
				static_cast<int32>(CoachMemorySnapshot.DominantCoachSuggestedMode)),
			CoachMemorySnapshot.DominantCoachSuggestedMode,
			CoachMemorySnapshot.DominantCoachSelectionPolicy);
		Signal.SuggestedDeckId = CoachMemorySnapshot.FocusDeckId;
		Signal.SuggestedMethodSegmentId = CoachMemorySnapshot.FocusMethodSegmentId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.PinnedCarryForwardCaseIds.Num() > 0
			? CoachMemorySnapshot.PinnedCarryForwardCaseIds
			: CoachMemorySnapshot.RecurringCoachCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::Recommended,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if (CoachMemorySnapshot.bNeedsArchiveRetentionTuning
		|| CoachMemorySnapshot.ArchiveReopenRiskCaseIds.Num() > 0)
	{
		const float Score = 58.0f
			+ FMath::Min(CoachMemorySnapshot.ArchiveRetentionTuningScore * 0.35f, 22.0f)
			+ FMath::Min(static_cast<float>(CoachMemorySnapshot.ArchiveReopenRiskCaseIds.Num()) * 5.0f, 15.0f);
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("archive_retention"),
			EHyperTwistCoachFocusLane::Stability,
			Score,
			TEXT("Archive retention needs tuning"),
			FString::Printf(
				TEXT("reopenRisk=%d, provisionalArchive=%d, stableArchive=%d"),
				CoachMemorySnapshot.ArchiveReopenRiskCaseIds.Num(),
				CoachMemorySnapshot.ProvisionalArchivedCoachCaseIds.Num(),
				CoachMemorySnapshot.StableArchivedCoachCaseIds.Num()),
			CoachMemorySnapshot.DominantCoachSuggestedMode,
			CoachMemorySnapshot.DominantCoachSelectionPolicy);
		Signal.SuggestedDeckId = CoachMemorySnapshot.FocusDeckId;
		Signal.SuggestedMethodSegmentId = CoachMemorySnapshot.FocusMethodSegmentId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.ArchiveReopenRiskCaseIds.Num() > 0
			? CoachMemorySnapshot.ArchiveReopenRiskCaseIds
			: CoachMemorySnapshot.ProvisionalArchivedCoachCaseIds;
		Signals.Add(Signal);
	}

	if (CoachMemorySnapshot.bNeedsScheduleFrictionRecovery)
	{
		const bool bArchiveAware = CoachMemorySnapshot.bHasArchiveAwareScheduleFriction;
		const bool bBlockedFollowUp = CoachMemorySnapshot.bHasBlockedFollowUpScheduleFriction;
		const bool bRepeatManualReschedule = CoachMemorySnapshot.bHasRepeatManualScheduleFriction;
		const bool bDashboardQueuedHandoff =
			CoachMemorySnapshot.PreferredCoachHandoffKind == EHyperTwistTrainingCoachHandoffKind::Queue;
		const bool bDashboardFollowUpHandoff =
			CoachMemorySnapshot.PreferredCoachHandoffKind == EHyperTwistTrainingCoachHandoffKind::FollowUp;
		const bool bDashboardRecommendedHandoff =
			CoachMemorySnapshot.PreferredCoachHandoffKind == EHyperTwistTrainingCoachHandoffKind::Recommended;
		const bool bDeferredOverflowDashboardHandoff =
			HyperTwistTrainingCoachLibraryInternal::IsDeferredOverflowDashboardHandoffSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bMethodDrillDashboardHandoff =
			HyperTwistTrainingCoachLibraryInternal::IsMethodDrillDashboardHandoffSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bNarrowMethodDrillPacketStructureHandoff =
			HyperTwistTrainingCoachLibraryInternal::IsNarrowMethodDrillFollowUpPacketStructureSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bBroadMethodDrillPacketStructureHandoff =
			HyperTwistTrainingCoachLibraryInternal::IsBroadMethodDrillFollowUpPacketStructureSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bStrongMethodDrillDashboardHandoff =
			HyperTwistTrainingCoachLibraryInternal::IsStrongMethodDrillRecoveryMemorySource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bWeakMethodDrillDashboardHandoff =
			HyperTwistTrainingCoachLibraryInternal::IsWeakMethodDrillRecoveryMemorySource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bExplicitDashboardHandoffPreference =
			CoachMemorySnapshot.PreferredCoachHandoffKind != EHyperTwistTrainingCoachHandoffKind::None;
		const bool bQueueRecoverySource =
			HyperTwistTrainingCoachLibraryInternal::IsQueueRecoveryMemorySource(
				CoachMemorySnapshot.PreferredGuidanceSourceLabel);
		const bool bQueueRecoveryFollowUp =
			bQueueRecoverySource
			&& CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp;
		const bool bQueueRecoveryRecommended =
			bQueueRecoverySource
			&& CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::Recommended;
		const bool bPromoteQueueRecovery =
			CoachMemorySnapshot.PreferredQueueRecoveryAction
			== EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred;
		const bool bLaunchQueueRecovery =
			CoachMemorySnapshot.PreferredQueueRecoveryAction
			== EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery;
		const bool bMethodDrillRecoveryActionSource =
			HyperTwistTrainingCoachLibraryInternal::IsMethodDrillRecoveryMemorySource(
				CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel
			);
		const bool bStrongMethodDrillRecoveryActionSource =
			HyperTwistTrainingCoachLibraryInternal::IsStrongMethodDrillRecoveryMemorySource(
				CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel
			);
		const bool bWeakMethodDrillRecoveryActionSource =
			HyperTwistTrainingCoachLibraryInternal::IsWeakMethodDrillRecoveryMemorySource(
				CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel
			);
		const bool bNarrowMethodDrillPacketStructureRecoveryActionSource =
			HyperTwistTrainingCoachLibraryInternal::IsNarrowMethodDrillFollowUpPacketStructureSource(
				CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel
			);
		const bool bBroadMethodDrillPacketStructureRecoveryActionSource =
			HyperTwistTrainingCoachLibraryInternal::IsBroadMethodDrillFollowUpPacketStructureSource(
				CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel
			);
		const float Score = 66.0f
			+ FMath::Min(CoachMemorySnapshot.ScheduleExecutionPressureScore * 0.25f, 20.0f)
			+ (bArchiveAware ? 5.0f : 0.0f)
			+ (bBlockedFollowUp ? 6.0f : 0.0f)
			+ (bRepeatManualReschedule ? 5.0f : 0.0f)
			+ (CoachMemorySnapshot.bHasQueueExecutionCompletionGap ? 4.0f : 0.0f)
			+ (bQueueRecoverySource ? 2.0f : 0.0f)
			+ (bExplicitDashboardHandoffPreference ? 2.0f : 0.0f)
			+ (bMethodDrillRecoveryActionSource ? 2.0f : 0.0f);

		const EHyperTwistCoachFocusLane FocusLane = bArchiveAware
			? EHyperTwistCoachFocusLane::Stability
			: EHyperTwistCoachFocusLane::Cadence;
		FString Headline;
		if (bDashboardQueuedHandoff)
		{
			Headline = bNarrowMethodDrillPacketStructureHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted narrow retained drill-follow-up-packet structure keeps the queue-first continuation slice active")
					: TEXT("Accepted narrow retained drill-follow-up-packet structure favors a queue-first continuation launch"))
				: (bStrongMethodDrillDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted strong retained drill-recovery queued handoffs keep the queue-first continuation slice active")
					: TEXT("Accepted strong retained drill-recovery queued handoffs favor a queue-first continuation launch"))
				: (bMethodDrillDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted drill-driven queued handoffs keep drill-tipped queued recovery work active")
					: TEXT("Accepted drill-driven queued handoffs favor a queue-first drill recovery launch"))
				: (bDeferredOverflowDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted deferred-overflow queued handoffs favor promoting narrowed queued work first")
					: TEXT("Accepted deferred-overflow queued handoffs favor a queue-first narrowed recovery launch"))
				: (bPromoteQueueRecovery
					? TEXT("Accepted queued handoffs favor promoting queued work first")
					: TEXT("Accepted queued handoffs favor a queue-first recovery launch")))));
		}
		else if (bDashboardFollowUpHandoff)
		{
			Headline = bNarrowMethodDrillPacketStructureHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted narrow retained drill-follow-up-packet structure keeps the continuation lane active")
					: TEXT("Accepted narrow retained drill-follow-up-packet structure favors recovering the continuation lane next"))
				: (bStrongMethodDrillDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted strong retained drill-recovery follow-up handoffs keep the narrowed continuation lane active")
					: TEXT("Accepted strong retained drill-recovery follow-up handoffs favor recovering the narrowed continuation lane next"))
				: (bMethodDrillDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted drill-driven follow-up handoffs keep the drill-derived follow-up lane active")
					: TEXT("Accepted drill-driven follow-up handoffs favor recovering the drill-derived follow-up lane next"))
				: (bDeferredOverflowDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted deferred-overflow follow-up handoffs keep narrowed follow-up work active")
					: TEXT("Accepted deferred-overflow follow-up handoffs favor recovering narrowed follow-up work next"))
				: (bPromoteQueueRecovery
					? TEXT("Accepted follow-up handoffs keep the deferred follow-up lane active")
					: TEXT("Accepted follow-up handoffs favor recovering the follow-up lane next")))));
		}
		else if (bDashboardRecommendedHandoff)
		{
			Headline = bBroadMethodDrillPacketStructureHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted broad retained drill-follow-up-packet structure keeps broader redirect work active")
					: TEXT("Accepted broad retained drill-follow-up-packet structure favors a broader redirect next"))
				: (bWeakMethodDrillDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted weak retained drill-recovery history keeps broader recommended redirect work active")
					: TEXT("Accepted weak retained drill-recovery history favors a broader recommended redirect next"))
				: (bMethodDrillDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted drill-driven recommended handoffs keep drill-tipped recommended recovery work active")
					: TEXT("Accepted drill-driven recommended handoffs favor restoring drill-tipped recommended work next"))
				: (bDeferredOverflowDashboardHandoff
				? (bPromoteQueueRecovery
					? TEXT("Accepted deferred-overflow recommended handoffs keep narrowed recommended work active")
					: TEXT("Accepted deferred-overflow recommended handoffs favor restoring narrowed recommended work next"))
				: (bPromoteQueueRecovery
					? TEXT("Accepted recommended handoffs keep the deferred recommended lane active")
					: TEXT("Accepted recommended handoffs favor restoring the recommended lane next")))));
		}
		else if (bQueueRecoveryFollowUp)
		{
			Headline = bNarrowMethodDrillPacketStructureRecoveryActionSource
				? (bPromoteQueueRecovery
					? TEXT("Promote the narrow retained drill-follow-up-packet structure back into active queue flow")
					: TEXT("Recover the narrow retained drill-follow-up-packet structure before the queue drifts further"))
				: (bStrongMethodDrillRecoveryActionSource
				? (bPromoteQueueRecovery
					? TEXT("Promote the strong retained drill-recovery continuation lane back into active queue flow")
					: TEXT("Recover the strong retained drill-recovery continuation lane before the queue drifts further"))
				: (bMethodDrillRecoveryActionSource
				? (bPromoteQueueRecovery
					? TEXT("Promote the deferred drill-derived follow-up lane back into active queue flow")
					: TEXT("Recover the drill-derived follow-up lane before the queue drifts further"))
				: (bPromoteQueueRecovery
					? TEXT("Promote the deferred follow-up lane back into active queue flow")
					: TEXT("Recover the deferred follow-up lane before the queue drifts further"))));
		}
		else if (bQueueRecoveryRecommended)
		{
			Headline = bBroadMethodDrillPacketStructureRecoveryActionSource
				? (bPromoteQueueRecovery
					? TEXT("Promote the broad retained drill-follow-up-packet redirect back into the active queue")
					: TEXT("Recover the broad retained drill-follow-up-packet redirect and restore queue cadence"))
				: (bWeakMethodDrillRecoveryActionSource
				? (bPromoteQueueRecovery
					? TEXT("Promote the weak retained drill-recovery redirect lane back into the active queue")
					: TEXT("Recover the weak retained drill-recovery redirect lane and restore queue cadence"))
				: (bMethodDrillRecoveryActionSource
				? (bPromoteQueueRecovery
					? TEXT("Promote the deferred drill-tipped recommended lane back into the active queue")
					: TEXT("Recover the drill-tipped recommended lane and restore queue cadence"))
				: (bPromoteQueueRecovery
					? TEXT("Promote the deferred recommended lane back into the active queue")
					: TEXT("Recover the deferred recommended lane and restore queue cadence"))));
		}
		else if (bBlockedFollowUp)
		{
			Headline = bPromoteQueueRecovery
				? TEXT("Promote deferred work to relieve follow-up scheduling friction")
				: TEXT("Follow-up scheduling friction is stalling the queue");
		}
		else if (bArchiveAware)
		{
			Headline = TEXT("Archive-aware scheduling friction needs cleanup");
		}
		else if (bLaunchQueueRecovery)
		{
			Headline = TEXT("Launch recovery work to restore coaching queue cadence");
		}
		else
		{
			Headline = TEXT("Coaching queue scheduling needs intervention");
		}
		const FString DeferralReasonLabel = !CoachMemorySnapshot.DominantScheduleDeferralReasonLabel.IsEmpty()
			? CoachMemorySnapshot.DominantScheduleDeferralReasonLabel
			: TEXT("none");
		const FString RecoverySourceLabel = bQueueRecoverySource
			? HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
				CoachMemorySnapshot.PreferredGuidanceSourceLabel)
			: TEXT("none");
		const FString RecoveryActionLabel =
			CoachMemorySnapshot.PreferredQueueRecoveryAction == EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred
				? TEXT("promote-deferred")
				: (CoachMemorySnapshot.PreferredQueueRecoveryAction
					== EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery
					? TEXT("launch-recovery")
					: TEXT("none"));
		const FString RecoveryActionSourceLabel =
			CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel.IsEmpty()
				? TEXT("none")
				: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
					CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel);
		const FString HandoffPreferenceLabel =
			HyperTwistTrainingCoachLibraryInternal::DescribeCoachHandoffKind(
				CoachMemorySnapshot.PreferredCoachHandoffKind);
		const FString HandoffSourceLabel =
			CoachMemorySnapshot.PreferredCoachHandoffSourceLabel.IsEmpty()
				? TEXT("none")
				: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
					CoachMemorySnapshot.PreferredCoachHandoffSourceLabel);
		const FString RetainedMethodDrillRecoveryStanceLabel =
			HyperTwistTrainingCoachLibraryInternal::DescribeRetainedMethodDrillRecoveryStanceLabel(
				!CoachMemorySnapshot.PreferredCoachHandoffSourceLabel.IsEmpty()
					? CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
					: CoachMemorySnapshot.PreferredQueueRecoveryActionSourceLabel);
		const FString SignalId = bQueueRecoveryFollowUp
			? (bPromoteQueueRecovery
				? TEXT("schedule_friction_follow_up_promote_recovery")
				: TEXT("schedule_friction_follow_up_recovery"))
			: (bQueueRecoveryRecommended
				? (bPromoteQueueRecovery
					? TEXT("schedule_friction_recommended_promote_recovery")
					: TEXT("schedule_friction_recommended_recovery"))
				: TEXT("schedule_friction"));
		const EHyperTwistTrainingDeliveryMode SuggestedMode = bQueueRecoveryFollowUp
			? EHyperTwistTrainingDeliveryMode::CoachReviewed
			: (bQueueRecoveryRecommended
				? CoachMemorySnapshot.DominantCoachSuggestedMode
				: (bBlockedFollowUp
					? EHyperTwistTrainingDeliveryMode::CoachReviewed
					: CoachMemorySnapshot.DominantCoachSuggestedMode));
		const EHyperTwistTrainingSelectionPolicy SuggestedSelectionPolicy = bQueueRecoveryFollowUp
			? EHyperTwistTrainingSelectionPolicy::Scripted
			: (bQueueRecoveryRecommended
				? EHyperTwistTrainingSelectionPolicy::Weighted
				: (bBlockedFollowUp
					? EHyperTwistTrainingSelectionPolicy::Scripted
					: CoachMemorySnapshot.DominantCoachSelectionPolicy));
		const bool bTightenedDeferredOverflowHandoff =
			bDeferredOverflowDashboardHandoff
			&& (bDashboardQueuedHandoff || bDashboardFollowUpHandoff || bDashboardRecommendedHandoff);

		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			SignalId,
			FocusLane,
			Score,
			Headline,
			FString::Printf(
				TEXT("deferred=%d, manual=%d, archiveAware=%d, blockedFollowUp=%d, completionGap=%d, deferralReason=%s, recoverySource=%s, recoveryAction=%s, recoveryActionSource=%s, handoffPreference=%s, handoffSource=%s, retainedMethodDrillRecoveryStance=%s, deferredOverflowHandoff=%d, methodDrillHandoff=%d, methodDrillRecoverySource=%d"),
				CoachMemorySnapshot.ScheduleDeferredEventCount,
				CoachMemorySnapshot.ScheduleManualRescheduleEventCount,
				CoachMemorySnapshot.ScheduleArchiveAwareEventCount,
				CoachMemorySnapshot.ScheduleBlockedFollowUpEventCount,
				CoachMemorySnapshot.bHasQueueExecutionCompletionGap ? 1 : 0,
				*DeferralReasonLabel,
				*RecoverySourceLabel,
				*RecoveryActionLabel,
				*RecoveryActionSourceLabel,
				*HandoffPreferenceLabel,
				*HandoffSourceLabel,
				*RetainedMethodDrillRecoveryStanceLabel,
				bTightenedDeferredOverflowHandoff ? 1 : 0,
				bMethodDrillDashboardHandoff ? 1 : 0,
				bMethodDrillRecoveryActionSource ? 1 : 0),
			bTightenedDeferredOverflowHandoff
				? (CoachMemorySnapshot.DominantCoachSuggestedMode
						== EHyperTwistTrainingDeliveryMode::RecognitionAssisted
						? EHyperTwistTrainingDeliveryMode::RecognitionAssisted
						: EHyperTwistTrainingDeliveryMode::CoachReviewed)
				: SuggestedMode,
			bTightenedDeferredOverflowHandoff
				? EHyperTwistTrainingSelectionPolicy::Scripted
				: SuggestedSelectionPolicy);
		Signal.SuggestedDeckId = CoachMemorySnapshot.FocusDeckId;
		Signal.SuggestedMethodSegmentId = CoachMemorySnapshot.FocusMethodSegmentId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.SchedulePressureCaseIds.Num() > 0
			? CoachMemorySnapshot.SchedulePressureCaseIds
			: CoachMemorySnapshot.WeakCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			bBlockedFollowUp
				? EHyperTwistTrainingCoachGuidanceLane::FollowUp
				: EHyperTwistTrainingCoachGuidanceLane::None,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if (CoachMemorySnapshot.bNeedsCoachIntervention
		|| ReviewProgramSummary.bNeedsCoachIntervention
		|| LearnerDeckStateSummary.OverdueCaseCount >= 3)
	{
		const float Score = 90.0f
			+ FMath::Min(static_cast<float>(LearnerDeckStateSummary.OverdueCaseCount) * 2.0f, 8.0f)
			+ FMath::Min(static_cast<float>(ReviewProgramSummary.CarryoverCaseCount), 6.0f);
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("review_backlog"),
			EHyperTwistCoachFocusLane::ReviewBacklog,
			Score,
			TEXT("Review backlog needs intervention"),
			FString::Printf(
				TEXT("overdue=%d, carryover=%d, pendingPlans=%d"),
				LearnerDeckStateSummary.OverdueCaseCount,
				ReviewProgramSummary.CarryoverCaseCount,
				ReviewProgramSummary.PendingPlanCount),
			EHyperTwistTrainingDeliveryMode::CoachReviewed,
			EHyperTwistTrainingSelectionPolicy::Weighted);
		Signal.SuggestedDeckId = !CoachMemorySnapshot.FocusDeckId.IsEmpty()
			? CoachMemorySnapshot.FocusDeckId
			: ReviewProgramSummary.FocusDeckId;
		Signal.SuggestedMethodSegmentId = !CoachMemorySnapshot.FocusMethodSegmentId.IsEmpty()
			? CoachMemorySnapshot.FocusMethodSegmentId
			: ReviewProgramSummary.FocusMethodSegmentId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.OverdueCaseIds.Num() > 0
			? CoachMemorySnapshot.OverdueCaseIds
			: CoachMemorySnapshot.DueCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::FollowUp,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if (CoachMemorySnapshot.bNeedsCadenceRecovery || LearnerProfile.RecentSevenDaySessionCount == 0)
	{
		const float Score = CoachMemorySnapshot.bNeedsCadenceRecovery ? 72.0f : 48.0f;
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("cadence_recovery"),
			EHyperTwistCoachFocusLane::Cadence,
			Score,
			TEXT("Cadence recovery recommended"),
			FString::Printf(
				TEXT("streak=%d, recent7d=%d"),
				LearnerProfile.ActiveTrainingDayStreak,
				LearnerProfile.RecentSevenDaySessionCount),
			EHyperTwistTrainingDeliveryMode::Timer,
			EHyperTwistTrainingSelectionPolicy::Weighted);
		Signal.SuggestedDeckId = CoachMemorySnapshot.FocusDeckId;
		Signal.SuggestedMethodSegmentId = CoachMemorySnapshot.FocusMethodSegmentId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.WeakCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::Recommended,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if (CoachMemorySnapshot.bNeedsVarietyRotation)
	{
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("variety_rotation"),
			EHyperTwistCoachFocusLane::Variety,
			46.0f,
			TEXT("Variety rotation advised"),
			FString::Printf(
				TEXT("favoriteDeckShare=%.2f, recoveryDecks=%d"),
				LearnerProfile.FavoriteDeckSessionShare,
				CoachMemorySnapshot.RecoveryDeckIds.Num()),
			EHyperTwistTrainingDeliveryMode::VirtualCube,
			EHyperTwistTrainingSelectionPolicy::Uniform);
		if (CoachMemorySnapshot.RecoveryDeckIds.Num() > 0)
		{
			Signal.SuggestedDeckId = CoachMemorySnapshot.RecoveryDeckIds[0];
		}
		if (CoachMemorySnapshot.RecoveryMethodSegmentIds.Num() > 0)
		{
			Signal.SuggestedMethodSegmentId = CoachMemorySnapshot.RecoveryMethodSegmentIds[0];
		}
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::Recommended,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if (HyperTwistTrainingCoachLibraryInternal::ShouldPreferRecognitionReplayReview(
			ReplayReviewAnalytics,
			RecognitionReplaySummary))
	{
		const float ConfidencePenalty = RecognitionReplaySummary.AverageCommitConfidence >= 0.0f
			? (1.0f - RecognitionReplaySummary.AverageCommitConfidence) * 25.0f
			: 0.0f;
		const float Score = 68.0f
			+ static_cast<float>(RecognitionReplaySummary.AmbiguousEpisodeCount * 5)
			+ static_cast<float>(ReplayReviewAnalytics.RecognitionCorrectionCount * 4)
			+ ConfidencePenalty;
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("recognition_clarity"),
			EHyperTwistCoachFocusLane::Recognition,
			Score,
			TEXT("Recognition clarity needs work"),
			FString::Printf(
				TEXT("episodes=%d, ambiguous=%d, avgCommit=%.2f"),
				RecognitionReplaySummary.EpisodeCount,
				RecognitionReplaySummary.AmbiguousEpisodeCount,
				RecognitionReplaySummary.AverageCommitConfidence),
			EHyperTwistTrainingDeliveryMode::RecognitionAssisted,
			EHyperTwistTrainingSelectionPolicy::Weighted);
		Signal.SuggestedDeckId = CoachMemorySnapshot.FocusDeckId;
		Signal.SuggestedMethodSegmentId = CoachMemorySnapshot.FocusMethodSegmentId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.WeakCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::Recommended,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if ((SessionSummary.TotalMistakes > 0 && SessionSummary.CompletedAttemptCount > 0)
		|| DeckScopedStats.MistakeAttemptCount > 0
		|| ReplayReviewAnalytics.LongestIdleGapMs >= 2500)
	{
		const float MistakePressure = SessionSummary.CompletedAttemptCount > 0
			? (static_cast<float>(SessionSummary.TotalMistakes) / SessionSummary.CompletedAttemptCount) * 18.0f
			: 0.0f;
		const float Score = 52.0f
			+ MistakePressure
			+ FMath::Min(static_cast<float>(ReplayReviewAnalytics.LongestIdleGapMs) / 150.0f, 18.0f);
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("execution_flow"),
			EHyperTwistCoachFocusLane::Execution,
			Score,
			TEXT("Execution flow is uneven"),
			FString::Printf(
				TEXT("mistakes=%d, idleGapMs=%d, longestPhase=%s"),
				SessionSummary.TotalMistakes,
				ReplayReviewAnalytics.LongestIdleGapMs,
				*ReplayReviewAnalytics.LongestPhaseKind),
			EHyperTwistTrainingDeliveryMode::VirtualCube,
			EHyperTwistTrainingSelectionPolicy::Weighted);
		Signal.SuggestedDeckId = SessionSummary.DeckId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.WeakCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::Recommended,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if ((DeckScopedStats.AttemptCount > 0 && DeckScopedStats.SuccessCount < DeckScopedStats.FailureCount)
		|| LearnerDeckStateSummary.AverageDifficultyScore >= 0.7f)
	{
		const float FailureBias = DeckScopedStats.AttemptCount > 0
			? (static_cast<float>(DeckScopedStats.FailureCount) / DeckScopedStats.AttemptCount) * 25.0f
			: 0.0f;
		const float Score = 44.0f
			+ FailureBias
			+ (LearnerDeckStateSummary.AverageDifficultyScore * 15.0f);
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("accuracy_rebuild"),
			EHyperTwistCoachFocusLane::Accuracy,
			Score,
			TEXT("Accuracy rebuild recommended"),
			FString::Printf(
				TEXT("failures=%d, success=%d, avgDifficulty=%.2f"),
				DeckScopedStats.FailureCount,
				DeckScopedStats.SuccessCount,
				LearnerDeckStateSummary.AverageDifficultyScore),
			EHyperTwistTrainingDeliveryMode::Timer,
			EHyperTwistTrainingSelectionPolicy::Weighted);
		Signal.SuggestedDeckId = SessionSummary.DeckId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.WeakCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::Recommended,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	if (LearnerDeckStateSummary.DueCaseCount > 0
		|| LearnerDeckStateSummary.OverdueCaseCount > 0
		|| ReviewProgramSummary.PendingPlanCount > 0)
	{
		const float Score = 38.0f
			+ FMath::Min(static_cast<float>(LearnerDeckStateSummary.DueCaseCount), 8.0f)
			+ FMath::Min(static_cast<float>(LearnerDeckStateSummary.OverdueCaseCount) * 2.0f, 12.0f);
		FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
			TEXT("stability_maintenance"),
			EHyperTwistCoachFocusLane::Stability,
			Score,
			TEXT("Stability maintenance is due"),
			FString::Printf(
				TEXT("due=%d, overdue=%d, pendingPlans=%d"),
				LearnerDeckStateSummary.DueCaseCount,
				LearnerDeckStateSummary.OverdueCaseCount,
				ReviewProgramSummary.PendingPlanCount),
			EHyperTwistTrainingDeliveryMode::Timer,
			EHyperTwistTrainingSelectionPolicy::Spaced);
		Signal.SuggestedDeckId = SessionSummary.DeckId;
		Signal.SuggestedCaseIds = CoachMemorySnapshot.DueCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
			Signal,
			EHyperTwistTrainingCoachGuidanceLane::Recommended,
			CoachMemorySnapshot,
			bHasCompetingGuidancePressure
		);
		Signals.Add(Signal);
	}

	HyperTwistTrainingCoachLibraryInternal::SortSignals(Signals);

	return Signals;
}

FHyperTwistCoachBrief UHyperTwistTrainingCoachLibrary::DeriveCoachBrief(
	const FHyperTwistTrainingSessionSummary& SessionSummary,
	const FHyperTwistTrainingDeckScopedStats& DeckScopedStats,
	const FHyperTwistTrainingLearnerDeckStateSummary& LearnerDeckStateSummary,
	const FHyperTwistTrainingLearnerProfile& LearnerProfile,
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistTrainingReviewProgramSummary& ReviewProgramSummary,
	const FHyperTwistReplayReviewAnalytics& ReplayReviewAnalytics,
	const FHyperTwistRecognitionReplaySummary& RecognitionReplaySummary)
{
	FHyperTwistCoachBrief Brief;
	Brief.UserId = !SessionSummary.UserId.IsEmpty() ? SessionSummary.UserId : LearnerProfile.UserId;
	Brief.ReferenceUtc = !CoachMemorySnapshot.ReferenceUtc.IsEmpty()
		? CoachMemorySnapshot.ReferenceUtc
		: LearnerProfile.ReferenceUtc;
	Brief.TrainingSessionId = SessionSummary.TrainingSessionId;
	Brief.SourceReviewPlanId = !ReviewProgramSummary.CurrentPlanId.IsEmpty()
		? ReviewProgramSummary.CurrentPlanId
		: ReviewProgramSummary.NextPlanId;
	Brief.FocusDeckId = !CoachMemorySnapshot.FocusDeckId.IsEmpty()
		? CoachMemorySnapshot.FocusDeckId
		: SessionSummary.DeckId;
	Brief.FocusMethodSegmentId = !CoachMemorySnapshot.FocusMethodSegmentId.IsEmpty()
		? CoachMemorySnapshot.FocusMethodSegmentId
		: LearnerProfile.FavoriteMethodSegmentId;
	Brief.bNeedsCoachReview = CoachMemorySnapshot.bNeedsCoachIntervention || ReviewProgramSummary.bNeedsCoachIntervention;
	Brief.bNeedsCadenceRecovery =
		CoachMemorySnapshot.bNeedsCadenceRecovery || CoachMemorySnapshot.bNeedsScheduleFrictionRecovery;
	Brief.bNeedsVarietyRotation = CoachMemorySnapshot.bNeedsVarietyRotation;
	Brief.bPreferRecognitionReplayReview =
		HyperTwistTrainingCoachLibraryInternal::ShouldPreferRecognitionReplayReview(
			ReplayReviewAnalytics,
			RecognitionReplaySummary);

	Brief.Signals = DeriveCoachSignals(
		SessionSummary,
		DeckScopedStats,
		LearnerDeckStateSummary,
		LearnerProfile,
		CoachMemorySnapshot,
		ReviewProgramSummary,
		ReplayReviewAnalytics,
		RecognitionReplaySummary);

	if (Brief.Signals.Num() == 0)
	{
		Brief.Priority = EHyperTwistCoachPriority::Informational;
		Brief.FocusLane = EHyperTwistCoachFocusLane::Stability;
		Brief.PriorityScore = 0.0f;
		Brief.Headline = TEXT("Training state is stable");
		Brief.PrimaryActionLabel = TEXT("maintain-rhythm");
		Brief.SuggestedMode = EHyperTwistTrainingDeliveryMode::Timer;
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
		return Brief;
	}

	const FHyperTwistCoachSignal& PrimarySignal = Brief.Signals[0];
	HyperTwistTrainingCoachLibraryInternal::ApplyPrimarySignalToBrief(Brief, PrimarySignal);

	const bool bScheduleFacingBrief =
		CoachMemorySnapshot.bNeedsScheduleFrictionRecovery
		&& (PrimarySignal.SignalId == TEXT("schedule_friction")
			|| Brief.FocusLane == EHyperTwistCoachFocusLane::Cadence
			|| Brief.FocusLane == EHyperTwistCoachFocusLane::Stability
			|| Brief.bNeedsCadenceRecovery);
	if (bScheduleFacingBrief)
	{
		const bool bPreferFollowUpRecovery =
			CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp;
		const bool bPreferRecommendedRecovery =
			CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::Recommended;
		const bool bPromoteDeferredRecovery =
			CoachMemorySnapshot.PreferredQueueRecoveryAction
			== EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred;
		const bool bLaunchRecovery =
			CoachMemorySnapshot.PreferredQueueRecoveryAction
			== EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery;

		if (CoachMemorySnapshot.SchedulePressureCaseIds.Num() > 0
			&& (Brief.FocusCaseIds.Num() == 0
				|| PrimarySignal.SignalId == TEXT("schedule_friction")
				|| Brief.FocusLane == EHyperTwistCoachFocusLane::Cadence
				|| Brief.FocusLane == EHyperTwistCoachFocusLane::Stability))
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.SchedulePressureCaseIds;
		}

		if (bPreferFollowUpRecovery)
		{
			Brief.SuggestedMode = EHyperTwistTrainingDeliveryMode::CoachReviewed;
			Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
			Brief.PrimaryActionLabel = bPromoteDeferredRecovery
				? TEXT("promote_deferred_follow_up_recovery")
				: (bLaunchRecovery
					? TEXT("launch_follow_up_recovery")
					: TEXT("recover_follow_up_schedule_friction"));
		}
		else if (bPreferRecommendedRecovery)
		{
			Brief.SuggestedMode = CoachMemorySnapshot.DominantCoachSuggestedMode;
			Brief.SuggestedSelectionPolicy = CoachMemorySnapshot.bHasQueueExecutionCompletionGap
				? EHyperTwistTrainingSelectionPolicy::Weighted
				: CoachMemorySnapshot.DominantCoachSelectionPolicy;
			Brief.PrimaryActionLabel = bPromoteDeferredRecovery
				? TEXT("promote_deferred_recommended_recovery")
				: (bLaunchRecovery
					? TEXT("launch_recommended_recovery")
					: TEXT("recover_recommended_schedule_friction"));
		}
		else if (CoachMemorySnapshot.bHasArchiveAwareScheduleFriction)
		{
			Brief.PrimaryActionLabel = TEXT("stabilize_archive_aware_schedule");
		}
		else
		{
			Brief.PrimaryActionLabel = bPromoteDeferredRecovery
				? TEXT("promote_deferred_schedule_recovery")
				: (bLaunchRecovery
					? TEXT("launch_schedule_recovery")
					: TEXT("recover_schedule_friction"));
		}
	}

	if (Brief.FocusCaseIds.Num() == 0)
	{
		if (CoachMemorySnapshot.bNeedsScheduleFrictionRecovery
			&& CoachMemorySnapshot.SchedulePressureCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.SchedulePressureCaseIds;
		}
		else if (CoachMemorySnapshot.EscalationCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.EscalationCaseIds;
		}
		else if (CoachMemorySnapshot.bHasPinnedCarryForwardPressure
			&& CoachMemorySnapshot.PinnedCarryForwardCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.PinnedCarryForwardCaseIds;
		}
		else if (CoachMemorySnapshot.bHasRepeatRecommendationPressure
			&& CoachMemorySnapshot.RecurringCoachCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.RecurringCoachCaseIds;
		}
		else if (CoachMemorySnapshot.bNeedsArchiveRetentionTuning
			&& CoachMemorySnapshot.ArchiveReopenRiskCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.ArchiveReopenRiskCaseIds;
		}
		else if (Brief.bNeedsCoachReview && CoachMemorySnapshot.OverdueCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.OverdueCaseIds;
		}
		else if (Brief.bPreferRecognitionReplayReview && CoachMemorySnapshot.WeakCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.WeakCaseIds;
		}
		else
		{
			Brief.FocusCaseIds = CoachMemorySnapshot.DueCaseIds;
		}
	}

	return Brief;
}

FHyperTwistCoachBrief UHyperTwistTrainingCoachLibrary::DeriveCoachFollowUpBrief(
	const FHyperTwistCoachBrief& CurrentBrief,
	const FHyperTwistTrainingCoachActionPlan& ActionPlan,
	const FHyperTwistTrainingCoachActionPlanOutcomeSummary& OutcomeSummary)
{
	FHyperTwistCoachBrief Brief;
	if (!ActionPlan.IsStructurallyValid() || !OutcomeSummary.IsStructurallyValid())
	{
		return Brief;
	}

	Brief.UserId = OutcomeSummary.UserId;
	Brief.ReferenceUtc = !OutcomeSummary.ReferenceUtc.IsEmpty()
		? OutcomeSummary.ReferenceUtc
		: ActionPlan.ReferenceUtc;
	Brief.TrainingSessionId = OutcomeSummary.SourceSessionId;
	Brief.SourceReviewPlanId = CurrentBrief.SourceReviewPlanId;
	Brief.CarryForwardPlanId = ActionPlan.PlanId;
	Brief.RootPlanId = !ActionPlan.RootPlanId.IsEmpty() ? ActionPlan.RootPlanId : ActionPlan.PlanId;
	Brief.FollowUpDepth = ActionPlan.FollowUpDepth + 1;
	Brief.FocusDeckId = !OutcomeSummary.FocusDeckId.IsEmpty()
		? OutcomeSummary.FocusDeckId
		: ActionPlan.FocusDeckId;
	Brief.FocusMethodSegmentId = !OutcomeSummary.FocusMethodSegmentId.IsEmpty()
		? OutcomeSummary.FocusMethodSegmentId
		: ActionPlan.FocusMethodSegmentId;
	Brief.bNeedsCoachReview = ActionPlan.bNeedsCoachReview
		|| OutcomeSummary.AbortedCount > 0
		|| (ActionPlan.bPreferRecognitionReplayReview && OutcomeSummary.ReplayBackedAttemptCount == 0);
	Brief.bNeedsCadenceRecovery = ActionPlan.bNeedsCadenceRecovery;
	Brief.bNeedsVarietyRotation = ActionPlan.bNeedsVarietyRotation;
	Brief.bPreferRecognitionReplayReview = ActionPlan.bPreferRecognitionReplayReview
		|| OutcomeSummary.RecognitionAttemptCount > 0;
	const bool bHasDeferredLaunchCases = OutcomeSummary.DeferredLaunchCaseIds.Num() > 0;
	const bool bHasLaunchedFollowUpCases = OutcomeSummary.FollowUpCaseIds.Num() > 0;
	const bool bNarrowedContinuationSource =
		HyperTwistTrainingCoachLibraryInternal::IsDeferredOverflowDashboardHandoffSource(
			ActionPlan.PreferredCoachHandoffSourceLabel
		);
	const bool bDeferredFirstContinuationSource =
		HyperTwistTrainingCoachLibraryInternal::IsDeferredFirstContinuationSource(
			ActionPlan.PreferredCoachHandoffSourceLabel
		);
	const bool bStrongMethodDrillRecoveryPacketSource =
		HyperTwistTrainingCoachLibraryInternal::IsMethodDrillRecoveryPacketSource(
			ActionPlan.PreferredCoachHandoffSourceLabel)
		&& HyperTwistTrainingCoachLibraryInternal::IsStrongMethodDrillRecoveryMemorySource(
			ActionPlan.PreferredCoachHandoffSourceLabel);
	const bool bWeakMethodDrillRecoveryPacketSource =
		HyperTwistTrainingCoachLibraryInternal::IsMethodDrillRecoveryPacketSource(
			ActionPlan.PreferredCoachHandoffSourceLabel)
		&& HyperTwistTrainingCoachLibraryInternal::IsWeakMethodDrillRecoveryMemorySource(
			ActionPlan.PreferredCoachHandoffSourceLabel);
	const EHyperTwistTrainingCoachHandoffKind MethodDrillRecoveryPacketHandoffKind =
		HyperTwistTrainingCoachLibraryInternal::MethodDrillRecoveryPacketHandoffKindFromSourceLabel(
			ActionPlan.PreferredCoachHandoffSourceLabel);
	const FString MethodDrillRecoveryPacketLaneLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeMethodDrillRecoveryPacketLane(
			MethodDrillRecoveryPacketHandoffKind);
	const bool bStrongMethodDrillFollowUpPacketSource =
		HyperTwistTrainingCoachLibraryInternal::IsMethodDrillFollowUpPacketSource(
			ActionPlan.PreferredCoachHandoffSourceLabel)
		&& HyperTwistTrainingCoachLibraryInternal::IsStrongMethodDrillFollowUpPacketMemorySource(
			ActionPlan.PreferredCoachHandoffSourceLabel);
	const bool bWeakMethodDrillFollowUpPacketSource =
		HyperTwistTrainingCoachLibraryInternal::IsMethodDrillFollowUpPacketSource(
			ActionPlan.PreferredCoachHandoffSourceLabel)
		&& HyperTwistTrainingCoachLibraryInternal::IsWeakMethodDrillFollowUpPacketMemorySource(
			ActionPlan.PreferredCoachHandoffSourceLabel);
	const EHyperTwistTrainingCoachHandoffKind MethodDrillFollowUpPacketHandoffKind =
		HyperTwistTrainingCoachLibraryInternal::MethodDrillFollowUpPacketHandoffKindFromSourceLabel(
			ActionPlan.PreferredCoachHandoffSourceLabel,
			ActionPlan.PreferredCoachHandoffKind);
	const FString MethodDrillFollowUpPacketLaneLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeMethodDrillFollowUpPacketLane(
			MethodDrillFollowUpPacketHandoffKind);
	const FString AlignedGuidanceOutcomeSourceLabel =
		HyperTwistTrainingCoachLibraryInternal::IsAlignedTightFollowUpGuidanceSourceLabel(
			ActionPlan.PreferredCoachHandoffSourceLabel)
		|| HyperTwistTrainingCoachLibraryInternal::IsAlignedBroadRecommendedGuidanceSourceLabel(
			ActionPlan.PreferredCoachHandoffSourceLabel)
			? ActionPlan.PreferredCoachHandoffSourceLabel
			: (HyperTwistTrainingCoachLibraryInternal::IsAlignedTightFollowUpGuidanceSourceLabel(
					ActionPlan.PreferredGuidanceSourceLabel)
				|| HyperTwistTrainingCoachLibraryInternal::IsAlignedBroadRecommendedGuidanceSourceLabel(
					ActionPlan.PreferredGuidanceSourceLabel)
				? ActionPlan.PreferredGuidanceSourceLabel
				: FString());
	const bool bAlignedTightFollowUpOutcomeSource =
		HyperTwistTrainingCoachLibraryInternal::IsAlignedTightFollowUpGuidanceSourceLabel(
			AlignedGuidanceOutcomeSourceLabel);
	const bool bAlignedBroadRecommendedOutcomeSource =
		HyperTwistTrainingCoachLibraryInternal::IsAlignedBroadRecommendedGuidanceSourceLabel(
			AlignedGuidanceOutcomeSourceLabel);
	const FString AlignedGuidanceOutcomeSourceDescription =
		AlignedGuidanceOutcomeSourceLabel.IsEmpty()
			? TEXT("none")
			: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
				AlignedGuidanceOutcomeSourceLabel);
	const FString NarrowedContinuationSourceLabel =
		bNarrowedContinuationSource
			? HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
				ActionPlan.PreferredCoachHandoffSourceLabel
			)
			: TEXT("none");
	const bool bPrioritizeDeferredLaunchCasesInFollowUpPacket =
		bNarrowedContinuationSource && bHasDeferredLaunchCases;
	Brief.DeferredLaunchCaseCount = OutcomeSummary.DeferredLaunchCaseIds.Num();
	Brief.bNeedsDeferredLaunchRecovery = bHasDeferredLaunchCases;
	Brief.bHasTightenedLaunchOverflow =
		OutcomeSummary.bTightenedLaunchBudget && bHasDeferredLaunchCases;
	Brief.FocusCaseIds = bHasLaunchedFollowUpCases
		? HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
			bPrioritizeDeferredLaunchCasesInFollowUpPacket
				? OutcomeSummary.DeferredLaunchCaseIds
				: OutcomeSummary.FollowUpCaseIds,
			bPrioritizeDeferredLaunchCasesInFollowUpPacket
				? OutcomeSummary.FollowUpCaseIds
				: OutcomeSummary.DeferredLaunchCaseIds)
		: (bHasDeferredLaunchCases
				? OutcomeSummary.DeferredLaunchCaseIds
				: ActionPlan.FocusCaseIds);
	FString FollowUpPacketStructureLabel = bPrioritizeDeferredLaunchCasesInFollowUpPacket
		? TEXT("deferred-first")
		: TEXT("default");
	const TArray<FString> RecoveryPacketCases =
		HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
			OutcomeSummary.FollowUpCaseIds,
			OutcomeSummary.DeferredLaunchCaseIds);
	const TArray<FString> RecommendedPacketCases =
		HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
			ActionPlan.FocusCaseIds,
			RecoveryPacketCases);
	if (bStrongMethodDrillFollowUpPacketSource)
	{
		switch (MethodDrillFollowUpPacketHandoffKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			if (bHasDeferredLaunchCases)
			{
				Brief.FocusCaseIds = HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
					OutcomeSummary.DeferredLaunchCaseIds,
					bHasLaunchedFollowUpCases ? OutcomeSummary.FollowUpCaseIds : ActionPlan.FocusCaseIds);
				FollowUpPacketStructureLabel = TEXT("drill-follow-up-queue-entry-first");
			}
			break;
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			if (bHasLaunchedFollowUpCases)
			{
				Brief.FocusCaseIds = HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
					OutcomeSummary.FollowUpCaseIds,
					bHasDeferredLaunchCases ? OutcomeSummary.DeferredLaunchCaseIds : ActionPlan.FocusCaseIds);
				FollowUpPacketStructureLabel = TEXT("drill-follow-up-follow-up-packet-first");
			}
			break;
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			if (RecommendedPacketCases.Num() > 0)
			{
				Brief.FocusCaseIds = RecommendedPacketCases;
				FollowUpPacketStructureLabel = TEXT("drill-follow-up-recommended-brief-first");
			}
			break;
		default:
			break;
		}
	}
	else if (bWeakMethodDrillFollowUpPacketSource
		&& MethodDrillFollowUpPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		if (RecommendedPacketCases.Num() > 0)
		{
			Brief.FocusCaseIds = RecommendedPacketCases;
			FollowUpPacketStructureLabel = MethodDrillFollowUpPacketHandoffKind
				== EHyperTwistTrainingCoachHandoffKind::Recommended
				? TEXT("drill-follow-up-recommended-brief-redirect")
				: TEXT("drill-follow-up-broadened-redirect-first");
		}
	}
	else if (bStrongMethodDrillRecoveryPacketSource)
	{
		switch (MethodDrillRecoveryPacketHandoffKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			if (bHasDeferredLaunchCases)
			{
				Brief.FocusCaseIds = HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
					OutcomeSummary.DeferredLaunchCaseIds,
					bHasLaunchedFollowUpCases ? OutcomeSummary.FollowUpCaseIds : ActionPlan.FocusCaseIds);
				FollowUpPacketStructureLabel = TEXT("queue-entry-first");
			}
			break;
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			if (bHasLaunchedFollowUpCases)
			{
				Brief.FocusCaseIds = HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
					OutcomeSummary.FollowUpCaseIds,
					bHasDeferredLaunchCases ? OutcomeSummary.DeferredLaunchCaseIds : ActionPlan.FocusCaseIds);
				FollowUpPacketStructureLabel = TEXT("follow-up-packet-first");
			}
			break;
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			if (RecommendedPacketCases.Num() > 0)
			{
				Brief.FocusCaseIds = RecommendedPacketCases;
				FollowUpPacketStructureLabel = TEXT("recommended-brief-first");
			}
			break;
		default:
			break;
		}
	}
	else if (bWeakMethodDrillRecoveryPacketSource
		&& MethodDrillRecoveryPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		if (RecommendedPacketCases.Num() > 0)
		{
			Brief.FocusCaseIds = RecommendedPacketCases;
			FollowUpPacketStructureLabel = MethodDrillRecoveryPacketHandoffKind
				== EHyperTwistTrainingCoachHandoffKind::Recommended
				? TEXT("recommended-brief-redirect")
				: TEXT("broadened-redirect-first");
		}
	}
	else if (bAlignedTightFollowUpOutcomeSource)
	{
		if (bHasLaunchedFollowUpCases)
		{
			Brief.FocusCaseIds = HyperTwistTrainingCoachLibraryInternal::MergeFocusCaseIds(
				OutcomeSummary.FollowUpCaseIds,
				bHasDeferredLaunchCases ? OutcomeSummary.DeferredLaunchCaseIds : ActionPlan.FocusCaseIds);
			FollowUpPacketStructureLabel = TEXT("aligned-tight-follow-up-first");
		}
		else if (ActionPlan.FocusCaseIds.Num() > 0)
		{
			Brief.FocusCaseIds = ActionPlan.FocusCaseIds;
			FollowUpPacketStructureLabel = TEXT("aligned-tight-follow-up-carry-forward");
		}
	}
	else if (bAlignedBroadRecommendedOutcomeSource)
	{
		if (RecommendedPacketCases.Num() > 0)
		{
			Brief.FocusCaseIds = RecommendedPacketCases;
			FollowUpPacketStructureLabel = TEXT("aligned-broad-recommended-first");
		}
	}

	if (!OutcomeSummary.bNeedsFollowUpPlan && Brief.FocusCaseIds.Num() == 0)
	{
		return FHyperTwistCoachBrief();
	}

	Brief.PriorityScore = FMath::Clamp(
		(100.0f - OutcomeSummary.OutcomeScore)
		+ (static_cast<float>(OutcomeSummary.UntouchedFocusCaseCount) * 4.0f)
		+ (static_cast<float>(OutcomeSummary.FailureCount) * 3.0f)
		+ (static_cast<float>(OutcomeSummary.TimeoutCount) * 4.0f)
		+ (static_cast<float>(OutcomeSummary.DNFCount) * 5.0f)
		+ (static_cast<float>(OutcomeSummary.AbortedCount) * 6.0f),
		20.0f,
		100.0f
	);
	Brief.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(Brief.PriorityScore);

	if (OutcomeSummary.AbortedCount > 0)
	{
		Brief.FocusLane = EHyperTwistCoachFocusLane::Cadence;
		Brief.Headline = TEXT("Resume the interrupted coaching sequence");
		Brief.PrimaryActionLabel = TEXT("resume_aborted_plan");
		Brief.SuggestedMode = EHyperTwistTrainingDeliveryMode::VirtualCube;
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
	}
	else if (OutcomeSummary.TimeoutCount > 0 || OutcomeSummary.DNFCount > 0)
	{
		Brief.FocusLane = EHyperTwistCoachFocusLane::Execution;
		Brief.Headline = TEXT("Stabilize unfinished focus cases");
		Brief.PrimaryActionLabel = TEXT("stabilize_unfinished_cases");
		Brief.SuggestedMode = EHyperTwistTrainingDeliveryMode::VirtualCube;
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
	}
	else if (OutcomeSummary.FailureCount > 0)
	{
		Brief.FocusLane = EHyperTwistCoachFocusLane::Accuracy;
		Brief.Headline = TEXT("Rebuild accuracy on coach-selected cases");
		Brief.PrimaryActionLabel = TEXT("rebuild_accuracy");
		Brief.SuggestedMode = EHyperTwistTrainingDeliveryMode::Timer;
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
	}
	else if (OutcomeSummary.UntouchedFocusCaseCount > 0)
	{
		Brief.FocusLane = EHyperTwistCoachFocusLane::ReviewBacklog;
		Brief.Headline = TEXT("Complete the remaining coach-selected cases");
		Brief.PrimaryActionLabel = TEXT("complete_focus_cases");
		Brief.SuggestedMode = ActionPlan.SuggestedMode;
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
	}
	else if (bHasDeferredLaunchCases)
	{
		Brief.FocusLane = EHyperTwistCoachFocusLane::ReviewBacklog;
		switch (ActionPlan.PreferredCoachHandoffKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			Brief.Headline = bDeferredFirstContinuationSource
				? TEXT("Resume the deferred-first queued coach slice before broadening again")
				: (bNarrowedContinuationSource
					? TEXT("Resume the narrowed queued coach slice before broadening again")
					: TEXT("Resume the deferred coach slice excluded by the tighter launch budget"));
			Brief.PrimaryActionLabel = bDeferredFirstContinuationSource
				? TEXT("resume_deferred_first_queue_slice")
				: (bNarrowedContinuationSource
					? TEXT("resume_narrowed_queue_slice")
					: TEXT("resume_deferred_launch_slice"));
			break;
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			Brief.Headline = bDeferredFirstContinuationSource
				? TEXT("Restore the deferred-first recommended coach slice before broadening again")
				: (bNarrowedContinuationSource
					? TEXT("Restore the narrowed recommended coach slice before broadening again")
					: TEXT("Resume the deferred coach slice excluded by the tighter launch budget"));
			Brief.PrimaryActionLabel = bDeferredFirstContinuationSource
				? TEXT("restore_deferred_first_recommended_slice")
				: (bNarrowedContinuationSource
					? TEXT("restore_narrowed_recommended_slice")
					: TEXT("resume_deferred_launch_slice"));
			break;
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
		default:
			Brief.Headline = bDeferredFirstContinuationSource
				? TEXT("Continue the deferred-first follow-up coach slice before broadening again")
				: (bNarrowedContinuationSource
					? TEXT("Continue the narrowed follow-up coach slice before broadening again")
					: TEXT("Resume the deferred coach slice excluded by the tighter launch budget"));
			Brief.PrimaryActionLabel = bDeferredFirstContinuationSource
				? TEXT("continue_deferred_first_follow_up_slice")
				: (bNarrowedContinuationSource
					? TEXT("continue_narrowed_follow_up_slice")
					: TEXT("resume_deferred_launch_slice"));
			break;
		}
		Brief.SuggestedMode = bNarrowedContinuationSource
			? (Brief.bPreferRecognitionReplayReview
				? EHyperTwistTrainingDeliveryMode::RecognitionAssisted
				: EHyperTwistTrainingDeliveryMode::CoachReviewed)
			: ActionPlan.SuggestedMode;
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
	}
	else if (Brief.bPreferRecognitionReplayReview)
	{
		Brief.FocusLane = EHyperTwistCoachFocusLane::Recognition;
		Brief.Headline = TEXT("Run recognition-focused follow-up review");
		Brief.PrimaryActionLabel = TEXT("recognition_follow_up");
		Brief.SuggestedMode = EHyperTwistTrainingDeliveryMode::RecognitionAssisted;
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
	}
	else
	{
		Brief.FocusLane = CurrentBrief.FocusLane;
		Brief.Headline = TEXT("Reinforce the prior coach focus set");
		Brief.PrimaryActionLabel = TEXT("reinforce_focus_cases");
		Brief.SuggestedMode = ActionPlan.SuggestedMode;
		Brief.SuggestedSelectionPolicy = ActionPlan.SuggestedSelectionPolicy;
	}
	if (bStrongMethodDrillRecoveryPacketSource
		&& MethodDrillRecoveryPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
		if (MethodDrillRecoveryPacketHandoffKind != EHyperTwistTrainingCoachHandoffKind::Recommended)
		{
			Brief.SuggestedMode = Brief.bPreferRecognitionReplayReview
				? EHyperTwistTrainingDeliveryMode::RecognitionAssisted
				: EHyperTwistTrainingDeliveryMode::CoachReviewed;
		}
	}
	else if (bWeakMethodDrillRecoveryPacketSource
		&& MethodDrillRecoveryPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
		Brief.SuggestedMode = ActionPlan.SuggestedMode;
	}
	else if (bAlignedTightFollowUpOutcomeSource)
	{
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
		Brief.SuggestedMode = Brief.bPreferRecognitionReplayReview
			? EHyperTwistTrainingDeliveryMode::RecognitionAssisted
			: EHyperTwistTrainingDeliveryMode::CoachReviewed;
	}
	else if (bAlignedBroadRecommendedOutcomeSource)
	{
		Brief.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
		Brief.SuggestedMode = ActionPlan.SuggestedMode;
	}

	if (OutcomeSummary.bTightenedLaunchBudget)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s with a tighter follow-up scope"),
			*Brief.Headline
		);
	}
	else if (OutcomeSummary.bBroadenedLaunchBudget)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s while carrying the broader coach set forward"),
			*Brief.Headline
		);
	}
	if (bHasDeferredLaunchCases && bHasLaunchedFollowUpCases)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s, then recover the deferred launch slice"),
			*Brief.Headline
		);
	}
	if (bNarrowedContinuationSource && bHasDeferredLaunchCases)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s (%s)"),
			*Brief.Headline,
			*NarrowedContinuationSourceLabel
		);
	}
	if (bAlignedTightFollowUpOutcomeSource)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s (accepted aligned tight follow-up continuation)"),
			*Brief.Headline
		);
	}
	else if (bAlignedBroadRecommendedOutcomeSource)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s (accepted aligned broad recommended redirect)"),
			*Brief.Headline
		);
	}
	if (bStrongMethodDrillRecoveryPacketSource
		&& MethodDrillRecoveryPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s (packet-proven %s continuation)"),
			*Brief.Headline,
			*MethodDrillRecoveryPacketLaneLabel
		);
	}
	if (bStrongMethodDrillFollowUpPacketSource
		&& MethodDrillFollowUpPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s (packet-proven drill follow-up %s continuation)"),
			*Brief.Headline,
			*MethodDrillFollowUpPacketLaneLabel
		);
	}
	else if (bWeakMethodDrillFollowUpPacketSource
		&& MethodDrillFollowUpPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s (packet-proven drill follow-up %s redirect)"),
			*Brief.Headline,
			*MethodDrillFollowUpPacketLaneLabel
		);
	}
	else if (bWeakMethodDrillRecoveryPacketSource
		&& MethodDrillRecoveryPacketHandoffKind
			!= EHyperTwistTrainingCoachHandoffKind::None)
	{
		Brief.Headline = FString::Printf(
			TEXT("%s (packet-proven %s redirect)"),
			*Brief.Headline,
			*MethodDrillRecoveryPacketLaneLabel
		);
	}

	FHyperTwistCoachSignal FollowUpSignal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
		Brief.PrimaryActionLabel,
		Brief.FocusLane,
		Brief.PriorityScore,
		Brief.Headline,
		FString::Printf(
			TEXT("followUpCases=%d, deferredLaunchCases=%d, success=%d, failure=%d, timeout=%d, dnf=%d, launchBudget=%s, plannedLaunchCases=%d, requestedLaunchCases=%d, launchBudgetReason=%s, preferredHandoff=%s, preferredHandoffSource=%s, alignedGuidanceOutcomeSource=%s, narrowedContinuation=%d, deferredFirstContinuation=%d, alignedTightContinuation=%d, alignedBroadRedirect=%d, deferredPacketOrdering=%s, drillFollowUpPacketLane=%s, drillFollowUpPacketStance=%s, drillRecoveryPacketLane=%s, drillRecoveryPacketStance=%s"),
		Brief.FocusCaseIds.Num(),
		OutcomeSummary.DeferredLaunchCaseIds.Num(),
		OutcomeSummary.SuccessCount,
		OutcomeSummary.FailureCount,
		OutcomeSummary.TimeoutCount,
			OutcomeSummary.DNFCount,
			*HyperTwistTrainingCoachLibraryInternal::DescribeLaunchBudgetScopeLabel(
				OutcomeSummary.bBroadenedLaunchBudget,
				OutcomeSummary.bTightenedLaunchBudget),
			OutcomeSummary.PlannedLaunchCaseCount,
			OutcomeSummary.RequestedLaunchCaseCount,
			OutcomeSummary.LaunchBudgetReasonLine.IsEmpty()
				? TEXT("none")
				: *OutcomeSummary.LaunchBudgetReasonLine,
			*HyperTwistTrainingCoachLibraryInternal::DescribeCoachHandoffKind(
				ActionPlan.PreferredCoachHandoffKind
			),
			*NarrowedContinuationSourceLabel,
			*AlignedGuidanceOutcomeSourceDescription,
			bNarrowedContinuationSource ? 1 : 0,
			bDeferredFirstContinuationSource ? 1 : 0,
			bAlignedTightFollowUpOutcomeSource ? 1 : 0,
			bAlignedBroadRecommendedOutcomeSource ? 1 : 0,
			*FollowUpPacketStructureLabel,
			*MethodDrillFollowUpPacketLaneLabel,
			bStrongMethodDrillFollowUpPacketSource
				? TEXT("strong continuation")
				: (bWeakMethodDrillFollowUpPacketSource
					? TEXT("weak redirect")
					: TEXT("none")),
			*MethodDrillRecoveryPacketLaneLabel,
			bStrongMethodDrillRecoveryPacketSource
				? TEXT("strong continuation")
				: (bWeakMethodDrillRecoveryPacketSource
					? TEXT("weak redirect")
					: TEXT("none"))),
		Brief.SuggestedMode,
		Brief.SuggestedSelectionPolicy
	);
	FollowUpSignal.SuggestedDeckId = Brief.FocusDeckId;
	FollowUpSignal.SuggestedMethodSegmentId = Brief.FocusMethodSegmentId;
	FollowUpSignal.SuggestedCaseIds = Brief.FocusCaseIds;
	Brief.Signals = { FollowUpSignal };

	return Brief;
}

FHyperTwistCoachSessionQueueSummary UHyperTwistTrainingCoachLibrary::DeriveCoachSessionQueueSummary(
	const FHyperTwistCoachBrief& CurrentBrief,
	const FHyperTwistCoachBrief& FollowUpBrief,
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistTrainingCoachArchivePolicySummary& ArchivePolicySummary,
	const FHyperTwistTrainingReviewProgramSummary& ReviewProgramSummary)
{
	FHyperTwistCoachSessionQueueSummary Summary;
	Summary.UserId = !CurrentBrief.UserId.IsEmpty()
		? CurrentBrief.UserId
		: FollowUpBrief.UserId;
	if (Summary.UserId.IsEmpty())
	{
		return Summary;
	}

	Summary.ReferenceUtc = !FollowUpBrief.ReferenceUtc.IsEmpty()
		? FollowUpBrief.ReferenceUtc
		: (!CurrentBrief.ReferenceUtc.IsEmpty() ? CurrentBrief.ReferenceUtc : ArchivePolicySummary.ReferenceUtc);
	Summary.FocusDeckId = !FollowUpBrief.FocusDeckId.IsEmpty()
		? FollowUpBrief.FocusDeckId
		: (!CurrentBrief.FocusDeckId.IsEmpty() ? CurrentBrief.FocusDeckId : ArchivePolicySummary.FocusDeckId);
	Summary.FocusMethodSegmentId = !FollowUpBrief.FocusMethodSegmentId.IsEmpty()
		? FollowUpBrief.FocusMethodSegmentId
		: (!CurrentBrief.FocusMethodSegmentId.IsEmpty()
			? CurrentBrief.FocusMethodSegmentId
			: ArchivePolicySummary.FocusMethodSegmentId);
	const bool bHasFollowUpEntry =
		FollowUpBrief.UserId == Summary.UserId && FollowUpBrief.FocusCaseIds.Num() > 0;
	FString PrimaryQueueSuppressionReason;
	const bool bShouldCreatePrimaryEntry = HyperTwistTrainingCoachLibraryInternal::ShouldCreatePrimaryQueueEntry(
		CurrentBrief,
		FollowUpBrief,
		CoachMemorySnapshot,
		bHasFollowUpEntry,
		&PrimaryQueueSuppressionReason
	);
	FString FollowUpQueueSuppressionReason;
	const bool bShouldCreateFollowUpEntry =
		bHasFollowUpEntry
		&& HyperTwistTrainingCoachLibraryInternal::ShouldCreateFollowUpQueueEntry(
			CurrentBrief,
			FollowUpBrief,
			CoachMemorySnapshot,
			&FollowUpQueueSuppressionReason
		);
	Summary.bSuppressedPrimaryQueueCreation = !PrimaryQueueSuppressionReason.IsEmpty();
	Summary.PrimaryQueueSuppressionReason = PrimaryQueueSuppressionReason;
	Summary.bSuppressedFollowUpQueueCreation = !FollowUpQueueSuppressionReason.IsEmpty();
	Summary.FollowUpQueueSuppressionReason = FollowUpQueueSuppressionReason;
	const bool bHasCompetingGuidanceEntry = bShouldCreatePrimaryEntry && bShouldCreateFollowUpEntry;
	const bool bHasArchiveEntry =
		ArchivePolicySummary.IsStructurallyValid()
		&& (ArchivePolicySummary.bNeedsArchiveRetentionTuning
			|| ArchivePolicySummary.RetainedCarryForwardCaseCount > 0);

	auto AddBriefEntry = [
		&Summary,
		&FollowUpBrief,
		&CoachMemorySnapshot,
		&ArchivePolicySummary,
		bHasCompetingGuidanceEntry,
		bShouldCreateFollowUpEntry,
		bHasArchiveEntry
	](
		const FString& EntryId,
		const FString& SourceLabel,
		const FHyperTwistCoachBrief& Brief,
		const bool bRequiresFollowUp,
		const bool bRequiresArchiveRetentionTuning)
	{
		if (Brief.UserId.IsEmpty())
		{
			return;
		}

		FHyperTwistCoachSessionQueueEntry Entry;
		Entry.EntryId = EntryId;
		Entry.SourceLabel = SourceLabel;
		Entry.SourceBriefTrainingSessionId = Brief.TrainingSessionId;
		Entry.SourceReviewPlanId = Brief.SourceReviewPlanId;
		Entry.CarryForwardPlanId = Brief.CarryForwardPlanId;
		Entry.RootPlanId = Brief.RootPlanId;
		Entry.FollowUpDepth = FMath::Max(0, Brief.FollowUpDepth);
		Entry.Priority = Brief.Priority;
		Entry.PriorityScore = Brief.PriorityScore;
		Entry.FocusLane = Brief.FocusLane;
		Entry.Headline = Brief.Headline;
		Entry.PrimaryActionLabel = Brief.PrimaryActionLabel;
		Entry.SuggestedMode = Brief.SuggestedMode;
		Entry.SuggestedSelectionPolicy = Brief.SuggestedSelectionPolicy;
		Entry.FocusDeckId = Brief.FocusDeckId;
		Entry.FocusMethodSegmentId = Brief.FocusMethodSegmentId;
		Entry.FocusCaseIds = Brief.FocusCaseIds;
		Entry.DeferredLaunchCaseCount = FMath::Max(0, Brief.DeferredLaunchCaseCount);
		Entry.bNeedsDeferredLaunchRecovery = Brief.bNeedsDeferredLaunchRecovery;
		Entry.bHasTightenedLaunchOverflow = Brief.bHasTightenedLaunchOverflow;
		Entry.bRequiresFollowUp = bRequiresFollowUp;
		Entry.bRequiresArchiveRetentionTuning = bRequiresArchiveRetentionTuning;
		Entry.bNeedsCoachReview = Brief.bNeedsCoachReview;
		Entry.bNeedsCadenceRecovery = Brief.bNeedsCadenceRecovery;
		Entry.bNeedsVarietyRotation = Brief.bNeedsVarietyRotation;
		Entry.bPreferRecognitionReplayReview = Brief.bPreferRecognitionReplayReview;
		const bool bNarrowedContinuationPreferred =
			HyperTwistTrainingCoachLibraryInternal::IsDeferredOverflowDashboardHandoffSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bDeferredFirstContinuationPreferred =
			HyperTwistTrainingCoachLibraryInternal::IsDeferredFirstContinuationSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			);
		const bool bNarrowedQueueContinuation =
			bNarrowedContinuationPreferred
			&& CoachMemorySnapshot.PreferredCoachHandoffKind
				== EHyperTwistTrainingCoachHandoffKind::Queue
			&& Brief.bNeedsDeferredLaunchRecovery;
		const bool bNarrowedFollowUpContinuation =
			bNarrowedContinuationPreferred
			&& CoachMemorySnapshot.PreferredCoachHandoffKind
				== EHyperTwistTrainingCoachHandoffKind::FollowUp
			&& SourceLabel == TEXT("follow-up-brief");
		const bool bNarrowedRecommendedContinuation =
			bNarrowedContinuationPreferred
			&& CoachMemorySnapshot.PreferredCoachHandoffKind
				== EHyperTwistTrainingCoachHandoffKind::Recommended
			&& SourceLabel == TEXT("primary-brief");
		const bool bStrongRetainedMethodDrillRecoveryContinuation =
			HyperTwistTrainingCoachLibraryInternal::IsStrongMethodDrillRecoveryMemorySource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			)
			&& ((CoachMemorySnapshot.PreferredCoachHandoffKind
					== EHyperTwistTrainingCoachHandoffKind::Queue
					&& Brief.bNeedsDeferredLaunchRecovery)
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::FollowUp
					&& SourceLabel == TEXT("follow-up-brief"))
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::Recommended
					&& SourceLabel == TEXT("primary-brief")));
		const bool bStrongMethodDrillRecoveryPacketContinuation =
			bStrongRetainedMethodDrillRecoveryContinuation
			&& HyperTwistTrainingCoachLibraryInternal::IsMethodDrillRecoveryPacketSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel);
		const bool bStrongRetainedMethodDrillFollowUpPacketContinuation =
			HyperTwistTrainingCoachLibraryInternal::IsStrongMethodDrillFollowUpPacketMemorySource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			)
			&& ((CoachMemorySnapshot.PreferredCoachHandoffKind
					== EHyperTwistTrainingCoachHandoffKind::Queue
					&& Brief.bNeedsDeferredLaunchRecovery)
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::FollowUp
					&& SourceLabel == TEXT("follow-up-brief"))
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::Recommended
					&& SourceLabel == TEXT("primary-brief")));
		const bool bWeakRetainedMethodDrillRecoveryRedirect =
			HyperTwistTrainingCoachLibraryInternal::IsWeakMethodDrillRecoveryMemorySource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			)
			&& ((CoachMemorySnapshot.PreferredCoachHandoffKind
					== EHyperTwistTrainingCoachHandoffKind::Queue
					&& Brief.bNeedsDeferredLaunchRecovery)
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::FollowUp
					&& SourceLabel == TEXT("follow-up-brief"))
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::Recommended
					&& SourceLabel == TEXT("primary-brief")));
		const bool bWeakMethodDrillRecoveryPacketRedirect =
			bWeakRetainedMethodDrillRecoveryRedirect
			&& HyperTwistTrainingCoachLibraryInternal::IsMethodDrillRecoveryPacketSource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel);
		const bool bWeakRetainedMethodDrillFollowUpPacketRedirect =
			HyperTwistTrainingCoachLibraryInternal::IsWeakMethodDrillFollowUpPacketMemorySource(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			)
			&& ((CoachMemorySnapshot.PreferredCoachHandoffKind
					== EHyperTwistTrainingCoachHandoffKind::Queue
					&& Brief.bNeedsDeferredLaunchRecovery)
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::FollowUp
					&& SourceLabel == TEXT("follow-up-brief"))
				|| (CoachMemorySnapshot.PreferredCoachHandoffKind
						== EHyperTwistTrainingCoachHandoffKind::Recommended
					&& SourceLabel == TEXT("primary-brief")));
		const FString MethodDrillRecoveryPacketLaneLabel =
			HyperTwistTrainingCoachLibraryInternal::DescribeMethodDrillRecoveryPacketLane(
				HyperTwistTrainingCoachLibraryInternal::MethodDrillRecoveryPacketHandoffKindFromSourceLabel(
					CoachMemorySnapshot.PreferredCoachHandoffSourceLabel));
		const FString MethodDrillFollowUpPacketLaneLabel =
			HyperTwistTrainingCoachLibraryInternal::DescribeMethodDrillFollowUpPacketLane(
				HyperTwistTrainingCoachLibraryInternal::MethodDrillFollowUpPacketHandoffKindFromSourceLabel(
					CoachMemorySnapshot.PreferredCoachHandoffSourceLabel,
					CoachMemorySnapshot.PreferredCoachHandoffKind));
		const FString AlignedGuidanceOutcomeSourceLabel =
			HyperTwistTrainingCoachLibraryInternal::IsAlignedTightFollowUpGuidanceSourceLabel(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel)
			|| HyperTwistTrainingCoachLibraryInternal::IsAlignedBroadRecommendedGuidanceSourceLabel(
				CoachMemorySnapshot.PreferredCoachHandoffSourceLabel)
				? CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
				: (HyperTwistTrainingCoachLibraryInternal::IsAlignedTightFollowUpGuidanceSourceLabel(
						CoachMemorySnapshot.PreferredGuidanceSourceLabel)
					|| HyperTwistTrainingCoachLibraryInternal::IsAlignedBroadRecommendedGuidanceSourceLabel(
						CoachMemorySnapshot.PreferredGuidanceSourceLabel)
					? CoachMemorySnapshot.PreferredGuidanceSourceLabel
					: FString());
		const bool bAlignedTightFollowUpOutcomeContinuation =
			HyperTwistTrainingCoachLibraryInternal::IsAlignedTightFollowUpGuidanceSourceLabel(
				AlignedGuidanceOutcomeSourceLabel)
			&& SourceLabel == TEXT("follow-up-brief");
		const bool bAlignedBroadRecommendedOutcomeRedirect =
			HyperTwistTrainingCoachLibraryInternal::IsAlignedBroadRecommendedGuidanceSourceLabel(
				AlignedGuidanceOutcomeSourceLabel)
			&& SourceLabel == TEXT("primary-brief");
		if (bNarrowedQueueContinuation
			|| bNarrowedFollowUpContinuation
			|| bNarrowedRecommendedContinuation)
		{
			const FString ContinuationLabel = bNarrowedQueueContinuation
				? (bDeferredFirstContinuationPreferred
					? TEXT("queue-first deferred-first continuation")
					: TEXT("queue-first narrowed continuation"))
				: (bNarrowedFollowUpContinuation
					? (bDeferredFirstContinuationPreferred
						? TEXT("deferred-first narrowed follow-up continuation")
						: TEXT("narrowed follow-up continuation"))
					: (bDeferredFirstContinuationPreferred
						? TEXT("deferred-first narrowed recommended continuation")
						: TEXT("narrowed recommended continuation")));
			Entry.Headline = FString::Printf(
				TEXT("%s (%s)"),
				*Entry.Headline,
				*ContinuationLabel
			);
		}
		if (bAlignedTightFollowUpOutcomeContinuation
			|| bAlignedBroadRecommendedOutcomeRedirect)
		{
			Entry.Headline = FString::Printf(
				TEXT("%s (%s)"),
				*Entry.Headline,
				bAlignedTightFollowUpOutcomeContinuation
					? TEXT("accepted aligned tight follow-up continuation")
					: TEXT("accepted aligned broad recommended redirect")
			);
		}
		if (bStrongRetainedMethodDrillFollowUpPacketContinuation
			|| bWeakRetainedMethodDrillFollowUpPacketRedirect)
		{
			Entry.Headline = FString::Printf(
				TEXT("%s (packet-proven drill follow-up %s %s)"),
				*Entry.Headline,
				*MethodDrillFollowUpPacketLaneLabel,
				bStrongRetainedMethodDrillFollowUpPacketContinuation
					? TEXT("continuation")
					: TEXT("redirect")
			);
		}
		else if (bStrongMethodDrillRecoveryPacketContinuation
			|| bWeakMethodDrillRecoveryPacketRedirect)
		{
			Entry.Headline = FString::Printf(
				TEXT("%s (packet-proven %s %s)"),
				*Entry.Headline,
				*MethodDrillRecoveryPacketLaneLabel,
				bStrongMethodDrillRecoveryPacketContinuation
					? TEXT("continuation")
					: TEXT("redirect")
			);
		}
		else if (bStrongRetainedMethodDrillRecoveryContinuation
			|| bWeakRetainedMethodDrillRecoveryRedirect)
		{
			Entry.Headline = FString::Printf(
				TEXT("%s (%s)"),
				*Entry.Headline,
				bStrongRetainedMethodDrillRecoveryContinuation
					? TEXT("strong retained drill-recovery continuation")
					: TEXT("weak retained drill-recovery redirect")
			);
		}
		if (CoachMemorySnapshot.PreferredLaunchBudgetBias != 0
			&& (CoachMemorySnapshot.BroadenedLaunchBudgetHistoryCount > 0
				|| CoachMemorySnapshot.TightenedLaunchBudgetHistoryCount > 0))
		{
			const bool bBroadenPreferred = CoachMemorySnapshot.PreferredLaunchBudgetBias > 0;
			const bool bRecommendedEntry = SourceLabel == TEXT("primary-brief");
			const bool bFollowUpEntry = SourceLabel == TEXT("follow-up-brief");
			const bool bEntryMatchesLaunchBudgetBias =
				bBroadenPreferred
					? (bRecommendedEntry || (!bFollowUpEntry && !bHasCompetingGuidanceEntry))
					: (bFollowUpEntry || (!bRecommendedEntry && !bHasCompetingGuidanceEntry));
			if (bEntryMatchesLaunchBudgetBias)
			{
				const FString LaunchBudgetSourceLabel =
					CoachMemorySnapshot.PreferredLaunchBudgetSourceLabel.IsEmpty()
						? TEXT("launch history")
						: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
							CoachMemorySnapshot.PreferredLaunchBudgetSourceLabel);
				Entry.Headline = FString::Printf(
					TEXT("%s (%s launch bias: %s)"),
					*Entry.Headline,
					*HyperTwistTrainingCoachLibraryInternal::DescribeLaunchBudgetBiasLabel(
						CoachMemorySnapshot.PreferredLaunchBudgetBias),
					*LaunchBudgetSourceLabel
				);
			}
		}
		const float GuidanceBias = HyperTwistTrainingCoachLibraryInternal::ResolvePreferredGuidanceQueueBias(
			SourceLabel,
			CoachMemorySnapshot,
			bHasCompetingGuidanceEntry
		);
		const float ArchiveCompetitionBias =
			HyperTwistTrainingCoachLibraryInternal::ResolveArchiveCompetitionQueueBias(
				SourceLabel,
				CoachMemorySnapshot,
				ArchivePolicySummary,
				bShouldCreateFollowUpEntry,
				bHasArchiveEntry
			);
		const float RecoveryActionBias =
			HyperTwistTrainingCoachLibraryInternal::ResolvePreferredRecoveryActionQueueBias(
				SourceLabel,
				CoachMemorySnapshot,
				bHasCompetingGuidanceEntry,
				bHasArchiveEntry
			);
		const float DeferredLaunchBias =
			HyperTwistTrainingCoachLibraryInternal::ResolveDeferredLaunchCompetitionQueueBias(
				SourceLabel,
				FollowUpBrief,
				CoachMemorySnapshot,
				bHasCompetingGuidanceEntry,
				bHasArchiveEntry
			);
		const float MethodDrillQueueBias =
			HyperTwistTrainingCoachLibraryInternal::ResolveMethodDrillFollowUpQueueBias(
				SourceLabel,
				CoachMemorySnapshot,
				bHasCompetingGuidanceEntry
			);
		Entry.PriorityScore = FMath::Clamp(
			Entry.PriorityScore
				+ GuidanceBias
				+ ArchiveCompetitionBias
				+ RecoveryActionBias
				+ DeferredLaunchBias
				+ MethodDrillQueueBias,
			0.0f,
			100.0f
		);
		Entry.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(Entry.PriorityScore);
		Summary.Entries.Add(Entry);
	};

	if (bShouldCreatePrimaryEntry)
	{
		AddBriefEntry(
			TEXT("coach_queue_primary"),
			TEXT("primary-brief"),
			CurrentBrief,
			false,
			false
		);
	}

	if (bShouldCreateFollowUpEntry)
	{
		AddBriefEntry(
			TEXT("coach_queue_follow_up"),
			TEXT("follow-up-brief"),
			FollowUpBrief,
			true,
			false
		);
	}

	if (bHasArchiveEntry)
	{
		FHyperTwistCoachBrief ArchiveBrief;
		ArchiveBrief.UserId = Summary.UserId;
		ArchiveBrief.ReferenceUtc = Summary.ReferenceUtc;
		ArchiveBrief.PriorityScore = FMath::Clamp(
			55.0f + ArchivePolicySummary.ArchiveRetentionTuningScore,
			20.0f,
			100.0f
		);
		ArchiveBrief.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(ArchiveBrief.PriorityScore);
		ArchiveBrief.Headline = ArchivePolicySummary.bNeedsArchiveRetentionTuning
			? TEXT("Archive retention queue needs attention")
			: TEXT("Carry-forward archive queue is still active");
		ArchiveBrief.SuggestedMode = ArchivePolicySummary.DominantSuggestedMode;
		ArchiveBrief.SuggestedSelectionPolicy = ArchivePolicySummary.DominantSelectionPolicy;
		ArchiveBrief.FocusDeckId = ArchivePolicySummary.FocusDeckId;
		ArchiveBrief.FocusMethodSegmentId = ArchivePolicySummary.FocusMethodSegmentId;
		ArchiveBrief.FocusCaseIds = ArchivePolicySummary.ReopenRiskArchivedCaseIds.Num() > 0
			? ArchivePolicySummary.ReopenRiskArchivedCaseIds
			: (ArchivePolicySummary.ProvisionalArchivedCaseIds.Num() > 0
				? ArchivePolicySummary.ProvisionalArchivedCaseIds
				: ArchivePolicySummary.RetainedCarryForwardCaseIds);
		AddBriefEntry(
			TEXT("coach_queue_archive"),
			TEXT("archive-policy"),
			ArchiveBrief,
			false,
			ArchivePolicySummary.bNeedsArchiveRetentionTuning
		);
	}

	Summary.Entries.Sort([](const FHyperTwistCoachSessionQueueEntry& Left, const FHyperTwistCoachSessionQueueEntry& Right)
	{
		if (!FMath::IsNearlyEqual(Left.PriorityScore, Right.PriorityScore))
		{
			return Left.PriorityScore > Right.PriorityScore;
		}
		return Left.EntryId < Right.EntryId;
	});

	for (int32 Index = 0; Index < Summary.Entries.Num(); ++Index)
	{
		Summary.Entries[Index].SlotIndex = Index;
		Summary.FollowUpEntryCount += Summary.Entries[Index].bRequiresFollowUp ? 1 : 0;
		Summary.ArchiveRetentionEntryCount += Summary.Entries[Index].bRequiresArchiveRetentionTuning ? 1 : 0;
		Summary.ReviewBacklogEntryCount += Summary.Entries[Index].SourceLabel == TEXT("primary-brief")
			&& CurrentBrief.FocusLane == EHyperTwistCoachFocusLane::ReviewBacklog
			? 1
			: 0;
	}

	Summary.TotalEntryCount = Summary.Entries.Num();
	Summary.PrimaryQueueLabel = Summary.Entries.Num() > 0
		? Summary.Entries[0].SourceLabel
		: FString();
	Summary.NextQueueLabel = Summary.Entries.Num() > 1
		? Summary.Entries[1].SourceLabel
		: FString();
	Summary.bHasImmediateQueue = Summary.TotalEntryCount > 0;
	Summary.bNeedsArchiveAwareSequencing =
		ArchivePolicySummary.bNeedsArchiveRetentionTuning
		|| Summary.ArchiveRetentionEntryCount > 0
		|| ArchivePolicySummary.RetainedCarryForwardCaseCount > 0
		|| ReviewProgramSummary.bNeedsCoachIntervention;

	return Summary;
}

FHyperTwistCoachSignal UHyperTwistTrainingCoachLibrary::DeriveQueueSuppressionSignal(
	const FHyperTwistCoachSessionQueueSummary& QueueSummary,
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistCoachBrief& CurrentBrief,
	const FHyperTwistCoachBrief& FollowUpBrief)
{
	const bool bSuppressedPrimaryQueueCreation =
		QueueSummary.bSuppressedPrimaryQueueCreation
		&& !QueueSummary.PrimaryQueueSuppressionReason.IsEmpty();
	const bool bSuppressedFollowUpQueueCreation =
		QueueSummary.bSuppressedFollowUpQueueCreation
		&& !QueueSummary.FollowUpQueueSuppressionReason.IsEmpty();
	if (!bSuppressedPrimaryQueueCreation && !bSuppressedFollowUpQueueCreation)
	{
		return FHyperTwistCoachSignal();
	}

	const bool bPromoteDeferredRecovery =
		CoachMemorySnapshot.PreferredQueueRecoveryAction
		== EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred;
	const bool bLaunchRecovery =
		CoachMemorySnapshot.PreferredQueueRecoveryAction
		== EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery;
	const FString DeferredFirstContinuationSourceLabel =
		HyperTwistTrainingCoachLibraryInternal::IsDeferredFirstContinuationSource(
			CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
		)
			? CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
			: (HyperTwistTrainingCoachLibraryInternal::IsDeferredFirstContinuationSource(
				CoachMemorySnapshot.PreferredGuidanceSourceLabel
			)
				? CoachMemorySnapshot.PreferredGuidanceSourceLabel
				: FString());
	const bool bDeferredFirstContinuationSource =
		!DeferredFirstContinuationSourceLabel.IsEmpty();
	const bool bFollowUpPreferred =
		CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp;
	const bool bRecommendedPreferred =
		CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::Recommended;

	const FString SignalId =
		bDeferredFirstContinuationSource && bSuppressedPrimaryQueueCreation
			? TEXT("queue_suppression_deferred_first_continuation")
			: (bSuppressedPrimaryQueueCreation && bSuppressedFollowUpQueueCreation
			? TEXT("queue_suppression_competing_guidance")
			: (bSuppressedPrimaryQueueCreation
				? TEXT("queue_suppression_recommended")
				: TEXT("queue_suppression_follow_up")));
	const FString Headline =
		bDeferredFirstContinuationSource && bSuppressedPrimaryQueueCreation
			? TEXT("Keep the narrowed continuation slice ahead of broader recommendation work")
			: (bSuppressedPrimaryQueueCreation && bSuppressedFollowUpQueueCreation
			? TEXT("Queue recovery is suppressing competing guidance lanes")
			: (bSuppressedPrimaryQueueCreation
				? (bPromoteDeferredRecovery
					? TEXT("Keep follow-up recovery primary while recommended queue work stays suppressed")
					: TEXT("Follow-up recovery remains primary while recommended queue work is intentionally held back"))
				: (bLaunchRecovery
					? TEXT("Keep recommended recovery primary while follow-up queue regeneration stays suppressed")
					: TEXT("Recommended recovery remains primary while follow-up queue work is intentionally held back"))));
	const FString DeferredFirstSourceLabel =
		bDeferredFirstContinuationSource
			? HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
				DeferredFirstContinuationSourceLabel
			)
			: TEXT("n/a");
	const FString Detail = FString::Printf(
		TEXT("primarySuppressed=%s, followUpSuppressed=%s, preferredLane=%s, recoveryAction=%s, pressure=%.2f, deferredFirstHistory=%d, deferredFirstSource=%s, primaryReason=%s, followUpReason=%s"),
		bSuppressedPrimaryQueueCreation ? TEXT("yes") : TEXT("no"),
		bSuppressedFollowUpQueueCreation ? TEXT("yes") : TEXT("no"),
		bFollowUpPreferred
			? TEXT("follow-up")
			: (bRecommendedPreferred ? TEXT("recommended") : TEXT("none")),
		bPromoteDeferredRecovery
			? TEXT("promote-deferred")
			: (bLaunchRecovery ? TEXT("launch-recovery") : TEXT("none")),
		CoachMemorySnapshot.ScheduleExecutionPressureScore,
		CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount,
		*DeferredFirstSourceLabel,
		QueueSummary.PrimaryQueueSuppressionReason.IsEmpty()
			? TEXT("n/a")
			: *QueueSummary.PrimaryQueueSuppressionReason,
		QueueSummary.FollowUpQueueSuppressionReason.IsEmpty()
			? TEXT("n/a")
			: *QueueSummary.FollowUpQueueSuppressionReason
	);
	const float Score = 62.0f
		+ FMath::Min(CoachMemorySnapshot.ScheduleExecutionPressureScore * 0.2f, 18.0f)
		+ (CoachMemorySnapshot.bHasBlockedFollowUpScheduleFriction ? 6.0f : 0.0f)
		+ (CoachMemorySnapshot.bHasOutstandingDeferredScheduleWork ? 4.0f : 0.0f)
		+ (bSuppressedPrimaryQueueCreation && bSuppressedFollowUpQueueCreation ? 5.0f : 0.0f)
		+ (bDeferredFirstContinuationSource ? 4.0f : 0.0f)
		+ (bPromoteDeferredRecovery ? 2.0f : 0.0f);
	const EHyperTwistCoachFocusLane FocusLane =
		CoachMemorySnapshot.bHasArchiveAwareScheduleFriction
		&& !CoachMemorySnapshot.bHasBlockedFollowUpScheduleFriction
			? EHyperTwistCoachFocusLane::Stability
			: EHyperTwistCoachFocusLane::Cadence;
	const FHyperTwistCoachBrief& SurvivingBrief =
		bSuppressedPrimaryQueueCreation && FollowUpBrief.UserId == QueueSummary.UserId
			? FollowUpBrief
			: CurrentBrief;
	const EHyperTwistTrainingDeliveryMode SuggestedMode =
		SurvivingBrief.UserId == QueueSummary.UserId
			? SurvivingBrief.SuggestedMode
			: CoachMemorySnapshot.DominantCoachSuggestedMode;
	const EHyperTwistTrainingSelectionPolicy SuggestedSelectionPolicy =
		SurvivingBrief.UserId == QueueSummary.UserId
			? SurvivingBrief.SuggestedSelectionPolicy
			: CoachMemorySnapshot.DominantCoachSelectionPolicy;

	FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
		SignalId,
		FocusLane,
		Score,
		Headline,
		Detail,
		SuggestedMode,
		SuggestedSelectionPolicy
	);
	Signal.SuggestedDeckId = !SurvivingBrief.FocusDeckId.IsEmpty()
		? SurvivingBrief.FocusDeckId
		: QueueSummary.FocusDeckId;
	Signal.SuggestedMethodSegmentId = !SurvivingBrief.FocusMethodSegmentId.IsEmpty()
		? SurvivingBrief.FocusMethodSegmentId
		: QueueSummary.FocusMethodSegmentId;
	Signal.SuggestedCaseIds = SurvivingBrief.FocusCaseIds.Num() > 0
		? SurvivingBrief.FocusCaseIds
		: CoachMemorySnapshot.SchedulePressureCaseIds;
	HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
		Signal,
		bSuppressedPrimaryQueueCreation
			? EHyperTwistTrainingCoachGuidanceLane::FollowUp
			: (bSuppressedFollowUpQueueCreation
				? EHyperTwistTrainingCoachGuidanceLane::Recommended
				: CoachMemorySnapshot.PreferredGuidanceLane),
		CoachMemorySnapshot,
		true
	);
	return Signal;
}

FHyperTwistCoachBrief UHyperTwistTrainingCoachLibrary::RefineCoachBriefWithQueueSuppressionSignal(
	const FHyperTwistCoachBrief& BaseBrief,
	const FHyperTwistCoachSignal& QueueSuppressionSignal)
{
	if (QueueSuppressionSignal.SignalId.IsEmpty())
	{
		return BaseBrief;
	}

	FHyperTwistCoachBrief Brief = BaseBrief;
	if (!Brief.Signals.ContainsByPredicate(
		[&QueueSuppressionSignal](const FHyperTwistCoachSignal& Candidate)
		{
			return Candidate.SignalId == QueueSuppressionSignal.SignalId;
		}))
	{
		Brief.Signals.Add(QueueSuppressionSignal);
	}
	HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);

	const bool bScheduleFacingBrief =
		Brief.FocusLane == EHyperTwistCoachFocusLane::Cadence
		|| Brief.FocusLane == EHyperTwistCoachFocusLane::Stability
		|| Brief.bNeedsCadenceRecovery;
	const bool bShouldPromoteSuppressionSignal =
		bScheduleFacingBrief
		&& QueueSuppressionSignal.Score >= Brief.PriorityScore - 4.0f;
	if (bShouldPromoteSuppressionSignal)
	{
		for (FHyperTwistCoachSignal& Signal : Brief.Signals)
		{
			if (Signal.SignalId == QueueSuppressionSignal.SignalId)
			{
				Signal.Score = FMath::Clamp(FMath::Max(Signal.Score, Brief.Signals[0].Score + 0.5f), 0.0f, 100.0f);
				Signal.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(Signal.Score);
				Signal.bNeedsImmediateAttention = Signal.Priority == EHyperTwistCoachPriority::Critical;
				break;
			}
		}
		HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);
	}

	if (Brief.Signals.Num() > 0)
	{
		const FString OriginalDeckId = Brief.FocusDeckId;
		const FString OriginalMethodSegmentId = Brief.FocusMethodSegmentId;
		const TArray<FString> OriginalCaseIds = Brief.FocusCaseIds;
		const FString OriginalPrimaryActionLabel = Brief.PrimaryActionLabel;
		HyperTwistTrainingCoachLibraryInternal::ApplyPrimarySignalToBrief(Brief, Brief.Signals[0]);
		if (Brief.FocusDeckId.IsEmpty())
		{
			Brief.FocusDeckId = OriginalDeckId;
		}
		if (Brief.FocusMethodSegmentId.IsEmpty())
		{
			Brief.FocusMethodSegmentId = OriginalMethodSegmentId;
		}
		if (Brief.FocusCaseIds.Num() <= 0)
		{
			Brief.FocusCaseIds = OriginalCaseIds;
		}
		if (bShouldPromoteSuppressionSignal
			&& Brief.PrimaryActionLabel == QueueSuppressionSignal.SignalId
			&& (!OriginalPrimaryActionLabel.IsEmpty()
				&& (OriginalPrimaryActionLabel.Contains(TEXT("schedule"))
					|| OriginalPrimaryActionLabel.Contains(TEXT("recovery"))
					|| OriginalPrimaryActionLabel.Contains(TEXT("promote_deferred")))))
		{
			Brief.PrimaryActionLabel = OriginalPrimaryActionLabel;
		}
	}

	return Brief;
}

FHyperTwistCoachSignal UHyperTwistTrainingCoachLibrary::DeriveSchedulePolicyFeedbackSignal(
	const FHyperTwistCoachSchedulePolicySummary& SchedulePolicySummary,
	const FHyperTwistTrainingCoachSessionQueueExecutionSummary& QueueExecutionSummary,
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistCoachBrief& CurrentBrief)
{
	if (!SchedulePolicySummary.IsStructurallyValid() || !QueueExecutionSummary.IsStructurallyValid())
	{
		return FHyperTwistCoachSignal();
	}

	const bool bManualRescheduleReview = SchedulePolicySummary.bNeedsManualRescheduleReview;
	const bool bArchiveAwareDeferrals = SchedulePolicySummary.bHasArchiveAwareDeferrals;
	const bool bBlockedFollowUpDeferrals = SchedulePolicySummary.bHasBlockedFollowUpDeferrals;
	const bool bOutstandingDeferredWork = QueueExecutionSummary.bHasOutstandingDeferredWork;
	const bool bCompletionGap = QueueExecutionSummary.bHasCompletionGap;
	const bool bRepeatManualReschedule = QueueExecutionSummary.bHasRepeatManualRescheduleFriction;
	const bool bHighPolicyPressure = SchedulePolicySummary.ReschedulePressureScore >= 25.0f;
	const bool bHighExecutionPressure = QueueExecutionSummary.ExecutionPressureScore >= 25.0f;
	const bool bNeedsFeedback =
		bHighPolicyPressure
		|| bHighExecutionPressure
		|| bManualRescheduleReview
		|| bArchiveAwareDeferrals
		|| bBlockedFollowUpDeferrals
		|| bOutstandingDeferredWork
		|| bCompletionGap
		|| bRepeatManualReschedule;
	if (!bNeedsFeedback)
	{
		return FHyperTwistCoachSignal();
	}

	const bool bHistoryPrefersFollowUp =
		SchedulePolicySummary.bFollowUpContinuationFromRecoveryHistory;
	const bool bHistoryPrefersRecommended =
		SchedulePolicySummary.bBorderlineFollowUpSuppressedByRecoveryHistory;
	const bool bPreferFollowUpRecovery =
		bBlockedFollowUpDeferrals
		|| bHistoryPrefersFollowUp
		|| CoachMemorySnapshot.PreferredGuidanceLane
			== EHyperTwistTrainingCoachGuidanceLane::FollowUp;
	const bool bPreferRecommendedRecovery =
		!bPreferFollowUpRecovery
		&& (
			bHistoryPrefersRecommended
			|| CoachMemorySnapshot.PreferredGuidanceLane
				== EHyperTwistTrainingCoachGuidanceLane::Recommended
		);
	const bool bCompetingGuidancePressure =
		CoachMemorySnapshot.RecommendedGuidanceContinueBias > 0
		&& CoachMemorySnapshot.FollowUpGuidanceContinueBias > 0;

	const FString SignalId = bPreferFollowUpRecovery
		? TEXT("recover_follow_up_schedule_friction")
		: (bPreferRecommendedRecovery
			? TEXT("recover_recommended_schedule_friction")
			: (bArchiveAwareDeferrals
				? TEXT("stabilize_archive_aware_schedule")
				: (bManualRescheduleReview
					? TEXT("review_manual_schedule_friction")
					: (bCompletionGap
						? TEXT("recover_schedule_completion_gap")
						: TEXT("recover_schedule_friction")))));
	const FString Headline =
		bBlockedFollowUpDeferrals
			? (bCompletionGap
				? TEXT("Live queue friction is still blocking follow-up completion")
				: TEXT("Live queue friction is still holding follow-up work back"))
			: (bManualRescheduleReview
				? TEXT("Manual reschedule pressure is still shaping the next coaching run")
				: (bArchiveAwareDeferrals
					? TEXT("Archive-aware deferrals are still shaping the next coaching run")
					: (bCompletionGap
						? TEXT("Live queue execution still needs a tighter completion pass")
						: TEXT("Deferred queue work still needs schedule recovery"))));
	const FString Detail = FString::Printf(
		TEXT("policyPressure=%.2f, executionPressure=%.2f, immediate=%d, pending=%d, deferred=%d, manualRescheduleEntries=%d, manualRescheduleEvents=%d, completionGap=%s, outstandingDeferred=%s, blockedFollowUp=%s, archiveAware=%s, dominantDeferral=%s, closure=%s"),
		SchedulePolicySummary.ReschedulePressureScore,
		QueueExecutionSummary.ExecutionPressureScore,
		SchedulePolicySummary.ImmediateEntryCount,
		SchedulePolicySummary.PendingEntryCount,
		SchedulePolicySummary.DeferredEntryCount,
		SchedulePolicySummary.ManualRescheduleEntryCount,
		QueueExecutionSummary.ManualRescheduleEventCount,
		bCompletionGap ? TEXT("yes") : TEXT("no"),
		bOutstandingDeferredWork ? TEXT("yes") : TEXT("no"),
		bBlockedFollowUpDeferrals ? TEXT("yes") : TEXT("no"),
		bArchiveAwareDeferrals ? TEXT("yes") : TEXT("no"),
		SchedulePolicySummary.DominantDeferralReasonLabel.IsEmpty()
			? TEXT("n/a")
			: *SchedulePolicySummary.DominantDeferralReasonLabel,
		SchedulePolicySummary.ClosurePolicyLine.IsEmpty()
			? TEXT("n/a")
			: *SchedulePolicySummary.ClosurePolicyLine
	);
	const float Score = FMath::Clamp(
		59.0f
			+ FMath::Min(SchedulePolicySummary.ReschedulePressureScore * 0.22f, 18.0f)
			+ FMath::Min(QueueExecutionSummary.ExecutionPressureScore * 0.18f, 14.0f)
			+ (bBlockedFollowUpDeferrals ? 7.0f : 0.0f)
			+ (bManualRescheduleReview ? 5.0f : 0.0f)
			+ (bArchiveAwareDeferrals ? 4.0f : 0.0f)
			+ (bOutstandingDeferredWork ? 5.0f : 0.0f)
			+ (bCompletionGap ? 5.0f : 0.0f)
			+ (bRepeatManualReschedule ? 4.0f : 0.0f),
		0.0f,
		100.0f
	);
	const EHyperTwistCoachFocusLane FocusLane =
		bArchiveAwareDeferrals && !bBlockedFollowUpDeferrals
			? EHyperTwistCoachFocusLane::Stability
			: EHyperTwistCoachFocusLane::Cadence;
	const EHyperTwistTrainingDeliveryMode SuggestedMode =
		bPreferFollowUpRecovery
			? EHyperTwistTrainingDeliveryMode::CoachReviewed
			: ((CurrentBrief.UserId == SchedulePolicySummary.UserId
				&& CurrentBrief.SuggestedMode != EHyperTwistTrainingDeliveryMode::Timer)
				? CurrentBrief.SuggestedMode
				: CoachMemorySnapshot.DominantCoachSuggestedMode);
	const EHyperTwistTrainingSelectionPolicy SuggestedSelectionPolicy =
		bPreferFollowUpRecovery
			? EHyperTwistTrainingSelectionPolicy::Scripted
			: ((bCompletionGap || bOutstandingDeferredWork)
				? EHyperTwistTrainingSelectionPolicy::Weighted
				: ((CurrentBrief.UserId == SchedulePolicySummary.UserId
					&& CurrentBrief.SuggestedSelectionPolicy
						!= EHyperTwistTrainingSelectionPolicy::Weighted)
					? CurrentBrief.SuggestedSelectionPolicy
					: CoachMemorySnapshot.DominantCoachSelectionPolicy));

	FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
		SignalId,
		FocusLane,
		Score,
		Headline,
		Detail,
		SuggestedMode,
		SuggestedSelectionPolicy
	);
	Signal.SuggestedDeckId = !CurrentBrief.FocusDeckId.IsEmpty()
		? CurrentBrief.FocusDeckId
		: SchedulePolicySummary.FocusDeckId;
	Signal.SuggestedMethodSegmentId = !CurrentBrief.FocusMethodSegmentId.IsEmpty()
		? CurrentBrief.FocusMethodSegmentId
		: SchedulePolicySummary.FocusMethodSegmentId;
	Signal.SuggestedCaseIds = CurrentBrief.FocusCaseIds.Num() > 0
		? CurrentBrief.FocusCaseIds
		: (CoachMemorySnapshot.SchedulePressureCaseIds.Num() > 0
			? CoachMemorySnapshot.SchedulePressureCaseIds
			: CoachMemorySnapshot.DueCaseIds);
	HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
		Signal,
		bPreferFollowUpRecovery
			? EHyperTwistTrainingCoachGuidanceLane::FollowUp
			: (bPreferRecommendedRecovery
				? EHyperTwistTrainingCoachGuidanceLane::Recommended
				: CoachMemorySnapshot.PreferredGuidanceLane),
		CoachMemorySnapshot,
		bCompetingGuidancePressure
	);
	return Signal;
}

FHyperTwistCoachBrief UHyperTwistTrainingCoachLibrary::RefineCoachBriefWithSchedulePolicyFeedbackSignal(
	const FHyperTwistCoachBrief& BaseBrief,
	const FHyperTwistCoachSignal& SchedulePolicyFeedbackSignal)
{
	if (SchedulePolicyFeedbackSignal.SignalId.IsEmpty())
	{
		return BaseBrief;
	}

	FHyperTwistCoachBrief Brief = BaseBrief;
	if (!Brief.Signals.ContainsByPredicate(
		[&SchedulePolicyFeedbackSignal](const FHyperTwistCoachSignal& Candidate)
		{
			return Candidate.SignalId == SchedulePolicyFeedbackSignal.SignalId;
		}))
	{
		Brief.Signals.Add(SchedulePolicyFeedbackSignal);
	}
	HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);

	const bool bPolicyFacingBrief =
		Brief.FocusLane == EHyperTwistCoachFocusLane::Cadence
		|| Brief.FocusLane == EHyperTwistCoachFocusLane::Stability
		|| Brief.bNeedsCadenceRecovery;
	const bool bShouldPromotePolicySignal =
		bPolicyFacingBrief
		&& SchedulePolicyFeedbackSignal.Score >= Brief.PriorityScore - 3.5f;
	if (bShouldPromotePolicySignal)
	{
		for (FHyperTwistCoachSignal& Signal : Brief.Signals)
		{
			if (Signal.SignalId == SchedulePolicyFeedbackSignal.SignalId)
			{
				Signal.Score = FMath::Clamp(
					FMath::Max(Signal.Score, Brief.Signals[0].Score + 0.5f),
					0.0f,
					100.0f
				);
				Signal.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(Signal.Score);
				Signal.bNeedsImmediateAttention = Signal.Priority == EHyperTwistCoachPriority::Critical;
				break;
			}
		}
		HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);
	}

	if (Brief.Signals.Num() > 0)
	{
		const FString OriginalDeckId = Brief.FocusDeckId;
		const FString OriginalMethodSegmentId = Brief.FocusMethodSegmentId;
		const TArray<FString> OriginalCaseIds = Brief.FocusCaseIds;
		const FString OriginalPrimaryActionLabel = Brief.PrimaryActionLabel;
		HyperTwistTrainingCoachLibraryInternal::ApplyPrimarySignalToBrief(Brief, Brief.Signals[0]);
		if (Brief.FocusDeckId.IsEmpty())
		{
			Brief.FocusDeckId = OriginalDeckId;
		}
		if (Brief.FocusMethodSegmentId.IsEmpty())
		{
			Brief.FocusMethodSegmentId = OriginalMethodSegmentId;
		}
		if (Brief.FocusCaseIds.Num() <= 0)
		{
			Brief.FocusCaseIds = OriginalCaseIds;
		}
		if (bShouldPromotePolicySignal
			&& Brief.PrimaryActionLabel == SchedulePolicyFeedbackSignal.SignalId
			&& (!OriginalPrimaryActionLabel.IsEmpty()
				&& (OriginalPrimaryActionLabel.Contains(TEXT("schedule"))
					|| OriginalPrimaryActionLabel.Contains(TEXT("recovery"))
					|| OriginalPrimaryActionLabel.Contains(TEXT("promote_deferred"))
					|| OriginalPrimaryActionLabel.Contains(TEXT("reschedule"))
					|| OriginalPrimaryActionLabel.Contains(TEXT("archive")))))
		{
			Brief.PrimaryActionLabel = OriginalPrimaryActionLabel;
		}
	}

	return Brief;
}

FHyperTwistCoachSignal UHyperTwistTrainingCoachLibrary::DeriveClosureRecoveryHistorySignal(
	const FHyperTwistTrainingCoachActionClosureSummary& ClosureSummary,
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistCoachBrief& CurrentBrief)
{
	if (!ClosureSummary.IsStructurallyValid())
	{
		return FHyperTwistCoachSignal();
	}

	const int32 SustainedHistoryCount = CoachMemorySnapshot.RecoverySustainedFollowUpHistoryCount;
	const int32 SuppressedHistoryCount =
		CoachMemorySnapshot.RecoverySuppressedBorderlineFollowUpHistoryCount;
	if (SustainedHistoryCount <= 0 && SuppressedHistoryCount <= 0)
	{
		return FHyperTwistCoachSignal();
	}

	const bool bHistoryPrefersFollowUp = SustainedHistoryCount > SuppressedHistoryCount;
	const bool bHistoryPrefersRecommended = SuppressedHistoryCount > SustainedHistoryCount;
	if (!bHistoryPrefersFollowUp && !bHistoryPrefersRecommended)
	{
		return FHyperTwistCoachSignal();
	}

	const bool bCurrentFollowUpContinuation =
		ClosureSummary.bSpawnFollowUpFromSuppressionMemory;
	const bool bCurrentBorderlineSuppression =
		ClosureSummary.bSuppressedBorderlineFollowUpByRecoveryHistory;
	const bool bCompetingGuidancePressure =
		CoachMemorySnapshot.RecommendedGuidanceContinueBias > 0
		&& CoachMemorySnapshot.FollowUpGuidanceContinueBias > 0;

	const float Score = FMath::Clamp(
		(bHistoryPrefersFollowUp ? 64.0f : 60.0f)
			+ static_cast<float>(FMath::Max(SustainedHistoryCount, SuppressedHistoryCount)) * 4.0f
			+ (bCurrentFollowUpContinuation || bCurrentBorderlineSuppression ? 6.0f : 0.0f)
			+ (bCompetingGuidancePressure ? 4.0f : 0.0f),
		0.0f,
		100.0f
	);
	const FString SignalId = bHistoryPrefersFollowUp
		? TEXT("closure_history_follow_up_continuation")
		: TEXT("closure_history_recommended_suppression");
	const EHyperTwistCoachFocusLane FocusLane = bHistoryPrefersFollowUp
		? EHyperTwistCoachFocusLane::Cadence
		: EHyperTwistCoachFocusLane::Stability;
	const FString Headline = bHistoryPrefersFollowUp
		? (bCurrentFollowUpContinuation
			? TEXT("Recovery history keeps follow-up continuity alive")
			: TEXT("Recovery history favors sustained follow-up continuity"))
		: (bCurrentBorderlineSuppression
			? TEXT("Recovery history suppresses borderline follow-up regeneration")
			: TEXT("Recovery history favors recommended consolidation over borderline follow-up"));
	const FString Detail = FString::Printf(
		TEXT("keepHistory=%d, suppressHistory=%d, currentClosure=%s, followUpReady=%d, recoverySource=%s"),
		SustainedHistoryCount,
		SuppressedHistoryCount,
		ClosureSummary.ClosureLabel.IsEmpty() ? TEXT("n/a") : *ClosureSummary.ClosureLabel,
		CoachMemorySnapshot.FollowUpReadyCoachSequenceCount,
		CoachMemorySnapshot.PreferredGuidanceSourceLabel.IsEmpty()
			? TEXT("n/a")
			: *HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
				CoachMemorySnapshot.PreferredGuidanceSourceLabel)
	);
	const EHyperTwistTrainingDeliveryMode SuggestedMode = bHistoryPrefersFollowUp
		? EHyperTwistTrainingDeliveryMode::CoachReviewed
		: CoachMemorySnapshot.DominantCoachSuggestedMode;
	const EHyperTwistTrainingSelectionPolicy SuggestedSelectionPolicy = bHistoryPrefersFollowUp
		? EHyperTwistTrainingSelectionPolicy::Scripted
		: CoachMemorySnapshot.DominantCoachSelectionPolicy;

	FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
		SignalId,
		FocusLane,
		Score,
		Headline,
		Detail,
		SuggestedMode,
		SuggestedSelectionPolicy
	);
	Signal.SuggestedDeckId = !CurrentBrief.FocusDeckId.IsEmpty()
		? CurrentBrief.FocusDeckId
		: CoachMemorySnapshot.FocusDeckId;
	Signal.SuggestedMethodSegmentId = !CurrentBrief.FocusMethodSegmentId.IsEmpty()
		? CurrentBrief.FocusMethodSegmentId
		: CoachMemorySnapshot.FocusMethodSegmentId;
	Signal.SuggestedCaseIds = bHistoryPrefersFollowUp
		? (CoachMemorySnapshot.SchedulePressureCaseIds.Num() > 0
			? CoachMemorySnapshot.SchedulePressureCaseIds
			: CoachMemorySnapshot.PersistentCoachWeakCaseIds)
		: (CoachMemorySnapshot.RecurringCoachCaseIds.Num() > 0
			? CoachMemorySnapshot.RecurringCoachCaseIds
			: CoachMemorySnapshot.DueCaseIds);
	HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
		Signal,
		bHistoryPrefersFollowUp
			? EHyperTwistTrainingCoachGuidanceLane::FollowUp
			: EHyperTwistTrainingCoachGuidanceLane::Recommended,
		CoachMemorySnapshot,
		bCompetingGuidancePressure
	);
	return Signal;
}

FHyperTwistCoachBrief UHyperTwistTrainingCoachLibrary::RefineCoachBriefWithClosureRecoveryHistorySignal(
	const FHyperTwistCoachBrief& BaseBrief,
	const FHyperTwistCoachSignal& ClosureRecoveryHistorySignal)
{
	if (ClosureRecoveryHistorySignal.SignalId.IsEmpty())
	{
		return BaseBrief;
	}

	FHyperTwistCoachBrief Brief = BaseBrief;
	if (!Brief.Signals.ContainsByPredicate(
		[&ClosureRecoveryHistorySignal](const FHyperTwistCoachSignal& Candidate)
		{
			return Candidate.SignalId == ClosureRecoveryHistorySignal.SignalId;
		}))
	{
		Brief.Signals.Add(ClosureRecoveryHistorySignal);
	}
	HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);

	const bool bPolicyFacingBrief =
		Brief.FocusLane == EHyperTwistCoachFocusLane::Cadence
		|| Brief.FocusLane == EHyperTwistCoachFocusLane::Stability
		|| Brief.bNeedsCadenceRecovery;
	const bool bShouldPromoteHistorySignal =
		bPolicyFacingBrief
		&& ClosureRecoveryHistorySignal.Score >= Brief.PriorityScore - 5.0f;
	if (bShouldPromoteHistorySignal)
	{
		for (FHyperTwistCoachSignal& Signal : Brief.Signals)
		{
			if (Signal.SignalId == ClosureRecoveryHistorySignal.SignalId)
			{
				Signal.Score = FMath::Clamp(
					FMath::Max(Signal.Score, Brief.Signals[0].Score + 0.5f),
					0.0f,
					100.0f
				);
				Signal.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(Signal.Score);
				Signal.bNeedsImmediateAttention = Signal.Priority == EHyperTwistCoachPriority::Critical;
				break;
			}
		}
		HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);
	}

	if (Brief.Signals.Num() > 0)
	{
		const FString OriginalDeckId = Brief.FocusDeckId;
		const FString OriginalMethodSegmentId = Brief.FocusMethodSegmentId;
		const TArray<FString> OriginalCaseIds = Brief.FocusCaseIds;
		HyperTwistTrainingCoachLibraryInternal::ApplyPrimarySignalToBrief(Brief, Brief.Signals[0]);
		if (Brief.FocusDeckId.IsEmpty())
		{
			Brief.FocusDeckId = OriginalDeckId;
		}
		if (Brief.FocusMethodSegmentId.IsEmpty())
		{
			Brief.FocusMethodSegmentId = OriginalMethodSegmentId;
		}
		if (Brief.FocusCaseIds.Num() <= 0)
		{
			Brief.FocusCaseIds = OriginalCaseIds;
		}
	}

	return Brief;
}

FHyperTwistCoachSignal UHyperTwistTrainingCoachLibrary::DeriveLaunchBudgetHistorySignal(
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistCoachBrief& CurrentBrief)
{
	if (CoachMemorySnapshot.PreferredLaunchBudgetBias == 0
		|| (CoachMemorySnapshot.BroadenedLaunchBudgetHistoryCount <= 0
			&& CoachMemorySnapshot.TightenedLaunchBudgetHistoryCount <= 0))
	{
		return FHyperTwistCoachSignal();
	}

	const bool bBroadenPreferred = CoachMemorySnapshot.PreferredLaunchBudgetBias > 0;
	const bool bScheduleTighteningSource =
		!bBroadenPreferred
		&& CoachMemorySnapshot.PreferredLaunchBudgetSourceLabel.StartsWith(TEXT("coach-memory-schedule-"));
	const bool bFollowUpScheduleTightening =
		bScheduleTighteningSource
		&& CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp;
	const bool bCompetingGuidancePressure =
		CoachMemorySnapshot.RecommendedGuidanceContinueBias > 0
		&& CoachMemorySnapshot.FollowUpGuidanceContinueBias > 0;
	const float Score = FMath::Clamp(
		58.0f
			+ static_cast<float>(FMath::Max(
				CoachMemorySnapshot.BroadenedLaunchBudgetHistoryCount,
				CoachMemorySnapshot.TightenedLaunchBudgetHistoryCount)) * 4.0f
			+ (bCompetingGuidancePressure ? 4.0f : 0.0f)
			+ ((CurrentBrief.FocusLane == EHyperTwistCoachFocusLane::Cadence
				|| CurrentBrief.FocusLane == EHyperTwistCoachFocusLane::Stability
				|| CurrentBrief.FocusLane == EHyperTwistCoachFocusLane::ReviewBacklog) ? 3.0f : 0.0f)
			+ (bScheduleTighteningSource ? 4.0f : 0.0f),
		0.0f,
		100.0f
	);
	const FString SignalId = bBroadenPreferred
		? TEXT("launch_budget_history_broaden")
		: (bFollowUpScheduleTightening
			? TEXT("launch_budget_schedule_follow_up_tighten")
			: (bScheduleTighteningSource
				? TEXT("launch_budget_schedule_recommended_tighten")
				: TEXT("launch_budget_history_tighten")));
	const EHyperTwistCoachFocusLane FocusLane = bBroadenPreferred
		? EHyperTwistCoachFocusLane::ReviewBacklog
		: (bScheduleTighteningSource
			? EHyperTwistCoachFocusLane::Cadence
			: EHyperTwistCoachFocusLane::Stability);
	const FString Headline = bBroadenPreferred
		? TEXT("Launch history favors a broader next coach run")
		: (bScheduleTighteningSource
			? (CoachMemorySnapshot.bHasBlockedFollowUpScheduleFriction
				? TEXT("Schedule friction favors a tighter next coach run before broader guidance resumes")
				: TEXT("Schedule recovery favors a tighter next coach run before broader guidance resumes"))
			: TEXT("Launch history favors a tighter next coach run"));
	const FString PreferredGuidanceLaneLabel =
		CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp
			? TEXT("follow-up")
			: (CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::Recommended
				? TEXT("recommended")
				: TEXT("none"));
	const FString Detail = FString::Printf(
		TEXT("launchBias=%s, broadenedHistory=%d, tightenedHistory=%d, guidanceLane=%s, handoff=%s, source=%s"),
		bBroadenPreferred ? TEXT("broaden") : TEXT("tighten"),
		CoachMemorySnapshot.BroadenedLaunchBudgetHistoryCount,
		CoachMemorySnapshot.TightenedLaunchBudgetHistoryCount,
		*PreferredGuidanceLaneLabel,
		*HyperTwistTrainingCoachLibraryInternal::DescribeCoachHandoffKind(
			CoachMemorySnapshot.PreferredCoachHandoffKind),
		CoachMemorySnapshot.PreferredLaunchBudgetSourceLabel.IsEmpty()
			? TEXT("n/a")
			: *HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
				CoachMemorySnapshot.PreferredLaunchBudgetSourceLabel)
	);
	const EHyperTwistTrainingDeliveryMode SuggestedMode = bScheduleTighteningSource
		? (bFollowUpScheduleTightening
			? EHyperTwistTrainingDeliveryMode::CoachReviewed
			: CoachMemorySnapshot.DominantCoachSuggestedMode)
		: (CurrentBrief.SuggestedMode != EHyperTwistTrainingDeliveryMode::Timer
			? CurrentBrief.SuggestedMode
			: CoachMemorySnapshot.DominantCoachSuggestedMode);
	const EHyperTwistTrainingSelectionPolicy SuggestedSelectionPolicy = bScheduleTighteningSource
		? (bFollowUpScheduleTightening
			? EHyperTwistTrainingSelectionPolicy::Scripted
			: (CoachMemorySnapshot.bHasQueueExecutionCompletionGap
				? EHyperTwistTrainingSelectionPolicy::Weighted
				: CoachMemorySnapshot.DominantCoachSelectionPolicy))
		: (CurrentBrief.SuggestedSelectionPolicy != EHyperTwistTrainingSelectionPolicy::Weighted
			? CurrentBrief.SuggestedSelectionPolicy
			: CoachMemorySnapshot.DominantCoachSelectionPolicy);

	FHyperTwistCoachSignal Signal = HyperTwistTrainingCoachLibraryInternal::MakeSignal(
		SignalId,
		FocusLane,
		Score,
		Headline,
		Detail,
		SuggestedMode,
		SuggestedSelectionPolicy
	);
	Signal.SuggestedDeckId = !CurrentBrief.FocusDeckId.IsEmpty()
		? CurrentBrief.FocusDeckId
		: CoachMemorySnapshot.FocusDeckId;
	Signal.SuggestedMethodSegmentId = !CurrentBrief.FocusMethodSegmentId.IsEmpty()
		? CurrentBrief.FocusMethodSegmentId
		: CoachMemorySnapshot.FocusMethodSegmentId;
	Signal.SuggestedCaseIds = bScheduleTighteningSource && CoachMemorySnapshot.SchedulePressureCaseIds.Num() > 0
		? CoachMemorySnapshot.SchedulePressureCaseIds
		: (CurrentBrief.FocusCaseIds.Num() > 0
			? CurrentBrief.FocusCaseIds
			: (CoachMemorySnapshot.WeakCaseIds.Num() > 0
				? CoachMemorySnapshot.WeakCaseIds
				: CoachMemorySnapshot.DueCaseIds));
	HyperTwistTrainingCoachLibraryInternal::ApplyGuidancePreferenceToSignal(
		Signal,
		CoachMemorySnapshot.PreferredGuidanceLane,
		CoachMemorySnapshot,
		bCompetingGuidancePressure
	);
	return Signal;
}

FHyperTwistCoachBrief UHyperTwistTrainingCoachLibrary::RefineCoachBriefWithLaunchBudgetHistorySignal(
	const FHyperTwistCoachBrief& BaseBrief,
	const FHyperTwistCoachSignal& LaunchBudgetHistorySignal)
{
	if (LaunchBudgetHistorySignal.SignalId.IsEmpty())
	{
		return BaseBrief;
	}

	FHyperTwistCoachBrief Brief = BaseBrief;
	if (!Brief.Signals.ContainsByPredicate(
		[&LaunchBudgetHistorySignal](const FHyperTwistCoachSignal& Candidate)
		{
			return Candidate.SignalId == LaunchBudgetHistorySignal.SignalId;
		}))
	{
		Brief.Signals.Add(LaunchBudgetHistorySignal);
	}
	HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);

	const bool bLaunchFacingBrief =
		Brief.FocusLane == EHyperTwistCoachFocusLane::ReviewBacklog
		|| Brief.FocusLane == EHyperTwistCoachFocusLane::Cadence
		|| Brief.FocusLane == EHyperTwistCoachFocusLane::Stability
		|| Brief.bNeedsCadenceRecovery;
	const bool bShouldPromoteLaunchSignal =
		bLaunchFacingBrief
		&& LaunchBudgetHistorySignal.Score >= Brief.PriorityScore - 4.0f;
	if (bShouldPromoteLaunchSignal)
	{
		for (FHyperTwistCoachSignal& Signal : Brief.Signals)
		{
			if (Signal.SignalId == LaunchBudgetHistorySignal.SignalId)
			{
				Signal.Score = FMath::Clamp(
					FMath::Max(Signal.Score, Brief.Signals[0].Score + 0.5f),
					0.0f,
					100.0f
				);
				Signal.Priority = HyperTwistTrainingCoachLibraryInternal::PriorityFromScore(Signal.Score);
				Signal.bNeedsImmediateAttention = Signal.Priority == EHyperTwistCoachPriority::Critical;
				break;
			}
		}
		HyperTwistTrainingCoachLibraryInternal::SortSignals(Brief.Signals);
	}

	if (Brief.Signals.Num() > 0)
	{
		const FString OriginalDeckId = Brief.FocusDeckId;
		const FString OriginalMethodSegmentId = Brief.FocusMethodSegmentId;
		const TArray<FString> OriginalCaseIds = Brief.FocusCaseIds;
		const FString OriginalPrimaryActionLabel = Brief.PrimaryActionLabel;
		HyperTwistTrainingCoachLibraryInternal::ApplyPrimarySignalToBrief(Brief, Brief.Signals[0]);
		if (Brief.FocusDeckId.IsEmpty())
		{
			Brief.FocusDeckId = OriginalDeckId;
		}
		if (Brief.FocusMethodSegmentId.IsEmpty())
		{
			Brief.FocusMethodSegmentId = OriginalMethodSegmentId;
		}
		if (Brief.FocusCaseIds.Num() <= 0)
		{
			Brief.FocusCaseIds = OriginalCaseIds;
		}
		if (bShouldPromoteLaunchSignal)
		{
			if (Brief.PrimaryActionLabel == TEXT("launch_budget_schedule_follow_up_tighten"))
			{
				Brief.PrimaryActionLabel = TEXT("launch_follow_up_recovery");
			}
			else if (Brief.PrimaryActionLabel == TEXT("launch_budget_schedule_recommended_tighten"))
			{
				Brief.PrimaryActionLabel = TEXT("launch_recommended_recovery");
			}
			else if (Brief.PrimaryActionLabel == LaunchBudgetHistorySignal.SignalId
				&& (!OriginalPrimaryActionLabel.IsEmpty()
					&& (OriginalPrimaryActionLabel.Contains(TEXT("schedule"))
						|| OriginalPrimaryActionLabel.Contains(TEXT("recovery"))
						|| OriginalPrimaryActionLabel.Contains(TEXT("promote_deferred")))))
			{
				Brief.PrimaryActionLabel = OriginalPrimaryActionLabel;
			}
		}
	}

	return Brief;
}

FHyperTwistCoachScheduleHorizonSummary UHyperTwistTrainingCoachLibrary::DeriveCoachScheduleHorizonSummary(
	const FHyperTwistTrainingCoachSessionQueueState& QueueState,
	const FHyperTwistTrainingCoachArchivePolicySummary& ArchivePolicySummary,
	const FString& ReferenceUtc
)
{
	FHyperTwistCoachScheduleHorizonSummary Summary;
	if (!QueueState.IsStructurallyValid())
	{
		return Summary;
	}

	Summary.UserId = QueueState.UserId;
	Summary.ReferenceUtc = !ReferenceUtc.IsEmpty()
		? ReferenceUtc
		: (!QueueState.LastUpdatedAtUtc.IsEmpty() ? QueueState.LastUpdatedAtUtc : QueueState.ReferenceUtc);
	Summary.QueueId = QueueState.QueueId;
	Summary.FocusDeckId = QueueState.FocusDeckId;
	Summary.FocusMethodSegmentId = QueueState.FocusMethodSegmentId;
	Summary.ActiveEntryId = QueueState.ActiveEntryId;

	for (const FHyperTwistTrainingCoachSessionQueueStateEntry& Entry : QueueState.Entries)
	{
		if (!Entry.IsStructurallyValid())
		{
			continue;
		}

		const bool bIsImmediateEntry =
			Entry.EntryState == EHyperTwistTrainingCoachSessionQueueEntryState::Ready
			|| Entry.EntryState == EHyperTwistTrainingCoachSessionQueueEntryState::InProgress;
		const bool bIsDeferredEntry =
			Entry.EntryState == EHyperTwistTrainingCoachSessionQueueEntryState::Deferred
			|| Entry.EntryState == EHyperTwistTrainingCoachSessionQueueEntryState::Pending;

		Summary.ImmediateEntryCount += bIsImmediateEntry ? 1 : 0;
		Summary.DeferredEntryCount += bIsDeferredEntry ? 1 : 0;
		Summary.ArchiveAwareEntryCount += Entry.bRequiresArchiveRetentionTuning ? 1 : 0;
		Summary.FollowUpEntryCount += Entry.bRequiresFollowUp ? 1 : 0;
		Summary.PinnedEntryCount += Entry.bPinned ? 1 : 0;

		if (Entry.EntryState == EHyperTwistTrainingCoachSessionQueueEntryState::InProgress)
		{
			Summary.bHasInProgressEntry = true;
		}

		if (bIsImmediateEntry && Summary.NextReadyEntryId.IsEmpty())
		{
			Summary.NextReadyEntryId = Entry.EntryId;
		}
		if (bIsDeferredEntry && Summary.NextDeferredEntryId.IsEmpty())
		{
			Summary.NextDeferredEntryId = Entry.EntryId;
		}
		if (Entry.bRequiresArchiveRetentionTuning && Summary.NextArchiveEntryId.IsEmpty())
		{
			Summary.NextArchiveEntryId = Entry.EntryId;
		}
		if (Entry.bRequiresFollowUp && Summary.NextFollowUpEntryId.IsEmpty())
		{
			Summary.NextFollowUpEntryId = Entry.EntryId;
		}
	}

	Summary.bHasImmediateWindow = Summary.ImmediateEntryCount > 0;
	Summary.bHasDeferredWindow = Summary.DeferredEntryCount > 0;
	Summary.bNeedsArchiveWindow = QueueState.bNeedsArchiveAwareSequencing
		&& (Summary.ArchiveAwareEntryCount > 0 || ArchivePolicySummary.bNeedsArchiveRetentionTuning);
	Summary.bHasBlockedFollowUp = Summary.FollowUpEntryCount > 0
		&& Summary.NextFollowUpEntryId != Summary.NextReadyEntryId
		&& (Summary.bHasImmediateWindow || Summary.bNeedsArchiveWindow);

	if (Summary.bHasInProgressEntry || Summary.bHasImmediateWindow)
	{
		Summary.CurrentHorizonLabel = TEXT("immediate");
	}
	else if (Summary.bNeedsArchiveWindow)
	{
		Summary.CurrentHorizonLabel = TEXT("archive-aware");
	}
	else if (!Summary.NextFollowUpEntryId.IsEmpty())
	{
		Summary.CurrentHorizonLabel = TEXT("follow-up");
	}
	else if (!Summary.NextDeferredEntryId.IsEmpty())
	{
		Summary.CurrentHorizonLabel = TEXT("deferred");
	}
	else
	{
		Summary.CurrentHorizonLabel = TEXT("idle");
	}

	return Summary;
}

FHyperTwistCoachSchedulePolicySummary UHyperTwistTrainingCoachLibrary::DeriveCoachSchedulePolicySummary(
	const FHyperTwistTrainingCoachSessionQueueState& QueueState,
	const FHyperTwistCoachScheduleHorizonSummary& HorizonSummary,
	const FHyperTwistTrainingCoachActionClosureSummary& ClosureSummary,
	const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
	const FHyperTwistTrainingCoachArchivePolicySummary& ArchivePolicySummary,
	const FString& ReferenceUtc
)
{
	FHyperTwistCoachSchedulePolicySummary Summary;
	if (!QueueState.IsStructurallyValid())
	{
		return Summary;
	}

	Summary.UserId = QueueState.UserId;
	Summary.ReferenceUtc = !ReferenceUtc.IsEmpty()
		? ReferenceUtc
		: (!QueueState.LastUpdatedAtUtc.IsEmpty() ? QueueState.LastUpdatedAtUtc : QueueState.ReferenceUtc);
	Summary.QueueId = QueueState.QueueId;
	Summary.FocusDeckId = QueueState.FocusDeckId;
	Summary.FocusMethodSegmentId = QueueState.FocusMethodSegmentId;
	Summary.NextImmediateEntryId = HorizonSummary.NextReadyEntryId;

	TMap<FString, int32> DeferralReasonCounts;
	for (const FHyperTwistTrainingCoachSessionQueueStateEntry& Entry : QueueState.Entries)
	{
		if (!Entry.IsStructurallyValid())
		{
			continue;
		}

		switch (Entry.EntryState)
		{
		case EHyperTwistTrainingCoachSessionQueueEntryState::Ready:
		case EHyperTwistTrainingCoachSessionQueueEntryState::InProgress:
			Summary.ImmediateEntryCount += 1;
			break;
		case EHyperTwistTrainingCoachSessionQueueEntryState::Pending:
			Summary.PendingEntryCount += 1;
			if (Summary.NextPendingEntryId.IsEmpty())
			{
				Summary.NextPendingEntryId = Entry.EntryId;
			}
			break;
		case EHyperTwistTrainingCoachSessionQueueEntryState::Deferred:
			Summary.DeferredEntryCount += 1;
			if (Summary.NextDeferredEntryId.IsEmpty())
			{
				Summary.NextDeferredEntryId = Entry.EntryId;
			}
			if (Entry.bRequiresArchiveRetentionTuning)
			{
				Summary.ArchiveAwareDeferredEntryCount += 1;
			}
			if (Entry.bRequiresFollowUp)
			{
				Summary.BlockedFollowUpDeferredEntryCount += 1;
			}
			if (Summary.EarliestDeferredUntilUtc.IsEmpty()
				|| (!Entry.DeferredUntilUtc.IsEmpty() && Entry.DeferredUntilUtc < Summary.EarliestDeferredUntilUtc))
			{
				Summary.EarliestDeferredUntilUtc = Entry.DeferredUntilUtc;
			}
			if (!Entry.DeferralReasonLabel.IsEmpty())
			{
				DeferralReasonCounts.FindOrAdd(Entry.DeferralReasonLabel) += 1;
			}
			if (!Entry.DeferredUntilUtc.IsEmpty() && Entry.DeferredUntilUtc <= Summary.ReferenceUtc)
			{
				Summary.bHasExpiredDeferrals = true;
			}
			break;
		default:
			break;
		}

		if (Entry.bWasManuallyRescheduled)
		{
			Summary.ManualRescheduleEntryCount += 1;
			if (Summary.NextManualRescheduleEntryId.IsEmpty()
				&& (Entry.EntryState == EHyperTwistTrainingCoachSessionQueueEntryState::Deferred
					|| Entry.EntryState == EHyperTwistTrainingCoachSessionQueueEntryState::Pending))
			{
				Summary.NextManualRescheduleEntryId = Entry.EntryId;
			}
		}
	}

	int32 DominantReasonCount = 0;
	for (const TPair<FString, int32>& Pair : DeferralReasonCounts)
	{
		if (Pair.Value > DominantReasonCount
			|| (Pair.Value == DominantReasonCount
				&& (Summary.DominantDeferralReasonLabel.IsEmpty()
					|| Pair.Key < Summary.DominantDeferralReasonLabel)))
		{
			DominantReasonCount = Pair.Value;
			Summary.DominantDeferralReasonLabel = Pair.Key;
		}
	}

	Summary.bAllowsManualReschedule = QueueState.IsStructurallyValid()
		&& !HorizonSummary.bHasInProgressEntry;
	Summary.bHasArchiveAwareDeferrals = Summary.ArchiveAwareDeferredEntryCount > 0
		|| (ArchivePolicySummary.bNeedsArchiveRetentionTuning && Summary.DeferredEntryCount > 0);
	Summary.bHasBlockedFollowUpDeferrals = Summary.BlockedFollowUpDeferredEntryCount > 0;
	Summary.HistoricalFollowUpContinuationCount =
		CoachMemorySnapshot.RecoverySustainedFollowUpHistoryCount;
	Summary.HistoricalBorderlineFollowUpSuppressionCount =
		CoachMemorySnapshot.RecoverySuppressedBorderlineFollowUpHistoryCount;
	Summary.bFollowUpContinuationFromRecoveryHistory =
		ClosureSummary.bSpawnFollowUpFromSuppressionMemory;
	Summary.bBorderlineFollowUpSuppressedByRecoveryHistory =
		ClosureSummary.bSuppressedBorderlineFollowUpByRecoveryHistory;
	Summary.bNeedsManualRescheduleReview = Summary.bHasExpiredDeferrals
		|| Summary.ManualRescheduleEntryCount >= 2
		|| Summary.bHasBlockedFollowUpDeferrals;
	if (ClosureSummary.IsStructurallyValid())
	{
		if (Summary.bFollowUpContinuationFromRecoveryHistory)
		{
			Summary.ClosurePolicyLine =
				TEXT("Closure policy: recovery history keeps follow-up alive on carry-forward pressure.");
		}
		else if (Summary.bBorderlineFollowUpSuppressedByRecoveryHistory)
		{
			Summary.ClosurePolicyLine =
				TEXT("Closure policy: recommended recovery history suppresses a borderline follow-up.");
		}
		else if (ClosureSummary.bShouldSpawnFollowUp)
		{
			Summary.ClosurePolicyLine =
				TEXT("Closure policy: unresolved or weak cases still require follow-up.");
		}
		else if (ClosureSummary.bNeedsEscalation)
		{
			Summary.ClosurePolicyLine =
				TEXT("Closure policy: escalation takes precedence over additional follow-up.");
		}
		else if (ClosureSummary.bSequenceClosed)
		{
			Summary.ClosurePolicyLine =
				TEXT("Closure policy: sequence is closed and resolved work can archive forward.");
		}
		else
		{
			Summary.ClosurePolicyLine =
				TEXT("Closure policy: sequence remains stable without spawning new follow-up.");
		}
		if (Summary.HistoricalFollowUpContinuationCount > 0
			|| Summary.HistoricalBorderlineFollowUpSuppressionCount > 0)
		{
			Summary.ClosurePolicyLine = FString::Printf(
				TEXT("%s | history keep %d / suppress %d"),
				*Summary.ClosurePolicyLine,
				Summary.HistoricalFollowUpContinuationCount,
				Summary.HistoricalBorderlineFollowUpSuppressionCount
			);
		}
	}
	Summary.ReschedulePressureScore = FMath::Clamp(
		static_cast<float>(Summary.DeferredEntryCount) * 8.0f
			+ static_cast<float>(Summary.ManualRescheduleEntryCount) * 10.0f
			+ static_cast<float>(Summary.ArchiveAwareDeferredEntryCount) * 12.0f
			+ static_cast<float>(Summary.BlockedFollowUpDeferredEntryCount) * 12.0f
			+ (Summary.bHasExpiredDeferrals ? 15.0f : 0.0f),
		0.0f,
		100.0f
	);

	return Summary;
}

EHyperTwistTrainingCoachHandoffKind UHyperTwistTrainingCoachLibrary::ResolvePrimaryCoachActionKind(
	const FHyperTwistTrainingCoachPanelState& PanelState
)
{
	if (PanelState.bCanStartQueuedRun)
	{
		return EHyperTwistTrainingCoachHandoffKind::Queue;
	}
	if (PanelState.bCanStartCoachFollowUpRun && PanelState.bHasFollowUpGuidance)
	{
		return EHyperTwistTrainingCoachHandoffKind::FollowUp;
	}
	if (PanelState.bCanStartCoachRecommendedRun)
	{
		return EHyperTwistTrainingCoachHandoffKind::Recommended;
	}

	return EHyperTwistTrainingCoachHandoffKind::None;
}

FHyperTwistTrainingCoachPrimaryActionSurface UHyperTwistTrainingCoachLibrary::DerivePrimaryCoachActionSurface(
	const FHyperTwistTrainingCoachPanelState& PanelState
)
{
	FHyperTwistTrainingCoachPrimaryActionSurface Surface;
	Surface.Headline = PanelState.Headline;
	Surface.FocusDeckId = PanelState.FocusDeckId;
	Surface.FocusMethodSegmentId = PanelState.FocusMethodSegmentId;
	Surface.ActionKind = ResolvePrimaryCoachActionKind(PanelState);
	Surface.PreferredGuidanceLane = PanelState.PreferredGuidanceLane;
	Surface.SuggestedMode = PanelState.SuggestedMode;
	Surface.SuggestedSelectionPolicy = PanelState.SuggestedSelectionPolicy;
	Surface.SuggestedLaunchCaseBudget = PanelState.SuggestedLaunchCaseBudget;
	Surface.bCanExecute = Surface.ActionKind != EHyperTwistTrainingCoachHandoffKind::None;
	Surface.ActionLabel = HyperTwistTrainingCoachLibraryInternal::DescribePrimaryCoachActionLabel(
		PanelState,
		Surface.ActionKind
	);
	Surface.AvailabilityLine =
		HyperTwistTrainingCoachLibraryInternal::DescribePrimaryCoachAvailabilityLine(
			PanelState,
			Surface.ActionKind
		);
	Surface.DetailLine = HyperTwistTrainingCoachLibraryInternal::DescribePrimaryCoachDetailLine(
		PanelState,
		Surface.ActionKind
	);
	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionProvenancePreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionOwnedExecutionProvenancePreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
		OptionLaunchRequestPreviewSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionProvenancePreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Provenance Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Provenance Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Provenance Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution provenance preview requires a selector id from the active selector roster.");
		Surface.CaseSourceSummaryLine = TEXT("Case source attribution: n/a");
		Surface.DeckSourceSummaryLine = TEXT("Deck source attribution: n/a");
		Surface.TagSummaryLine = TEXT("Tag posture: n/a");
		Surface.CurrentSelectionProvenanceLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const FHyperTwistTrainingImportedGeneratedModeLaunchRequest& LaunchRequest =
		RunState.ImportedGeneratedModeLaunchRequest;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingCase* SeedCase = RunState.ActiveDeck.Cases.FindByPredicate(
		[](const FHyperTwistTrainingCase& Candidate)
		{
			return Candidate.IsStructurallyValid();
		}
	);

	const auto SanitizeGeneratedModeToken = [](const FString& Value) -> FString
	{
		FString Sanitized;
		Sanitized.Reserve(Value.Len());

		for (const TCHAR Character : Value)
		{
			if (FChar::IsAlnum(Character))
			{
				Sanitized.AppendChar(FChar::ToLower(Character));
			}
			else if (Sanitized.IsEmpty() || Sanitized[Sanitized.Len() - 1] != TEXT('-'))
			{
				Sanitized.AppendChar(TEXT('-'));
			}
		}

		while (Sanitized.StartsWith(TEXT("-")))
		{
			Sanitized.RightChopInline(1, EAllowShrinking::No);
		}
		while (Sanitized.EndsWith(TEXT("-")))
		{
			Sanitized.LeftChopInline(1, EAllowShrinking::No);
		}

		return Sanitized.IsEmpty() ? TEXT("value") : Sanitized;
	};

	const auto DescribeSourceMode = [](const EHyperTwistTrainingSourceMode SourceMode) -> FString
	{
		switch (SourceMode)
		{
			case EHyperTwistTrainingSourceMode::FirstParty:
				return TEXT("First Party");
			case EHyperTwistTrainingSourceMode::DirectDonor:
				return TEXT("Direct Donor");
			case EHyperTwistTrainingSourceMode::CleanRoom:
				return TEXT("Clean Room");
			case EHyperTwistTrainingSourceMode::Benchmark:
				return TEXT("Benchmark");
			default:
				return TEXT("Unknown");
		}
	};

	const auto BuildSourceModeLine = [&DescribeSourceMode](
		const TCHAR* Prefix,
		const FHyperTwistTrainingSourceAttribution& Attribution
	) -> FString
	{
		return FString::Printf(
			TEXT("%s: %s"),
			Prefix,
			*DescribeSourceMode(Attribution.SourceMode)
		);
	};

	const auto BuildSourceRefLine = [](
		const TCHAR* Prefix,
		const FHyperTwistTrainingSourceAttribution& Attribution
	) -> FString
	{
		TArray<FString> Parts;
		if (!Attribution.SourceRepo.IsEmpty())
		{
			Parts.Add(FString::Printf(TEXT("repo=%s"), *Attribution.SourceRepo));
		}
		if (!Attribution.SourceLicense.IsEmpty())
		{
			Parts.Add(FString::Printf(TEXT("license=%s"), *Attribution.SourceLicense));
		}
		if (!Attribution.SourceTrackId.IsEmpty())
		{
			Parts.Add(FString::Printf(TEXT("track=%s"), *Attribution.SourceTrackId));
		}
		if (!Attribution.SourceDeckId.IsEmpty())
		{
			Parts.Add(FString::Printf(TEXT("deck=%s"), *Attribution.SourceDeckId));
		}
		if (!Attribution.SourceCaseId.IsEmpty())
		{
			Parts.Add(FString::Printf(TEXT("case=%s"), *Attribution.SourceCaseId));
		}

		if (Parts.Num() == 0)
		{
			return FString::Printf(TEXT("%s: first-party lineage"), Prefix);
		}

		return FString::Printf(
			TEXT("%s: %s"),
			Prefix,
			*FString::Join(Parts, TEXT(" | "))
		);
	};

	const auto BuildSourceNotesLine = [](
		const TCHAR* Prefix,
		const FHyperTwistTrainingSourceAttribution& Attribution
	) -> FString
	{
		return FString::Printf(
			TEXT("%s: %s"),
			Prefix,
			Attribution.SourceNotes.IsEmpty() ? TEXT("none") : *Attribution.SourceNotes
		);
	};

	const auto BuildTagSummaryLine = [](
		const TCHAR* Prefix,
		const TArray<FString>& Tags
	) -> FString
	{
		if (Tags.Num() == 0)
		{
			return FString::Printf(TEXT("%s: none"), Prefix);
		}

		TArray<FString> PreviewTags;
		const int32 PreviewLimit = FMath::Min(3, Tags.Num());
		for (int32 Index = 0; Index < PreviewLimit; ++Index)
		{
			PreviewTags.Add(Tags[Index]);
		}

		FString PreviewText = FString::Join(PreviewTags, TEXT(" | "));
		if (Tags.Num() > PreviewLimit)
		{
			PreviewText += FString::Printf(
				TEXT(" | +%d more"),
				Tags.Num() - PreviewLimit
			);
		}

		return FString::Printf(
			TEXT("%s: %d [%s]"),
			Prefix,
			Tags.Num(),
			*PreviewText
		);
	};

	const auto AppendUniqueTag = [](
		TArray<FString>& Tags,
		const FString& Tag
	)
	{
		if (!Tag.IsEmpty())
		{
			Tags.AddUnique(Tag);
		}
	};

	const auto IncrementSourceModeCounts = [&Surface](
		const FHyperTwistTrainingSourceAttribution& Attribution,
		const bool bCaseSource
	)
	{
		switch (Attribution.SourceMode)
		{
			case EHyperTwistTrainingSourceMode::FirstParty:
				if (bCaseSource)
				{
					++Surface.FirstPartyCaseSourceOptionCount;
				}
				else
				{
					++Surface.FirstPartyDeckSourceOptionCount;
				}
				break;
			case EHyperTwistTrainingSourceMode::DirectDonor:
				if (bCaseSource)
				{
					++Surface.DirectDonorCaseSourceOptionCount;
				}
				else
				{
					++Surface.DirectDonorDeckSourceOptionCount;
				}
				break;
			case EHyperTwistTrainingSourceMode::CleanRoom:
				if (bCaseSource)
				{
					++Surface.CleanRoomCaseSourceOptionCount;
				}
				else
				{
					++Surface.CleanRoomDeckSourceOptionCount;
				}
				break;
			case EHyperTwistTrainingSourceMode::Benchmark:
				if (bCaseSource)
				{
					++Surface.BenchmarkCaseSourceOptionCount;
				}
				else
				{
					++Surface.BenchmarkDeckSourceOptionCount;
				}
				break;
			default:
				break;
		}
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution provenance preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.CaseSourceSummaryLine = TEXT("Case source attribution: n/a");
		Surface.DeckSourceSummaryLine = TEXT("Deck source attribution: n/a");
		Surface.TagSummaryLine = TEXT("Tag posture: n/a");
		Surface.CurrentSelectionProvenanceLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution provenance preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionProvenancePreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
			{
				FHyperTwistTrainingCase MatchingCase;
				if (UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
						RunState.ActiveDeck,
						SelectorId,
						PreviewEntry.OptionId,
						MatchingCase))
				{
					Entry.PreviewCaseSourceAttribution = MatchingCase.SourceAttribution;
					Entry.PreviewDeckSourceAttribution = RunState.ActiveDeck.SourceAttribution;
					Entry.PreviewCaseSourceModeLabel = DescribeSourceMode(
						Entry.PreviewCaseSourceAttribution.SourceMode
					);
					Entry.PreviewDeckSourceModeLabel = DescribeSourceMode(
						Entry.PreviewDeckSourceAttribution.SourceMode
					);
					Entry.PreviewCaseTags = MatchingCase.Tags;
					Entry.PreviewDeckTags = RunState.ActiveDeck.Tags;
					AppendUniqueTag(
						Entry.PreviewDeckTags,
						TEXT("runtime-surface:selector-option-applied")
					);
					AppendUniqueTag(
						Entry.PreviewDeckTags,
						FString::Printf(TEXT("selector:%s"), *SelectorId.ToLower())
					);
					AppendUniqueTag(
						Entry.PreviewDeckTags,
						FString::Printf(TEXT("selector-option:%s"), *PreviewEntry.OptionId.ToLower())
					);

					Entry.bHasCaseSourceAttribution =
						Entry.PreviewCaseSourceAttribution.IsStructurallyValid();
					Entry.bHasDeckSourceAttribution =
						Entry.PreviewDeckSourceAttribution.IsStructurallyValid();
					Entry.CaseTagCount = Entry.PreviewCaseTags.Num();
					Entry.DeckTagCount = Entry.PreviewDeckTags.Num();
					Entry.bHasCaseTags = Entry.CaseTagCount > 0;
					Entry.bHasDeckTags = Entry.DeckTagCount > 0;
					Entry.CaseSourceModeLine = BuildSourceModeLine(
						TEXT("Case source mode"),
						Entry.PreviewCaseSourceAttribution
					);
					Entry.CaseSourceRefLine = BuildSourceRefLine(
						TEXT("Case source ref"),
						Entry.PreviewCaseSourceAttribution
					);
					Entry.CaseSourceNotesLine = BuildSourceNotesLine(
						TEXT("Case source notes"),
						Entry.PreviewCaseSourceAttribution
					);
					Entry.DeckSourceModeLine = BuildSourceModeLine(
						TEXT("Deck source mode"),
						Entry.PreviewDeckSourceAttribution
					);
					Entry.DeckSourceRefLine = BuildSourceRefLine(
						TEXT("Deck source ref"),
						Entry.PreviewDeckSourceAttribution
					);
					Entry.DeckSourceNotesLine = BuildSourceNotesLine(
						TEXT("Deck source notes"),
						Entry.PreviewDeckSourceAttribution
					);
					Entry.CaseTagSummaryLine = BuildTagSummaryLine(
						TEXT("Case tags on execute"),
						Entry.PreviewCaseTags
					);
					Entry.DeckTagSummaryLine = BuildTagSummaryLine(
						TEXT("Deck tags on execute"),
						Entry.PreviewDeckTags
					);
					Entry.ProvenanceSourceLine =
						TEXT("Provenance source: exact direct covered-case attribution from the resolved imported option case plus active deck lineage.");
					Entry.PreviewStabilityLine =
						TEXT("Preview stability: exact direct owned-case provenance preview from covered-case launch.");
					Entry.bHasExactProvenancePreview = true;
					Entry.bCanPreview = true;
					++Surface.DirectExactOptionCount;
					IncrementSourceModeCounts(Entry.PreviewCaseSourceAttribution, true);
					IncrementSourceModeCounts(Entry.PreviewDeckSourceAttribution, false);
				}
				else
				{
					Entry.CaseSourceModeLine = TEXT("Case source mode: unavailable");
					Entry.CaseSourceRefLine = TEXT("Case source ref: unavailable");
					Entry.CaseSourceNotesLine = TEXT("Case source notes: unavailable");
					Entry.DeckSourceModeLine = TEXT("Deck source mode: unavailable");
					Entry.DeckSourceRefLine = TEXT("Deck source ref: unavailable");
					Entry.DeckSourceNotesLine = TEXT("Deck source notes: unavailable");
					Entry.CaseTagSummaryLine = TEXT("Case tags on execute: unavailable");
					Entry.DeckTagSummaryLine = TEXT("Deck tags on execute: unavailable");
					Entry.ProvenanceSourceLine =
						TEXT("Provenance source: unavailable because the covered case could not be re-resolved from the active deck.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
				}
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
			{
				if (SeedCase == nullptr)
				{
					Entry.CaseSourceModeLine = TEXT("Case source mode: unavailable");
					Entry.CaseSourceRefLine = TEXT("Case source ref: unavailable");
					Entry.CaseSourceNotesLine = TEXT("Case source notes: unavailable");
					Entry.DeckSourceModeLine = TEXT("Deck source mode: unavailable");
					Entry.DeckSourceRefLine = TEXT("Deck source ref: unavailable");
					Entry.DeckSourceNotesLine = TEXT("Deck source notes: unavailable");
					Entry.CaseTagSummaryLine = TEXT("Case tags on execute: unavailable");
					Entry.DeckTagSummaryLine = TEXT("Deck tags on execute: unavailable");
					Entry.ProvenanceSourceLine =
						TEXT("Provenance source: unavailable because the active generated-mode surface has no structurally valid seed case.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
					break;
				}

				const bool bStoredRequestReusable =
					PreviewEntry.LaunchRequestPreviewKind
					== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
						StoredRequestReusable;
				const bool bHasExactRequestId =
					bStoredRequestReusable && LaunchRequest.IsStructurallyValid()
					&& !LaunchRequest.RequestId.IsEmpty();
				const FString PreviewRequestId = bHasExactRequestId
					? LaunchRequest.RequestId
					: FString(TEXT("<next-request-id>"));
				const FString PreviewRequestTagToken = bHasExactRequestId
					? SanitizeGeneratedModeToken(PreviewRequestId)
					: FString(TEXT("<next-request-id>"));
				const FString PreviewSurfaceToken = PreviewEntry.HypotheticalSurfaceId.IsEmpty()
					? SanitizeGeneratedModeToken(RuntimeSurface.SurfaceId)
					: SanitizeGeneratedModeToken(PreviewEntry.HypotheticalSurfaceId);
				const FString CaseExecutionNote = FString::Printf(
					TEXT("Owned generated-mode execution case produced from request %s."),
					*PreviewRequestId
				);
				const FString DeckExecutionNote = FString::Printf(
					TEXT("Owned generated-mode execution deck produced from request %s."),
					*PreviewRequestId
				);

				Entry.PreviewCaseSourceAttribution =
					SeedCase->SourceAttribution.IsStructurallyValid()
						? SeedCase->SourceAttribution
						: RunState.ActiveDeck.SourceAttribution;
				if (Entry.PreviewCaseSourceAttribution.SourceCaseId.IsEmpty())
				{
					Entry.PreviewCaseSourceAttribution.SourceCaseId = SeedCase->CaseId;
				}
				Entry.PreviewCaseSourceAttribution.SourceNotes =
					Entry.PreviewCaseSourceAttribution.SourceNotes.IsEmpty()
						? CaseExecutionNote
						: FString::Printf(
							TEXT("%s | %s"),
							*Entry.PreviewCaseSourceAttribution.SourceNotes,
							*CaseExecutionNote
						);
				Entry.PreviewDeckSourceAttribution = RunState.ActiveDeck.SourceAttribution;
				Entry.PreviewDeckSourceAttribution.SourceNotes =
					Entry.PreviewDeckSourceAttribution.SourceNotes.IsEmpty()
						? DeckExecutionNote
						: FString::Printf(
							TEXT("%s | %s"),
							*Entry.PreviewDeckSourceAttribution.SourceNotes,
							*DeckExecutionNote
						);
				Entry.PreviewCaseSourceModeLabel = DescribeSourceMode(
					Entry.PreviewCaseSourceAttribution.SourceMode
				);
				Entry.PreviewDeckSourceModeLabel = DescribeSourceMode(
					Entry.PreviewDeckSourceAttribution.SourceMode
				);
				Entry.PreviewCaseTags = SeedCase->Tags;
				AppendUniqueTag(
					Entry.PreviewCaseTags,
					TEXT("runtime-surface:generated-mode")
				);
				AppendUniqueTag(
					Entry.PreviewCaseTags,
					TEXT("generated-mode:owned-execution")
				);
				AppendUniqueTag(
					Entry.PreviewCaseTags,
					FString::Printf(
						TEXT("generated-request:%s"),
						*PreviewRequestTagToken
					)
				);
				AppendUniqueTag(
					Entry.PreviewCaseTags,
					FString::Printf(
						TEXT("generated-surface:%s"),
						*PreviewSurfaceToken
					)
				);
				for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestSelectorChoiceEntrySurface&
					ChoiceEntry : PreviewEntry.SelectorChoiceEntries)
				{
					if (!ChoiceEntry.bHasChoice || ChoiceEntry.SelectorId.IsEmpty()
						|| ChoiceEntry.SelectedValue.IsEmpty())
					{
						continue;
					}

					AppendUniqueTag(
						Entry.PreviewCaseTags,
						FString::Printf(
							TEXT("generated-selector:%s=%s"),
							*SanitizeGeneratedModeToken(ChoiceEntry.SelectorId),
							*SanitizeGeneratedModeToken(ChoiceEntry.SelectedValue)
						)
					);
				}

				Entry.PreviewDeckTags = RunState.ActiveDeck.Tags;
				AppendUniqueTag(
					Entry.PreviewDeckTags,
					TEXT("runtime-surface:generated-mode")
				);
				AppendUniqueTag(
					Entry.PreviewDeckTags,
					TEXT("generated-mode:owned-execution")
				);
				AppendUniqueTag(
					Entry.PreviewDeckTags,
					FString::Printf(
						TEXT("generated-request:%s"),
						*PreviewRequestTagToken
					)
				);

				Entry.bHasCaseSourceAttribution =
					Entry.PreviewCaseSourceAttribution.IsStructurallyValid();
				Entry.bHasDeckSourceAttribution =
					Entry.PreviewDeckSourceAttribution.IsStructurallyValid();
				Entry.CaseTagCount = Entry.PreviewCaseTags.Num();
				Entry.DeckTagCount = Entry.PreviewDeckTags.Num();
				Entry.bHasCaseTags = Entry.CaseTagCount > 0;
				Entry.bHasDeckTags = Entry.DeckTagCount > 0;
				Entry.CaseSourceModeLine = BuildSourceModeLine(
					TEXT("Case source mode"),
					Entry.PreviewCaseSourceAttribution
				);
				Entry.CaseSourceRefLine = BuildSourceRefLine(
					TEXT("Case source ref"),
					Entry.PreviewCaseSourceAttribution
				);
				Entry.CaseSourceNotesLine = BuildSourceNotesLine(
					TEXT("Case source notes"),
					Entry.PreviewCaseSourceAttribution
				);
				Entry.DeckSourceModeLine = BuildSourceModeLine(
					TEXT("Deck source mode"),
					Entry.PreviewDeckSourceAttribution
				);
				Entry.DeckSourceRefLine = BuildSourceRefLine(
					TEXT("Deck source ref"),
					Entry.PreviewDeckSourceAttribution
				);
				Entry.DeckSourceNotesLine = BuildSourceNotesLine(
					TEXT("Deck source notes"),
					Entry.PreviewDeckSourceAttribution
				);
				Entry.CaseTagSummaryLine = BuildTagSummaryLine(
					TEXT("Case tags on execute"),
					Entry.PreviewCaseTags
				);
				Entry.DeckTagSummaryLine = BuildTagSummaryLine(
					TEXT("Deck tags on execute"),
					Entry.PreviewDeckTags
				);
				Entry.ProvenanceSourceLine =
					bHasExactRequestId
						? TEXT("Provenance source: generated owned-execution attribution and tags synthesized exactly from the seed case, active deck lineage, and reusable stored request.")
						: TEXT("Provenance source: generated owned-execution attribution is exact, but request-id-dependent notes and tags remain preview templates until execute refreshes the launch request.");
				Entry.PreviewStabilityLine =
					bHasExactRequestId
						? TEXT("Preview stability: exact while execute reuses the current stored request.")
						: TEXT("Preview stability: case/deck attribution is exact, but request-id-specific notes and tags remain template preview until launch-request refresh.");
				Entry.bHasExactProvenancePreview = bHasExactRequestId;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				IncrementSourceModeCounts(Entry.PreviewCaseSourceAttribution, true);
				IncrementSourceModeCounts(Entry.PreviewDeckSourceAttribution, false);
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.CaseSourceModeLine =
					TEXT("Case source mode: blocked until every required selector is resolved.");
				Entry.CaseSourceRefLine =
					TEXT("Case source ref: blocked until every required selector is resolved.");
				Entry.CaseSourceNotesLine =
					TEXT("Case source notes: blocked until every required selector is resolved.");
				Entry.DeckSourceModeLine =
					TEXT("Deck source mode: blocked until every required selector is resolved.");
				Entry.DeckSourceRefLine =
					TEXT("Deck source ref: blocked until every required selector is resolved.");
				Entry.DeckSourceNotesLine =
					TEXT("Deck source notes: blocked until every required selector is resolved.");
				Entry.CaseTagSummaryLine =
					TEXT("Case tags on execute: blocked until every required selector is resolved.");
				Entry.DeckTagSummaryLine =
					TEXT("Deck tags on execute: blocked until every required selector is resolved.");
				Entry.ProvenanceSourceLine =
					TEXT("Provenance source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.CaseSourceModeLine =
					TEXT("Case source mode: blocked until a structurally valid launch payload can be derived.");
				Entry.CaseSourceRefLine =
					TEXT("Case source ref: blocked until a structurally valid launch payload can be derived.");
				Entry.CaseSourceNotesLine =
					TEXT("Case source notes: blocked until a structurally valid launch payload can be derived.");
				Entry.DeckSourceModeLine =
					TEXT("Deck source mode: blocked until a structurally valid launch payload can be derived.");
				Entry.DeckSourceRefLine =
					TEXT("Deck source ref: blocked until a structurally valid launch payload can be derived.");
				Entry.DeckSourceNotesLine =
					TEXT("Deck source notes: blocked until a structurally valid launch payload can be derived.");
				Entry.CaseTagSummaryLine =
					TEXT("Case tags on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.DeckTagSummaryLine =
					TEXT("Deck tags on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.ProvenanceSourceLine =
					TEXT("Provenance source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.CaseSourceModeLine = TEXT("Case source mode: unavailable");
				Entry.CaseSourceRefLine = TEXT("Case source ref: unavailable");
				Entry.CaseSourceNotesLine = TEXT("Case source notes: unavailable");
				Entry.DeckSourceModeLine = TEXT("Deck source mode: unavailable");
				Entry.DeckSourceRefLine = TEXT("Deck source ref: unavailable");
				Entry.DeckSourceNotesLine = TEXT("Deck source notes: unavailable");
				Entry.CaseTagSummaryLine = TEXT("Case tags on execute: unavailable");
				Entry.DeckTagSummaryLine = TEXT("Deck tags on execute: unavailable");
				Entry.ProvenanceSourceLine = TEXT("Provenance source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		if (Entry.bHasCaseTags)
		{
			++Surface.CaseTaggedOptionCount;
		}
		if (Entry.bHasDeckTags)
		{
			++Surface.DeckTaggedOptionCount;
		}
		if (Entry.PreviewCaseTags.Contains(TEXT("generated-mode:owned-execution")))
		{
			++Surface.GeneratedExecutionCaseTagOptionCount;
		}
		if (Entry.PreviewDeckTags.Contains(TEXT("generated-mode:owned-execution")))
		{
			++Surface.GeneratedExecutionDeckTagOptionCount;
		}

		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*PreviewEntry.DetailLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactProvenancePreview =
				Entry.bHasExactProvenancePreview;
			Surface.bCurrentSelectionHasCaseSourceAttribution =
				Entry.bHasCaseSourceAttribution;
			Surface.bCurrentSelectionHasDeckSourceAttribution =
				Entry.bHasDeckSourceAttribution;
			Surface.bCurrentSelectionHasCaseTags = Entry.bHasCaseTags;
			Surface.bCurrentSelectionHasDeckTags = Entry.bHasDeckTags;
			Surface.CurrentSelectionProvenanceLine = FString::Printf(
				TEXT("Current selection: case %s | deck %s | case tags %d | deck tags %d | %s"),
				Entry.PreviewCaseSourceModeLabel.IsEmpty()
					? TEXT("n/a")
					: *Entry.PreviewCaseSourceModeLabel,
				Entry.PreviewDeckSourceModeLabel.IsEmpty()
					? TEXT("n/a")
					: *Entry.PreviewDeckSourceModeLabel,
				Entry.CaseTagCount,
				Entry.DeckTagCount,
				*Entry.PreviewStabilityLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionProvenancePreviewOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectProvenancePreviewOptions = Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedProvenancePreviewOptions = Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedProvenancePreviewOptions = Surface.BlockedOptionCount > 0;

	Surface.CaseSourceSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Case source attribution: %d first-party | %d direct donor | %d clean-room | %d benchmark"),
			Surface.FirstPartyCaseSourceOptionCount,
			Surface.DirectDonorCaseSourceOptionCount,
			Surface.CleanRoomCaseSourceOptionCount,
			Surface.BenchmarkCaseSourceOptionCount
		)
		: TEXT("Case source attribution: no imported options");
	Surface.DeckSourceSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Deck source attribution: %d first-party | %d direct donor | %d clean-room | %d benchmark"),
			Surface.FirstPartyDeckSourceOptionCount,
			Surface.DirectDonorDeckSourceOptionCount,
			Surface.CleanRoomDeckSourceOptionCount,
			Surface.BenchmarkDeckSourceOptionCount
		)
		: TEXT("Deck source attribution: no imported options");
	Surface.TagSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Tag posture: %d case-tagged | %d deck-tagged | %d generated-case-tagged | %d generated-deck-tagged"),
			Surface.CaseTaggedOptionCount,
			Surface.DeckTaggedOptionCount,
			Surface.GeneratedExecutionCaseTagOptionCount,
			Surface.GeneratedExecutionDeckTagOptionCount
		)
		: TEXT("Tag posture: no imported options");

	if (Surface.CurrentSelectionProvenanceLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionProvenanceLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionProvenanceLine =
				TEXT("Current selection has no additional owned-execution provenance preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionProvenanceLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionProvenanceLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution provenance preview exposes %d direct exact option%s, %d generated preview option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution provenance preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution provenance preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeckTitleSelectionPolicyPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionDeckTitleSelectionPolicyPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeckTitleSelectionPolicyPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Deck Title/Selection Policy Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Deck Title/Selection Policy Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Deck Title/Selection Policy Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution deck title/selection policy preview requires a selector id from the active selector roster.");
		Surface.DeckTitleSummaryLine = TEXT("Deck title: n/a");
		Surface.SelectionPolicySummaryLine = TEXT("Selection policy: n/a");
		Surface.CurrentSelectionDeckLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	const auto DescribeSelectionPolicy = [](
		const EHyperTwistTrainingSelectionPolicy SelectionPolicy
	) -> FString
	{
		switch (SelectionPolicy)
		{
			case EHyperTwistTrainingSelectionPolicy::Uniform:
				return TEXT("Uniform");
			case EHyperTwistTrainingSelectionPolicy::Weighted:
				return TEXT("Weighted");
			case EHyperTwistTrainingSelectionPolicy::Spaced:
				return TEXT("Spaced");
			case EHyperTwistTrainingSelectionPolicy::Scripted:
				return TEXT("Scripted");
			default:
				return TEXT("Unknown");
		}
	};

	const auto BuildDeckTitleLine = [](const FString& DeckTitle) -> FString
	{
		return DeckTitle.IsEmpty()
			? TEXT("Deck title on execute: empty")
			: FString::Printf(TEXT("Deck title on execute: %s"), *DeckTitle);
	};

	const auto BuildSelectionPolicyLine = [&DescribeSelectionPolicy](
		const EHyperTwistTrainingSelectionPolicy SelectionPolicy
	) -> FString
	{
		return FString::Printf(
			TEXT("Selection policy on execute: %s"),
			*DescribeSelectionPolicy(SelectionPolicy)
		);
	};

	const auto IncrementSelectionPolicyCounts = [&Surface](
		const EHyperTwistTrainingSelectionPolicy SelectionPolicy
	)
	{
		switch (SelectionPolicy)
		{
			case EHyperTwistTrainingSelectionPolicy::Uniform:
				++Surface.UniformSelectionPolicyOptionCount;
				break;
			case EHyperTwistTrainingSelectionPolicy::Weighted:
				++Surface.WeightedSelectionPolicyOptionCount;
				break;
			case EHyperTwistTrainingSelectionPolicy::Spaced:
				++Surface.SpacedSelectionPolicyOptionCount;
				break;
			case EHyperTwistTrainingSelectionPolicy::Scripted:
				++Surface.ScriptedSelectionPolicyOptionCount;
				break;
			default:
				break;
		}
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution deck title/selection policy preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.DeckTitleSummaryLine = TEXT("Deck title: n/a");
		Surface.SelectionPolicySummaryLine = TEXT("Selection policy: n/a");
		Surface.CurrentSelectionDeckLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution deck title/selection policy preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeckTitleSelectionPolicyPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				Entry.PreviewDeckTitle = RunState.ActiveDeck.Title;
				Entry.PreviewSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
				Entry.PreviewSelectionPolicyLabel =
					DescribeSelectionPolicy(Entry.PreviewSelectionPolicy);
				Entry.bHasExactDeckTitle = true;
				Entry.bHasExactSelectionPolicy = true;
				Entry.bUsesActiveDeckTitle = true;
				Entry.DeckTitleLine = BuildDeckTitleLine(Entry.PreviewDeckTitle);
				Entry.DeckTitleSourceLine = Entry.PreviewDeckTitle.IsEmpty()
					? TEXT("Deck title source: exact active deck title retained on direct covered-case start, but the active deck title is currently empty.")
					: TEXT("Deck title source: exact active deck title retained on direct covered-case start.");
				Entry.SelectionPolicyLine =
					BuildSelectionPolicyLine(Entry.PreviewSelectionPolicy);
				Entry.SelectionPolicySourceLine =
					TEXT("Selection policy source: direct covered-case start resets the owned execution deck to scripted selection.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: exact direct owned-execution deck container preview from covered-case launch.");
				Entry.bCanPreview = true;
				++Surface.DirectExactOptionCount;
				++Surface.RetainedActiveDeckTitleOptionCount;
				IncrementSelectionPolicyCounts(Entry.PreviewSelectionPolicy);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
			{
				Entry.PreviewSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
				Entry.PreviewSelectionPolicyLabel =
					DescribeSelectionPolicy(Entry.PreviewSelectionPolicy);
				Entry.bHasExactDeckTitle = true;
				Entry.bHasExactSelectionPolicy = true;

				if (!RunState.ActiveDeck.Title.IsEmpty())
				{
					Entry.PreviewDeckTitle = RunState.ActiveDeck.Title;
					Entry.bUsesActiveDeckTitle = true;
					Entry.DeckTitleSourceLine =
						TEXT("Deck title source: exact source-deck title retained on generated owned execution.");
					++Surface.RetainedActiveDeckTitleOptionCount;
				}
				else if (!PreviewEntry.HypotheticalSurfaceLabel.IsEmpty())
				{
					Entry.PreviewDeckTitle = PreviewEntry.HypotheticalSurfaceLabel;
					Entry.bUsesGeneratedSurfaceLabelFallback = true;
					Entry.DeckTitleSourceLine =
						TEXT("Deck title source: exact generated surface label fallback from the hypothetical execute launch config.");
					++Surface.SurfaceLabelFallbackOptionCount;
				}
				else if (!RuntimeSurface.SurfaceLabel.IsEmpty())
				{
					Entry.PreviewDeckTitle = RuntimeSurface.SurfaceLabel;
					Entry.bUsesGeneratedSurfaceLabelFallback = true;
					Entry.DeckTitleSourceLine =
						TEXT("Deck title source: exact active runtime-surface label fallback for generated owned execution.");
					++Surface.SurfaceLabelFallbackOptionCount;
				}
				else
				{
					Entry.PreviewDeckTitle = TEXT("Generated mode deck");
					Entry.bUsesGeneratedModeDefaultTitle = true;
					Entry.DeckTitleSourceLine =
						TEXT("Deck title source: exact generated-mode default title because no retained deck title or surface label is available.");
					++Surface.GeneratedModeDefaultTitleOptionCount;
				}

				Entry.DeckTitleLine = BuildDeckTitleLine(Entry.PreviewDeckTitle);
				Entry.SelectionPolicyLine =
					BuildSelectionPolicyLine(Entry.PreviewSelectionPolicy);
				Entry.SelectionPolicySourceLine =
					TEXT("Selection policy source: generated owned execution resets the owned execution deck to scripted selection.");
				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
					? TEXT("Preview stability: exact while execute reuses the current stored request.")
					: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				IncrementSelectionPolicyCounts(Entry.PreviewSelectionPolicy);
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.DeckTitleLine =
					TEXT("Deck title on execute: blocked until every required selector is resolved.");
				Entry.DeckTitleSourceLine =
					TEXT("Deck title source: blocked while selector coverage remains incomplete.");
				Entry.SelectionPolicyLine =
					TEXT("Selection policy on execute: blocked until every required selector is resolved.");
				Entry.SelectionPolicySourceLine =
					TEXT("Selection policy source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.DeckTitleLine =
					TEXT("Deck title on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.DeckTitleSourceLine =
					TEXT("Deck title source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.SelectionPolicyLine =
					TEXT("Selection policy on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SelectionPolicySourceLine =
					TEXT("Selection policy source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.DeckTitleLine = TEXT("Deck title on execute: unavailable");
				Entry.DeckTitleSourceLine = TEXT("Deck title source: unavailable");
				Entry.SelectionPolicyLine = TEXT("Selection policy on execute: unavailable");
				Entry.SelectionPolicySourceLine = TEXT("Selection policy source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*PreviewEntry.DetailLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactDeckTitle = Entry.bHasExactDeckTitle;
			Surface.bCurrentSelectionHasExactSelectionPolicy =
				Entry.bHasExactSelectionPolicy;
			Surface.bCurrentSelectionUsesActiveDeckTitle = Entry.bUsesActiveDeckTitle;
			Surface.bCurrentSelectionUsesGeneratedSurfaceLabelFallback =
				Entry.bUsesGeneratedSurfaceLabelFallback;
			Surface.bCurrentSelectionUsesGeneratedModeDefaultTitle =
				Entry.bUsesGeneratedModeDefaultTitle;
			Surface.CurrentSelectionDeckLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.DeckTitleLine,
				*Entry.SelectionPolicyLine,
				*Entry.PreviewStabilityLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionDeckTitleSelectionPolicyPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectDeckTitleSelectionPolicyPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedDeckTitleSelectionPolicyPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedDeckTitleSelectionPolicyPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.DeckTitleSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Deck title: %d retained active-deck | %d surface-label fallback | %d generated default | %d blocked | %d unavailable"),
			Surface.RetainedActiveDeckTitleOptionCount,
			Surface.SurfaceLabelFallbackOptionCount,
			Surface.GeneratedModeDefaultTitleOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Deck title: no imported options");
	Surface.SelectionPolicySummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Selection policy: %d scripted | %d weighted | %d uniform | %d spaced | %d blocked | %d unavailable"),
			Surface.ScriptedSelectionPolicyOptionCount,
			Surface.WeightedSelectionPolicyOptionCount,
			Surface.UniformSelectionPolicyOptionCount,
			Surface.SpacedSelectionPolicyOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Selection policy: no imported options");

	if (Surface.CurrentSelectionDeckLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionDeckLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionDeckLine =
				TEXT("Current selection has no additional owned-execution deck container preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionDeckLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionDeckLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution deck title/selection policy preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution deck title/selection policy preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution deck title/selection policy preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeckIdRuntimeSurfaceRetentionPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionDeckIdRuntimeSurfaceRetentionPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeckIdRuntimeSurfaceRetentionPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Deck Id/Runtime-Surface Retention Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Deck Id/Runtime-Surface Retention Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Deck Id/Runtime-Surface Retention Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution deck id/runtime-surface retention preview requires a selector id from the active selector roster.");
		Surface.DeckIdSummaryLine = TEXT("Deck id: n/a");
		Surface.RuntimeSurfaceSummaryLine = TEXT("Runtime surface: n/a");
		Surface.CurrentSelectionDeckRuntimeSurfaceLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	const auto BuildDeckIdLine = [](const FString& DeckId) -> FString
	{
		return DeckId.IsEmpty()
			? TEXT("Deck id on execute: empty")
			: FString::Printf(TEXT("Deck id on execute: %s"), *DeckId);
	};

	const auto BuildRuntimeSurfaceLine = [](
		const FString& SurfaceKind,
		const FString& SurfaceId,
		const FString& SurfaceLabel,
		const FString& RuntimeModeId,
		const FString& GeneratorType
	) -> FString
	{
		const FString KindSummary = SurfaceKind.IsEmpty() ? TEXT("n/a") : SurfaceKind;
		const FString IdSummary = SurfaceId.IsEmpty() ? TEXT("n/a") : SurfaceId;
		const FString LabelSummary = SurfaceLabel.IsEmpty()
			? FString()
			: FString::Printf(TEXT(" [%s]"), *SurfaceLabel);
		const FString RuntimeSummary = RuntimeModeId.IsEmpty()
			? TEXT("runtime=n/a")
			: FString::Printf(TEXT("runtime=%s"), *RuntimeModeId);
		const FString GeneratorSummary = GeneratorType.IsEmpty()
			? TEXT("generator=n/a")
			: FString::Printf(TEXT("generator=%s"), *GeneratorType);
		return FString::Printf(
			TEXT("Runtime surface on execute: %s / %s%s | %s | %s"),
			*KindSummary,
			*IdSummary,
			*LabelSummary,
			*RuntimeSummary,
			*GeneratorSummary
		);
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution deck id/runtime-surface retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.DeckIdSummaryLine = TEXT("Deck id: n/a");
		Surface.RuntimeSurfaceSummaryLine = TEXT("Runtime surface: n/a");
		Surface.CurrentSelectionDeckRuntimeSurfaceLine =
			OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution deck id/runtime-surface retention preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeckIdRuntimeSurfaceRetentionPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				Entry.PreviewDeckId = RunState.ActiveDeck.DeckId;
				Entry.PreviewSurfaceKind = RuntimeSurface.SurfaceKind;
				Entry.PreviewSurfaceId = RuntimeSurface.SurfaceId;
				Entry.PreviewSurfaceLabel = RuntimeSurface.SurfaceLabel;
				Entry.PreviewRuntimeModeId = RuntimeSurface.RuntimeModeId;
				Entry.PreviewGeneratorType = RuntimeSurface.GeneratorType;
				Entry.bHasExactDeckId = true;
				Entry.bHasExactRuntimeSurfaceIdentity = true;
				Entry.bHasRuntimeSurfaceLabel = !Entry.PreviewSurfaceLabel.IsEmpty();
				Entry.bHasRuntimeModeId = !Entry.PreviewRuntimeModeId.IsEmpty();
				Entry.bHasGeneratorType = !Entry.PreviewGeneratorType.IsEmpty();
				Entry.bRetainsActiveDeckId = true;
				Entry.bRetainsImportedRuntimeSurface = true;
				Entry.DeckIdLine = BuildDeckIdLine(Entry.PreviewDeckId);
				Entry.DeckIdSourceLine = Entry.PreviewDeckId.IsEmpty()
					? TEXT("Deck id source: exact active deck id would be retained on direct covered-case start, but the active deck id is currently empty.")
					: TEXT("Deck id source: exact active deck id retained on direct covered-case start.");
				Entry.RuntimeSurfaceLine = BuildRuntimeSurfaceLine(
					Entry.PreviewSurfaceKind,
					Entry.PreviewSurfaceId,
					Entry.PreviewSurfaceLabel,
					Entry.PreviewRuntimeModeId,
					Entry.PreviewGeneratorType
				);
				Entry.RuntimeSurfaceSourceLine =
					TEXT("Runtime surface source: exact active imported runtime surface retained on direct covered-case start.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: exact direct owned-execution container retention preview from covered-case launch.");
				Entry.bCanPreview = true;
				++Surface.DirectExactOptionCount;
				++Surface.RetainedActiveDeckIdOptionCount;
				++Surface.RetainedImportedRuntimeSurfaceOptionCount;
				if (Entry.bHasRuntimeSurfaceLabel)
				{
					++Surface.LabeledRuntimeSurfaceOptionCount;
				}
				if (Entry.bHasRuntimeModeId)
				{
					++Surface.RuntimeModeTaggedOptionCount;
				}
				if (Entry.bHasGeneratorType)
				{
					++Surface.GeneratorTaggedOptionCount;
				}
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				Entry.PreviewDeckId = RunState.ActiveDeck.DeckId;
				Entry.PreviewSurfaceKind = RuntimeSurface.SurfaceKind;
				Entry.PreviewSurfaceId = RuntimeSurface.SurfaceId;
				Entry.PreviewSurfaceLabel = RuntimeSurface.SurfaceLabel;
				Entry.PreviewRuntimeModeId = RuntimeSurface.RuntimeModeId;
				Entry.PreviewGeneratorType = RuntimeSurface.GeneratorType;
				Entry.bHasExactDeckId = true;
				Entry.bHasExactRuntimeSurfaceIdentity = true;
				Entry.bHasRuntimeSurfaceLabel = !Entry.PreviewSurfaceLabel.IsEmpty();
				Entry.bHasRuntimeModeId = !Entry.PreviewRuntimeModeId.IsEmpty();
				Entry.bHasGeneratorType = !Entry.PreviewGeneratorType.IsEmpty();
				Entry.bRetainsActiveDeckId = true;
				Entry.bRetainsImportedRuntimeSurface = true;
				Entry.DeckIdLine = BuildDeckIdLine(Entry.PreviewDeckId);
				Entry.DeckIdSourceLine = Entry.PreviewDeckId.IsEmpty()
					? TEXT("Deck id source: exact source-deck id would be retained on generated owned execution, but the active deck id is currently empty.")
					: TEXT("Deck id source: exact source-deck id retained on generated owned execution.");
				Entry.RuntimeSurfaceLine = BuildRuntimeSurfaceLine(
					Entry.PreviewSurfaceKind,
					Entry.PreviewSurfaceId,
					Entry.PreviewSurfaceLabel,
					Entry.PreviewRuntimeModeId,
					Entry.PreviewGeneratorType
				);
				Entry.RuntimeSurfaceSourceLine =
					TEXT("Runtime surface source: exact source imported runtime surface retained on generated owned execution.");
				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
					? TEXT("Preview stability: exact while execute reuses the current stored request.")
					: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				++Surface.RetainedActiveDeckIdOptionCount;
				++Surface.RetainedImportedRuntimeSurfaceOptionCount;
				if (Entry.bHasRuntimeSurfaceLabel)
				{
					++Surface.LabeledRuntimeSurfaceOptionCount;
				}
				if (Entry.bHasRuntimeModeId)
				{
					++Surface.RuntimeModeTaggedOptionCount;
				}
				if (Entry.bHasGeneratorType)
				{
					++Surface.GeneratorTaggedOptionCount;
				}
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.DeckIdLine =
					TEXT("Deck id on execute: blocked until every required selector is resolved.");
				Entry.DeckIdSourceLine =
					TEXT("Deck id source: blocked while selector coverage remains incomplete.");
				Entry.RuntimeSurfaceLine =
					TEXT("Runtime surface on execute: blocked until every required selector is resolved.");
				Entry.RuntimeSurfaceSourceLine =
					TEXT("Runtime surface source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.DeckIdLine =
					TEXT("Deck id on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.DeckIdSourceLine =
					TEXT("Deck id source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.RuntimeSurfaceLine =
					TEXT("Runtime surface on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.RuntimeSurfaceSourceLine =
					TEXT("Runtime surface source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.DeckIdLine = TEXT("Deck id on execute: unavailable");
				Entry.DeckIdSourceLine = TEXT("Deck id source: unavailable");
				Entry.RuntimeSurfaceLine = TEXT("Runtime surface on execute: unavailable");
				Entry.RuntimeSurfaceSourceLine = TEXT("Runtime surface source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*PreviewEntry.DetailLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactDeckId = Entry.bHasExactDeckId;
			Surface.bCurrentSelectionHasExactRuntimeSurfaceIdentity =
				Entry.bHasExactRuntimeSurfaceIdentity;
			Surface.bCurrentSelectionHasRuntimeSurfaceLabel =
				Entry.bHasRuntimeSurfaceLabel;
			Surface.bCurrentSelectionHasRuntimeModeId = Entry.bHasRuntimeModeId;
			Surface.bCurrentSelectionHasGeneratorType = Entry.bHasGeneratorType;
			Surface.bCurrentSelectionRetainsActiveDeckId =
				Entry.bRetainsActiveDeckId;
			Surface.bCurrentSelectionRetainsImportedRuntimeSurface =
				Entry.bRetainsImportedRuntimeSurface;
			Surface.CurrentSelectionDeckRuntimeSurfaceLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.DeckIdLine,
				*Entry.RuntimeSurfaceLine,
				*Entry.PreviewStabilityLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionDeckIdRuntimeSurfaceRetentionPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectDeckIdRuntimeSurfaceRetentionPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedDeckIdRuntimeSurfaceRetentionPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedDeckIdRuntimeSurfaceRetentionPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.DeckIdSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Deck id: %d retained active-deck id | %d blocked | %d unavailable"),
			Surface.RetainedActiveDeckIdOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Deck id: no imported options");
	Surface.RuntimeSurfaceSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Runtime surface: %d retained imported surface | %d labeled | %d runtime-mode tagged | %d generator-tagged | %d blocked | %d unavailable"),
			Surface.RetainedImportedRuntimeSurfaceOptionCount,
			Surface.LabeledRuntimeSurfaceOptionCount,
			Surface.RuntimeModeTaggedOptionCount,
			Surface.GeneratorTaggedOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Runtime surface: no imported options");

	if (Surface.CurrentSelectionDeckRuntimeSurfaceLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionDeckRuntimeSurfaceLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionDeckRuntimeSurfaceLine =
				TEXT("Current selection has no additional owned-execution deck id/runtime-surface preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionDeckRuntimeSurfaceLine =
				TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionDeckRuntimeSurfaceLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution deck id/runtime-surface retention preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution deck id/runtime-surface retention preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution deck id/runtime-surface retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryModeRosterAllowedModeRetentionPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryModeRosterAllowedModeRetentionPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryModeRosterAllowedModeRetentionPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Delivery-Mode Roster/Allowed-Mode Retention Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Delivery-Mode Roster/Allowed-Mode Retention Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Delivery-Mode Roster/Allowed-Mode Retention Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution delivery-mode roster/allowed-mode retention preview requires a selector id from the active selector roster.");
		Surface.DeliveryModeRosterSummaryLine = TEXT("Deck delivery roster: n/a");
		Surface.AllowedModeRosterSummaryLine = TEXT("Allowed-mode roster: n/a");
		Surface.CurrentSelectionDeliveryModeRosterLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingCase* SeedCase = RunState.ActiveDeck.Cases.FindByPredicate(
		[](const FHyperTwistTrainingCase& Candidate)
		{
			return Candidate.IsStructurallyValid();
		}
	);

	const auto DescribeDeliveryMode = [](
		const EHyperTwistTrainingDeliveryMode DeliveryMode
	) -> FString
	{
		switch (DeliveryMode)
		{
			case EHyperTwistTrainingDeliveryMode::Timer:
				return TEXT("Timer");
			case EHyperTwistTrainingDeliveryMode::VirtualCube:
				return TEXT("Virtual Cube");
			case EHyperTwistTrainingDeliveryMode::SmartDevice:
				return TEXT("Smart Device");
			case EHyperTwistTrainingDeliveryMode::RecognitionAssisted:
				return TEXT("Recognition Assisted");
			case EHyperTwistTrainingDeliveryMode::CoachReviewed:
				return TEXT("Coach Reviewed");
			default:
				return TEXT("Unknown");
		}
	};

	const auto BuildModeLabels = [&DescribeDeliveryMode](
		const TArray<EHyperTwistTrainingDeliveryMode>& DeliveryModes
	) -> TArray<FString>
	{
		TArray<FString> Labels;
		Labels.Reserve(DeliveryModes.Num());
		for (const EHyperTwistTrainingDeliveryMode DeliveryMode : DeliveryModes)
		{
			Labels.Add(DescribeDeliveryMode(DeliveryMode));
		}

		return Labels;
	};

	const auto BuildModeRosterLine = [&BuildModeLabels](
		const FString& Prefix,
		const TArray<EHyperTwistTrainingDeliveryMode>& DeliveryModes,
		TArray<FString>& OutLabels
	) -> FString
	{
		OutLabels = BuildModeLabels(DeliveryModes);
		const FString LabelSummary = OutLabels.Num() > 0
			? FString::Join(OutLabels, TEXT(", "))
			: FString(TEXT("none"));
		return FString::Printf(TEXT("%s: %s"), *Prefix, *LabelSummary);
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution delivery-mode roster/allowed-mode retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.DeliveryModeRosterSummaryLine = TEXT("Deck delivery roster: n/a");
		Surface.AllowedModeRosterSummaryLine = TEXT("Allowed-mode roster: n/a");
		Surface.CurrentSelectionDeliveryModeRosterLine =
			OptionMenuSurface.bHasUnresolvedSelectionDetail
				? OptionMenuSurface.UnresolvedSelectionLine
				: (OptionMenuSurface.bHasSelection
					? TEXT("Current selection remains cached, but no active owned-execution delivery-mode roster preview is available.")
					: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryModeRosterAllowedModeRetentionPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
			{
				FHyperTwistTrainingCase MatchingCase;
				if (UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
						RunState.ActiveDeck,
						SelectorId,
						PreviewEntry.OptionId,
						MatchingCase))
				{
					Entry.PreviewDeckDeliveryModes = RunState.ActiveDeck.DeliveryModes;
					Entry.DeliveryModeRosterLine = BuildModeRosterLine(
						TEXT("Deck delivery modes retained on execute"),
						Entry.PreviewDeckDeliveryModes,
						Entry.PreviewDeckDeliveryModeLabels
					);
					Entry.bRetainsActiveDeckDeliveryModeRoster = true;
					Entry.bHasExactDeliveryModeRosterPreview = true;

					if (MatchingCase.AllowedDeliveryModes.Num() > 0)
					{
						Entry.PreviewAllowedDeliveryModes = MatchingCase.AllowedDeliveryModes;
						Entry.AllowedModeSourceLine =
							TEXT("Allowed-mode source: exact covered-case allowed-mode roster retained on direct covered-case start.");
					}
					else
					{
						Entry.PreviewAllowedDeliveryModes = RunState.ActiveDeck.DeliveryModes;
						Entry.bAllowedModeRosterFallsBackToDeckModes = true;
						Entry.AllowedModeSourceLine =
							TEXT("Allowed-mode source: covered owned case imposes no additional delivery-mode restriction, so the effective allowed-mode roster matches the retained active deck delivery roster.");
					}

					Entry.AllowedModeRosterLine = BuildModeRosterLine(
						TEXT("Allowed modes on execute"),
						Entry.PreviewAllowedDeliveryModes,
						Entry.PreviewAllowedDeliveryModeLabels
					);
					Entry.PreviewStabilityLine =
						TEXT("Preview stability: exact direct owned-execution modality roster from covered-case launch.");
					Entry.bHasExactAllowedModeRosterPreview = true;
					Entry.bCanPreview = true;
					++Surface.DirectExactOptionCount;
					++Surface.RetainedDeckDeliveryModeRosterOptionCount;
					++Surface.ExactAllowedModeRosterOptionCount;
					if (Entry.bAllowedModeRosterFallsBackToDeckModes)
					{
						++Surface.DeckFallbackAllowedModeRosterOptionCount;
					}
				}
				else
				{
					Entry.DeliveryModeRosterLine = TEXT("Deck delivery modes retained on execute: unavailable");
					Entry.AllowedModeRosterLine = TEXT("Allowed modes on execute: unavailable");
					Entry.AllowedModeSourceLine =
						TEXT("Allowed-mode source: unavailable because the covered case could not be re-resolved from the active deck.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
				}
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
			{
				if (SeedCase == nullptr)
				{
					Entry.DeliveryModeRosterLine =
						TEXT("Deck delivery modes retained on execute: unavailable");
					Entry.AllowedModeRosterLine = TEXT("Allowed modes on execute: unavailable");
					Entry.AllowedModeSourceLine =
						TEXT("Allowed-mode source: unavailable because the active generated-mode surface has no structurally valid seed case.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
					break;
				}

				Entry.PreviewDeckDeliveryModes = RunState.ActiveDeck.DeliveryModes;
				Entry.DeliveryModeRosterLine = BuildModeRosterLine(
					TEXT("Deck delivery modes retained on execute"),
					Entry.PreviewDeckDeliveryModes,
					Entry.PreviewDeckDeliveryModeLabels
				);
				Entry.bRetainsActiveDeckDeliveryModeRoster = true;
				Entry.bHasExactDeliveryModeRosterPreview = true;

				if (SeedCase->AllowedDeliveryModes.Num() > 0)
				{
					Entry.PreviewAllowedDeliveryModes = SeedCase->AllowedDeliveryModes;
				}
				else
				{
					Entry.PreviewAllowedDeliveryModes = RunState.ActiveDeck.DeliveryModes;
					Entry.bAllowedModeRosterFallsBackToDeckModes = true;
				}

				const int32 AllowedModeCountBeforeAugment =
					Entry.PreviewAllowedDeliveryModes.Num();
				Entry.PreviewAllowedDeliveryModes.AddUnique(
					PreviewEntry.HypotheticalDeliveryMode
				);
				Entry.bAllowedModeRosterAddsExecutionMode =
					Entry.PreviewAllowedDeliveryModes.Num() > AllowedModeCountBeforeAugment;
				Entry.AllowedModeRosterLine = BuildModeRosterLine(
					TEXT("Allowed modes on execute"),
					Entry.PreviewAllowedDeliveryModes,
					Entry.PreviewAllowedDeliveryModeLabels
				);

				const FString ExecuteModeLabel = DescribeDeliveryMode(
					PreviewEntry.HypotheticalDeliveryMode
				);
				if (Entry.bAllowedModeRosterFallsBackToDeckModes)
				{
					Entry.AllowedModeSourceLine =
						Entry.bAllowedModeRosterAddsExecutionMode
							? FString::Printf(
								TEXT("Allowed-mode source: generated owned execution falls back to the active deck delivery roster, then widens it with %s."),
								*ExecuteModeLabel
							)
							: FString::Printf(
								TEXT("Allowed-mode source: generated owned execution falls back to the active deck delivery roster, and %s is already included."),
								*ExecuteModeLabel
							);
				}
				else
				{
					Entry.AllowedModeSourceLine =
						Entry.bAllowedModeRosterAddsExecutionMode
							? FString::Printf(
								TEXT("Allowed-mode source: exact seed-case allowed-mode roster retained, then widened with %s."),
								*ExecuteModeLabel
							)
							: FString::Printf(
								TEXT("Allowed-mode source: exact seed-case allowed-mode roster retained, and %s is already included."),
								*ExecuteModeLabel
							);
				}

				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
						? TEXT("Preview stability: exact while execute reuses the current stored request.")
						: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bHasExactAllowedModeRosterPreview = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				++Surface.RetainedDeckDeliveryModeRosterOptionCount;
				++Surface.ExactAllowedModeRosterOptionCount;
				if (Entry.bAllowedModeRosterFallsBackToDeckModes)
				{
					++Surface.DeckFallbackAllowedModeRosterOptionCount;
				}
				if (Entry.bAllowedModeRosterAddsExecutionMode)
				{
					++Surface.ExecutionModeAugmentedAllowedModeRosterOptionCount;
				}
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.DeliveryModeRosterLine =
					TEXT("Deck delivery modes retained on execute: blocked until every required selector is resolved.");
				Entry.AllowedModeRosterLine =
					TEXT("Allowed modes on execute: blocked until every required selector is resolved.");
				Entry.AllowedModeSourceLine =
					TEXT("Allowed-mode source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.DeliveryModeRosterLine =
					TEXT("Deck delivery modes retained on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.AllowedModeRosterLine =
					TEXT("Allowed modes on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.AllowedModeSourceLine =
					TEXT("Allowed-mode source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.DeliveryModeRosterLine = TEXT("Deck delivery modes retained on execute: unavailable");
				Entry.AllowedModeRosterLine = TEXT("Allowed modes on execute: unavailable");
				Entry.AllowedModeSourceLine = TEXT("Allowed-mode source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		const FString EntryDetail = Entry.AllowedModeSourceLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*Entry.AllowedModeSourceLine
			);
		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? EntryDetail
			: FString::Printf(TEXT("%s | %s"), *EntryDetail, *PreviewEntry.DetailLine);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactDeliveryModeRosterPreview =
				Entry.bHasExactDeliveryModeRosterPreview;
			Surface.bCurrentSelectionHasExactAllowedModeRosterPreview =
				Entry.bHasExactAllowedModeRosterPreview;
			Surface.bCurrentSelectionRetainsActiveDeckDeliveryModeRoster =
				Entry.bRetainsActiveDeckDeliveryModeRoster;
			Surface.bCurrentSelectionAllowedModeRosterFallsBackToDeckModes =
				Entry.bAllowedModeRosterFallsBackToDeckModes;
			Surface.bCurrentSelectionAllowedModeRosterAddsExecutionMode =
				Entry.bAllowedModeRosterAddsExecutionMode;
			Surface.CurrentSelectionDeliveryModeRosterLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.DeliveryModeRosterLine,
				*Entry.AllowedModeRosterLine,
				*Entry.PreviewStabilityLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionDeliveryModeRosterAllowedModeRetentionPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectDeliveryModeRosterAllowedModeRetentionPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedDeliveryModeRosterAllowedModeRetentionPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedDeliveryModeRosterAllowedModeRetentionPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.DeliveryModeRosterSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Deck delivery roster: %d retained active-deck roster | %d blocked | %d unavailable"),
			Surface.RetainedDeckDeliveryModeRosterOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Deck delivery roster: no imported options");
	Surface.AllowedModeRosterSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Allowed-mode roster: %d exact | %d deck-fallback | %d execute-mode widened | %d blocked | %d unavailable"),
			Surface.ExactAllowedModeRosterOptionCount,
			Surface.DeckFallbackAllowedModeRosterOptionCount,
			Surface.ExecutionModeAugmentedAllowedModeRosterOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Allowed-mode roster: no imported options");

	if (Surface.CurrentSelectionDeliveryModeRosterLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionDeliveryModeRosterLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionDeliveryModeRosterLine =
				TEXT("Current selection has no additional owned-execution delivery-mode roster preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionDeliveryModeRosterLine =
				TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionDeliveryModeRosterLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution delivery-mode roster/allowed-mode retention preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution delivery-mode roster/allowed-mode retention preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution delivery-mode roster/allowed-mode retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Deck Capability Retention Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Deck Capability Retention Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Deck Capability Retention Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution deck capability retention preview requires a selector id from the active selector roster.");
		Surface.RealScrambleSummaryLine = TEXT("Real scrambles: n/a");
		Surface.VirtualCubeSummaryLine = TEXT("Virtual cube: n/a");
		Surface.SmartCubeSummaryLine = TEXT("Smart cube: n/a");
		Surface.CurrentSelectionCapabilityLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	const auto BuildCapabilityLine = [](
		const TCHAR* Prefix,
		const bool bEnabled,
		const TCHAR* EnabledText,
		const TCHAR* DisabledText
	) -> FString
	{
		return FString::Printf(
			TEXT("%s: %s"),
			Prefix,
			bEnabled ? EnabledText : DisabledText
		);
	};

	const auto IncrementCapabilityCounts = [&Surface](
		const bool bUsesRealScrambles,
		const bool bSupportsVirtualCube,
		const bool bSupportsSmartCube
	)
	{
		if (bUsesRealScrambles)
		{
			++Surface.RealScrambleEnabledOptionCount;
		}
		else
		{
			++Surface.RealScrambleDisabledOptionCount;
		}

		if (bSupportsVirtualCube)
		{
			++Surface.VirtualCubeEnabledOptionCount;
		}
		else
		{
			++Surface.VirtualCubeDisabledOptionCount;
		}

		if (bSupportsSmartCube)
		{
			++Surface.SmartCubeEnabledOptionCount;
		}
		else
		{
			++Surface.SmartCubeDisabledOptionCount;
		}
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution deck capability retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.RealScrambleSummaryLine = TEXT("Real scrambles: n/a");
		Surface.VirtualCubeSummaryLine = TEXT("Virtual cube: n/a");
		Surface.SmartCubeSummaryLine = TEXT("Smart cube: n/a");
		Surface.CurrentSelectionCapabilityLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution deck capability preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				Entry.bPreviewUsesRealScrambles = RunState.ActiveDeck.bUsesRealScrambles;
				Entry.bPreviewSupportsVirtualCube = RunState.ActiveDeck.bSupportsVirtualCube;
				Entry.bPreviewSupportsSmartCube = RunState.ActiveDeck.bSupportsSmartCube;
				Entry.RealScrambleLine = BuildCapabilityLine(
					TEXT("Real-scramble posture on execute"),
					Entry.bPreviewUsesRealScrambles,
					TEXT("enabled"),
					TEXT("disabled")
				);
				Entry.VirtualCubeLine = BuildCapabilityLine(
					TEXT("Virtual-cube posture on execute"),
					Entry.bPreviewSupportsVirtualCube,
					TEXT("enabled"),
					TEXT("disabled")
				);
				Entry.SmartCubeLine = BuildCapabilityLine(
					TEXT("Smart-cube posture on execute"),
					Entry.bPreviewSupportsSmartCube,
					TEXT("enabled"),
					TEXT("disabled")
				);
				Entry.CapabilitySourceLine =
					TEXT("Capability source: exact active deck capability flags retained on direct covered-case start.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: exact direct owned-execution deck capability posture from covered-case launch.");
				Entry.bHasExactCapabilityPreview = true;
				Entry.bRetainsActiveDeckCapabilityFlags = true;
				Entry.bCanPreview = true;
				++Surface.DirectExactOptionCount;
				++Surface.RetainedActiveDeckCapabilityOptionCount;
				IncrementCapabilityCounts(
					Entry.bPreviewUsesRealScrambles,
					Entry.bPreviewSupportsVirtualCube,
					Entry.bPreviewSupportsSmartCube
				);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				Entry.bPreviewUsesRealScrambles = RunState.ActiveDeck.bUsesRealScrambles;
				Entry.bPreviewSupportsVirtualCube = RunState.ActiveDeck.bSupportsVirtualCube;
				Entry.bPreviewSupportsSmartCube = RunState.ActiveDeck.bSupportsSmartCube;
				Entry.RealScrambleLine = BuildCapabilityLine(
					TEXT("Real-scramble posture on execute"),
					Entry.bPreviewUsesRealScrambles,
					TEXT("enabled"),
					TEXT("disabled")
				);
				Entry.VirtualCubeLine = BuildCapabilityLine(
					TEXT("Virtual-cube posture on execute"),
					Entry.bPreviewSupportsVirtualCube,
					TEXT("enabled"),
					TEXT("disabled")
				);
				Entry.SmartCubeLine = BuildCapabilityLine(
					TEXT("Smart-cube posture on execute"),
					Entry.bPreviewSupportsSmartCube,
					TEXT("enabled"),
					TEXT("disabled")
				);
				Entry.CapabilitySourceLine =
					TEXT("Capability source: exact source deck capability flags retained on generated owned execution.");
				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
						? TEXT("Preview stability: exact while execute reuses the current stored request.")
						: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bHasExactCapabilityPreview = true;
				Entry.bRetainsActiveDeckCapabilityFlags = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				++Surface.RetainedActiveDeckCapabilityOptionCount;
				IncrementCapabilityCounts(
					Entry.bPreviewUsesRealScrambles,
					Entry.bPreviewSupportsVirtualCube,
					Entry.bPreviewSupportsSmartCube
				);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.RealScrambleLine =
					TEXT("Real-scramble posture on execute: blocked until every required selector is resolved.");
				Entry.VirtualCubeLine =
					TEXT("Virtual-cube posture on execute: blocked until every required selector is resolved.");
				Entry.SmartCubeLine =
					TEXT("Smart-cube posture on execute: blocked until every required selector is resolved.");
				Entry.CapabilitySourceLine =
					TEXT("Capability source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.RealScrambleLine =
					TEXT("Real-scramble posture on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.VirtualCubeLine =
					TEXT("Virtual-cube posture on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SmartCubeLine =
					TEXT("Smart-cube posture on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.CapabilitySourceLine =
					TEXT("Capability source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.RealScrambleLine = TEXT("Real-scramble posture on execute: unavailable");
				Entry.VirtualCubeLine = TEXT("Virtual-cube posture on execute: unavailable");
				Entry.SmartCubeLine = TEXT("Smart-cube posture on execute: unavailable");
				Entry.CapabilitySourceLine = TEXT("Capability source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		const FString EntryDetail = Entry.CapabilitySourceLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*Entry.CapabilitySourceLine
			);
		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? EntryDetail
			: FString::Printf(TEXT("%s | %s"), *EntryDetail, *PreviewEntry.DetailLine);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactCapabilityPreview =
				Entry.bHasExactCapabilityPreview;
			Surface.bCurrentSelectionUsesRealScrambles =
				Entry.bPreviewUsesRealScrambles;
			Surface.bCurrentSelectionSupportsVirtualCube =
				Entry.bPreviewSupportsVirtualCube;
			Surface.bCurrentSelectionSupportsSmartCube =
				Entry.bPreviewSupportsSmartCube;
			Surface.bCurrentSelectionRetainsActiveDeckCapabilityFlags =
				Entry.bRetainsActiveDeckCapabilityFlags;
			Surface.CurrentSelectionCapabilityLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.RealScrambleLine,
				*Entry.VirtualCubeLine,
				*Entry.SmartCubeLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedRealScrambleVirtualCubeSmartCubeCapabilityRetentionPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.RealScrambleSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Real scrambles: %d enabled | %d disabled | %d blocked | %d unavailable"),
			Surface.RealScrambleEnabledOptionCount,
			Surface.RealScrambleDisabledOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Real scrambles: no imported options");
	Surface.VirtualCubeSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Virtual cube: %d enabled | %d disabled | %d blocked | %d unavailable"),
			Surface.VirtualCubeEnabledOptionCount,
			Surface.VirtualCubeDisabledOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Virtual cube: no imported options");
	Surface.SmartCubeSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Smart cube: %d enabled | %d disabled | %d blocked | %d unavailable"),
			Surface.SmartCubeEnabledOptionCount,
			Surface.SmartCubeDisabledOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Smart cube: no imported options");

	if (Surface.CurrentSelectionCapabilityLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionCapabilityLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionCapabilityLine =
				TEXT("Current selection has no additional owned-execution deck capability preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionCapabilityLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionCapabilityLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution deck capability retention preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution deck capability retention preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution deck capability retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Timing-Policy Retention Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Timing-Policy Retention Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Timing-Policy Retention Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution timing-policy retention preview requires a selector id from the active selector roster.");
		Surface.InspectionSummaryLine = TEXT("Inspection timing: n/a");
		Surface.PenaltySummaryLine = TEXT("Penalty posture: n/a");
		Surface.VisibilitySummaryLine = TEXT("Running time: n/a");
		Surface.SplitPhaseSummaryLine = TEXT("Split phases: n/a");
		Surface.CurrentSelectionTimingPolicyLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution timing-policy retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.InspectionSummaryLine = TEXT("Inspection timing: n/a");
		Surface.PenaltySummaryLine = TEXT("Penalty posture: n/a");
		Surface.VisibilitySummaryLine = TEXT("Running time: n/a");
		Surface.SplitPhaseSummaryLine = TEXT("Split phases: n/a");
		Surface.CurrentSelectionTimingPolicyLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution timing-policy preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	const FHyperTwistTrainingTimingPolicy PreviewTimingPolicy =
		UHyperTwistTrainingLibrary::NormalizeTimingPolicy(RunState.ActiveDeck.TimingPolicy);

	const auto BuildInspectionLine = [](
		const FHyperTwistTrainingTimingPolicy& TimingPolicy
	) -> FString
	{
		if (!TimingPolicy.bInspectionEnabled)
		{
			return TEXT("Inspection on execute: disabled");
		}

		const double InspectionSeconds =
			static_cast<double>(TimingPolicy.InspectionDurationMs) / 1000.0;
		return FString::Printf(
			TEXT("Inspection on execute: enabled at %.2fs"),
			InspectionSeconds
		);
	};

	const auto BuildPenaltyLine = [](
		const FHyperTwistTrainingTimingPolicy& TimingPolicy
	) -> FString
	{
		return FString::Printf(
			TEXT("Penalty posture on execute: inspection %s | manual %s"),
			TimingPolicy.bInspectionPenaltiesEnabled ? TEXT("enabled") : TEXT("disabled"),
			TimingPolicy.bAllowManualPenalty ? TEXT("enabled") : TEXT("disabled")
		);
	};

	const auto BuildVisibilityLine = [](
		const FHyperTwistTrainingTimingPolicy& TimingPolicy
	) -> FString
	{
		return FString::Printf(
			TEXT("Running-time posture on execute: %s"),
			TimingPolicy.bHideRunningTime ? TEXT("hidden") : TEXT("visible")
		);
	};

	const auto BuildSplitPhaseLine = [](
		const FHyperTwistTrainingTimingPolicy& TimingPolicy,
		TArray<FString>& OutLabels
	) -> FString
	{
		OutLabels.Reset();
		for (const FHyperTwistTrainingSplitPhaseDefinition& PhaseDefinition :
			 TimingPolicy.SplitPhases)
		{
			OutLabels.Add(
				PhaseDefinition.Label.IsEmpty()
					? PhaseDefinition.PhaseId
					: PhaseDefinition.Label
			);
		}

		if (OutLabels.Num() <= 0)
		{
			return TEXT("Split phases on execute: none");
		}

		return FString::Printf(
			TEXT("Split phases on execute: %d retained (%s)"),
			OutLabels.Num(),
			*FString::Join(OutLabels, TEXT(", "))
		);
	};

	const auto IncrementTimingPolicyCounts = [&Surface](
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewEntrySurface&
			Entry
	)
	{
		if (Entry.bInspectionEnabled)
		{
			++Surface.InspectionEnabledOptionCount;
		}
		else
		{
			++Surface.InspectionDisabledOptionCount;
		}

		if (Entry.bInspectionPenaltiesEnabled)
		{
			++Surface.InspectionPenaltyEnabledOptionCount;
		}
		else
		{
			++Surface.InspectionPenaltyDisabledOptionCount;
		}

		if (Entry.bAllowManualPenalty)
		{
			++Surface.ManualPenaltyEnabledOptionCount;
		}
		else
		{
			++Surface.ManualPenaltyDisabledOptionCount;
		}

		if (Entry.bHideRunningTime)
		{
			++Surface.HiddenRunningTimeOptionCount;
		}
		else
		{
			++Surface.VisibleRunningTimeOptionCount;
		}

		if (Entry.SplitPhaseCount > 0)
		{
			++Surface.SplitPhaseEnabledOptionCount;
		}
		else
		{
			++Surface.SplitPhaseDisabledOptionCount;
		}
	};

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				Entry.InspectionDurationMs = PreviewTimingPolicy.InspectionDurationMs;
				Entry.SplitPhaseCount = PreviewTimingPolicy.SplitPhases.Num();
				Entry.bInspectionEnabled = PreviewTimingPolicy.bInspectionEnabled;
				Entry.bInspectionPenaltiesEnabled =
					PreviewTimingPolicy.bInspectionPenaltiesEnabled;
				Entry.bAllowManualPenalty = PreviewTimingPolicy.bAllowManualPenalty;
				Entry.bHideRunningTime = PreviewTimingPolicy.bHideRunningTime;
				Entry.InspectionLine = BuildInspectionLine(PreviewTimingPolicy);
				Entry.PenaltyLine = BuildPenaltyLine(PreviewTimingPolicy);
				Entry.VisibilityLine = BuildVisibilityLine(PreviewTimingPolicy);
				Entry.SplitPhaseLine = BuildSplitPhaseLine(
					PreviewTimingPolicy,
					Entry.PreviewSplitPhaseLabels
				);
				Entry.TimingPolicySourceLine =
					TEXT("Timing-policy source: exact normalized active-deck timing policy retained on direct covered-case start.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: exact direct owned-execution timing policy from covered-case launch.");
				Entry.bHasExactTimingPolicyPreview = true;
				Entry.bRetainsActiveDeckTimingPolicy = true;
				Entry.bCanPreview = true;
				++Surface.DirectExactOptionCount;
				++Surface.RetainedActiveDeckTimingPolicyOptionCount;
				IncrementTimingPolicyCounts(Entry);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				Entry.InspectionDurationMs = PreviewTimingPolicy.InspectionDurationMs;
				Entry.SplitPhaseCount = PreviewTimingPolicy.SplitPhases.Num();
				Entry.bInspectionEnabled = PreviewTimingPolicy.bInspectionEnabled;
				Entry.bInspectionPenaltiesEnabled =
					PreviewTimingPolicy.bInspectionPenaltiesEnabled;
				Entry.bAllowManualPenalty = PreviewTimingPolicy.bAllowManualPenalty;
				Entry.bHideRunningTime = PreviewTimingPolicy.bHideRunningTime;
				Entry.InspectionLine = BuildInspectionLine(PreviewTimingPolicy);
				Entry.PenaltyLine = BuildPenaltyLine(PreviewTimingPolicy);
				Entry.VisibilityLine = BuildVisibilityLine(PreviewTimingPolicy);
				Entry.SplitPhaseLine = BuildSplitPhaseLine(
					PreviewTimingPolicy,
					Entry.PreviewSplitPhaseLabels
				);
				Entry.TimingPolicySourceLine =
					TEXT("Timing-policy source: exact normalized source-deck timing policy retained on generated owned execution.");
				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
						? TEXT("Preview stability: exact while execute reuses the current stored request.")
						: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bHasExactTimingPolicyPreview = true;
				Entry.bRetainsActiveDeckTimingPolicy = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				++Surface.RetainedActiveDeckTimingPolicyOptionCount;
				IncrementTimingPolicyCounts(Entry);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.InspectionLine =
					TEXT("Inspection on execute: blocked until every required selector is resolved.");
				Entry.PenaltyLine =
					TEXT("Penalty posture on execute: blocked until every required selector is resolved.");
				Entry.VisibilityLine =
					TEXT("Running-time posture on execute: blocked until every required selector is resolved.");
				Entry.SplitPhaseLine =
					TEXT("Split phases on execute: blocked until every required selector is resolved.");
				Entry.TimingPolicySourceLine =
					TEXT("Timing-policy source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.InspectionLine =
					TEXT("Inspection on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.PenaltyLine =
					TEXT("Penalty posture on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.VisibilityLine =
					TEXT("Running-time posture on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SplitPhaseLine =
					TEXT("Split phases on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.TimingPolicySourceLine =
					TEXT("Timing-policy source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.InspectionLine = TEXT("Inspection on execute: unavailable");
				Entry.PenaltyLine = TEXT("Penalty posture on execute: unavailable");
				Entry.VisibilityLine = TEXT("Running-time posture on execute: unavailable");
				Entry.SplitPhaseLine = TEXT("Split phases on execute: unavailable");
				Entry.TimingPolicySourceLine = TEXT("Timing-policy source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		const FString EntryDetail = Entry.TimingPolicySourceLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*Entry.TimingPolicySourceLine
			);
		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? EntryDetail
			: FString::Printf(TEXT("%s | %s"), *EntryDetail, *PreviewEntry.DetailLine);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactTimingPolicyPreview =
				Entry.bHasExactTimingPolicyPreview;
			Surface.bCurrentSelectionRetainsActiveDeckTimingPolicy =
				Entry.bRetainsActiveDeckTimingPolicy;
			Surface.bCurrentSelectionInspectionEnabled = Entry.bInspectionEnabled;
			Surface.bCurrentSelectionInspectionPenaltiesEnabled =
				Entry.bInspectionPenaltiesEnabled;
			Surface.bCurrentSelectionAllowsManualPenalty =
				Entry.bAllowManualPenalty;
			Surface.bCurrentSelectionHidesRunningTime = Entry.bHideRunningTime;
			Surface.bCurrentSelectionUsesSplitPhases = Entry.SplitPhaseCount > 0;
			Surface.CurrentSelectionTimingPolicyLine = FString::Printf(
				TEXT("%s | %s | %s | %s"),
				*Entry.InspectionLine,
				*Entry.PenaltyLine,
				*Entry.VisibilityLine,
				*Entry.SplitPhaseLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionTimingPolicyRetentionPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectTimingPolicyRetentionPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedTimingPolicyRetentionPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedTimingPolicyRetentionPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.InspectionSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Inspection timing: %d enabled | %d disabled | %d blocked | %d unavailable"),
			Surface.InspectionEnabledOptionCount,
			Surface.InspectionDisabledOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Inspection timing: no imported options");
	Surface.PenaltySummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Penalty posture: %d inspection-penalty enabled | %d inspection-penalty disabled | %d manual enabled | %d manual disabled"),
			Surface.InspectionPenaltyEnabledOptionCount,
			Surface.InspectionPenaltyDisabledOptionCount,
			Surface.ManualPenaltyEnabledOptionCount,
			Surface.ManualPenaltyDisabledOptionCount
		)
		: TEXT("Penalty posture: no imported options");
	Surface.VisibilitySummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Running time: %d hidden | %d visible | %d retained active-deck timing policies"),
			Surface.HiddenRunningTimeOptionCount,
			Surface.VisibleRunningTimeOptionCount,
			Surface.RetainedActiveDeckTimingPolicyOptionCount
		)
		: TEXT("Running time: no imported options");
	Surface.SplitPhaseSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Split phases: %d non-empty | %d empty | %d blocked | %d unavailable"),
			Surface.SplitPhaseEnabledOptionCount,
			Surface.SplitPhaseDisabledOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Split phases: no imported options");

	if (Surface.CurrentSelectionTimingPolicyLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionTimingPolicyLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionTimingPolicyLine =
				TEXT("Current selection has no additional owned-execution timing-policy preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionTimingPolicyLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionTimingPolicyLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution timing-policy retention preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution timing-policy retention preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution timing-policy retention preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewSurface
		TimingPolicyPreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Detail Retention Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Detail Retention Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Detail Retention Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase detail retention preview requires a selector id from the active selector roster.");
		Surface.SplitPhaseCountSummaryLine = TEXT("Normalized split phases: n/a");
		Surface.SplitPhaseOrderSummaryLine = TEXT("Phase-order detail: n/a");
		Surface.CurrentSelectionSplitPhaseDetailLine = TEXT("Current selection: n/a");
		Surface.DetailLine = TimingPolicyPreviewSurface.DetailLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: TimingPolicyPreviewSurface.DetailLine;
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = TimingPolicyPreviewSurface.StatusLine;
		Surface.SplitPhaseCountSummaryLine = TEXT("Normalized split phases: n/a");
		Surface.SplitPhaseOrderSummaryLine = TEXT("Phase-order detail: n/a");
		Surface.CurrentSelectionSplitPhaseDetailLine =
			OptionMenuSurface.bHasUnresolvedSelectionDetail
				? OptionMenuSurface.UnresolvedSelectionLine
				: (OptionMenuSurface.bHasSelection
					? TEXT("Current selection remains cached, but no active owned-execution split-phase detail preview is available.")
					: TEXT("Current selection: unresolved"));
		Surface.DetailLine = TimingPolicyPreviewSurface.DetailLine;
		return Surface;
	}

	const FHyperTwistTrainingTimingPolicy PreviewTimingPolicy =
		UHyperTwistTrainingLibrary::NormalizeTimingPolicy(RunState.ActiveDeck.TimingPolicy);

	const auto BuildPhaseEntries = [](
		const FHyperTwistTrainingTimingPolicy& TimingPolicy,
		TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewPhaseEntrySurface>&
			OutEntries
	)
	{
		OutEntries.Reset();
		for (const FHyperTwistTrainingSplitPhaseDefinition& PhaseDefinition :
			 TimingPolicy.SplitPhases)
		{
			FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewPhaseEntrySurface
				PhaseEntry;
			PhaseEntry.PhaseId = PhaseDefinition.PhaseId;
			PhaseEntry.Label = PhaseDefinition.Label;
			PhaseEntry.Order = PhaseDefinition.Order;
			PhaseEntry.OrderLine = FString::Printf(
				TEXT("Normalized phase order on execute: #%d"),
				PhaseDefinition.Order
			);
			PhaseEntry.LabelLine = FString::Printf(
				TEXT("Normalized phase label on execute: %s (%s)"),
				*PhaseDefinition.Label,
				*PhaseDefinition.PhaseId
			);
			PhaseEntry.DetailLine = FString::Printf(
				TEXT("%s | %s"),
				*PhaseEntry.OrderLine,
				*PhaseEntry.LabelLine
			);
			PhaseEntry.bCanPreview = true;
			OutEntries.Add(MoveTemp(PhaseEntry));
		}
	};

	const auto BuildSplitPhaseCountLine = [](
		const int32 SplitPhaseCount
	) -> FString
	{
		return SplitPhaseCount > 0
			? FString::Printf(
				TEXT("Normalized split-phase detail on execute: %d retained phase%s"),
				SplitPhaseCount,
				SplitPhaseCount == 1 ? TEXT("") : TEXT("s")
			)
			: FString(TEXT("Normalized split-phase detail on execute: none"));
	};

	const auto BuildSplitPhaseOrderLine = [](
		const TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewPhaseEntrySurface>&
			PhaseEntries
	) -> FString
	{
		if (PhaseEntries.Num() <= 0)
		{
			return TEXT("Normalized phase order on execute: none");
		}

		TArray<FString> OrderedLabels;
		OrderedLabels.Reserve(PhaseEntries.Num());
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewPhaseEntrySurface&
			 PhaseEntry : PhaseEntries)
		{
			OrderedLabels.Add(
				FString::Printf(TEXT("#%d %s"), PhaseEntry.Order, *PhaseEntry.Label)
			);
		}

		return FString::Printf(
			TEXT("Normalized phase order on execute: %s"),
			*FString::Join(OrderedLabels, TEXT(" | "))
		);
	};

	const auto BuildSplitPhaseLabelLine = [](
		const TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewPhaseEntrySurface>&
			PhaseEntries
	) -> FString
	{
		if (PhaseEntries.Num() <= 0)
		{
			return TEXT("Normalized phase labels on execute: none");
		}

		TArray<FString> PhaseLabels;
		PhaseLabels.Reserve(PhaseEntries.Num());
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewPhaseEntrySurface&
			 PhaseEntry : PhaseEntries)
		{
			PhaseLabels.Add(
				FString::Printf(TEXT("%s (%s)"), *PhaseEntry.Label, *PhaseEntry.PhaseId)
			);
		}

		return FString::Printf(
			TEXT("Normalized phase labels on execute: %s"),
			*FString::Join(PhaseLabels, TEXT(", "))
		);
	};

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionTimingPolicyRetentionPreviewEntrySurface&
		TimingEntry : TimingPolicyPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewEntrySurface
			Entry;
		Entry.OptionId = TimingEntry.OptionId;
		Entry.Label = TimingEntry.Label;
		Entry.OptionValue = TimingEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = TimingEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = TimingEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = TimingEntry.bStartsOwnedCaseImmediately;

		switch (TimingEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				BuildPhaseEntries(PreviewTimingPolicy, Entry.PhaseEntries);
				Entry.SplitPhaseCount = Entry.PhaseEntries.Num();
				Entry.bHasSplitPhases = Entry.SplitPhaseCount > 0;
				Entry.SplitPhaseCountLine = BuildSplitPhaseCountLine(Entry.SplitPhaseCount);
				Entry.SplitPhaseOrderLine = BuildSplitPhaseOrderLine(Entry.PhaseEntries);
				Entry.SplitPhaseLabelLine = BuildSplitPhaseLabelLine(Entry.PhaseEntries);
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase source: exact normalized active-deck split-phase order and labels retained on direct covered-case start.");
				Entry.PreviewStabilityLine = TimingEntry.PreviewStabilityLine;
				Entry.bHasExactSplitPhaseDetailPreview = true;
				Entry.bRetainsActiveDeckSplitPhaseDetail = true;
				Entry.bCanPreview = true;
				++Surface.DirectExactOptionCount;
				if (Entry.bHasSplitPhases)
				{
					++Surface.NonEmptySplitPhaseOptionCount;
				}
				else
				{
					++Surface.EmptySplitPhaseOptionCount;
				}
				Surface.TotalPreviewedSplitPhaseCount += Entry.SplitPhaseCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				BuildPhaseEntries(PreviewTimingPolicy, Entry.PhaseEntries);
				Entry.SplitPhaseCount = Entry.PhaseEntries.Num();
				Entry.bHasSplitPhases = Entry.SplitPhaseCount > 0;
				Entry.SplitPhaseCountLine = BuildSplitPhaseCountLine(Entry.SplitPhaseCount);
				Entry.SplitPhaseOrderLine = BuildSplitPhaseOrderLine(Entry.PhaseEntries);
				Entry.SplitPhaseLabelLine = BuildSplitPhaseLabelLine(Entry.PhaseEntries);
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase source: exact normalized source-deck split-phase order and labels retained on generated owned execution.");
				Entry.PreviewStabilityLine = TimingEntry.PreviewStabilityLine;
				Entry.bHasExactSplitPhaseDetailPreview = true;
				Entry.bRetainsActiveDeckSplitPhaseDetail = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				if (Entry.bHasSplitPhases)
				{
					++Surface.NonEmptySplitPhaseOptionCount;
				}
				else
				{
					++Surface.EmptySplitPhaseOptionCount;
				}
				Surface.TotalPreviewedSplitPhaseCount += Entry.SplitPhaseCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.SplitPhaseCountLine =
					TEXT("Normalized split-phase detail on execute: blocked until every required selector is resolved.");
				Entry.SplitPhaseOrderLine =
					TEXT("Normalized phase order on execute: blocked until every required selector is resolved.");
				Entry.SplitPhaseLabelLine =
					TEXT("Normalized phase labels on execute: blocked until every required selector is resolved.");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine = TimingEntry.PreviewStabilityLine;
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.SplitPhaseCountLine =
					TEXT("Normalized split-phase detail on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SplitPhaseOrderLine =
					TEXT("Normalized phase order on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SplitPhaseLabelLine =
					TEXT("Normalized phase labels on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine = TimingEntry.PreviewStabilityLine;
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.SplitPhaseCountLine =
					TEXT("Normalized split-phase detail on execute: unavailable");
				Entry.SplitPhaseOrderLine = TEXT("Normalized phase order on execute: unavailable");
				Entry.SplitPhaseLabelLine =
					TEXT("Normalized phase labels on execute: unavailable");
				Entry.SplitPhaseSourceLine = TEXT("Split-phase source: unavailable");
				Entry.PreviewStabilityLine = TimingEntry.PreviewStabilityLine;
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		const FString EntryDetail = Entry.SplitPhaseSourceLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*Entry.SplitPhaseSourceLine
			);
		Entry.DetailLine = EntryDetail;

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactSplitPhaseDetailPreview =
				Entry.bHasExactSplitPhaseDetailPreview;
			Surface.bCurrentSelectionRetainsActiveDeckSplitPhaseDetail =
				Entry.bRetainsActiveDeckSplitPhaseDetail;
			Surface.bCurrentSelectionHasSplitPhases = Entry.bHasSplitPhases;
			Surface.CurrentSelectionSplitPhaseDetailLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.SplitPhaseCountLine,
				*Entry.SplitPhaseOrderLine,
				*Entry.SplitPhaseLabelLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionSplitPhaseDetailRetentionPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectSplitPhaseDetailRetentionPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedSplitPhaseDetailRetentionPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedSplitPhaseDetailRetentionPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.SplitPhaseCountSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Normalized split phases: %d options with retained phases | %d options with none | %d total phases | %d blocked | %d unavailable"),
			Surface.NonEmptySplitPhaseOptionCount,
			Surface.EmptySplitPhaseOptionCount,
			Surface.TotalPreviewedSplitPhaseCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Normalized split phases: no imported options");
	Surface.SplitPhaseOrderSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Phase-order detail: %d direct exact | %d generated exact | %d blocked | %d unavailable"),
			Surface.DirectExactOptionCount,
			Surface.GeneratedExactOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Phase-order detail: no imported options");

	if (Surface.CurrentSelectionSplitPhaseDetailLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionSplitPhaseDetailLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionSplitPhaseDetailLine =
				TEXT("Current selection has no additional owned-execution split-phase detail preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionSplitPhaseDetailLine =
				TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionSplitPhaseDetailLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase detail retention preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase detail retention preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = TimingPolicyPreviewSurface.StatusLine;
	}

	Surface.DetailLine = TimingPolicyPreviewSurface.DetailLine;

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewSurface
		SplitPhaseDetailPreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Phase-Id/Label-Fallback Provenance Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Phase-Id/Label-Fallback Provenance Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Phase-Id/Label-Fallback Provenance Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase phase-id/label-fallback provenance preview requires a selector id from the active selector roster.");
		Surface.SplitPhaseCountSummaryLine = TEXT("Split-phase label provenance: n/a");
		Surface.LabelProvenanceSummaryLine = TEXT("Label-fallback detail: n/a");
		Surface.CurrentSelectionSplitPhaseProvenanceLine = TEXT("Current selection: n/a");
		Surface.DetailLine = SplitPhaseDetailPreviewSurface.DetailLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: SplitPhaseDetailPreviewSurface.DetailLine;
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = SplitPhaseDetailPreviewSurface.StatusLine;
		Surface.SplitPhaseCountSummaryLine = TEXT("Split-phase label provenance: n/a");
		Surface.LabelProvenanceSummaryLine = TEXT("Label-fallback detail: n/a");
		Surface.CurrentSelectionSplitPhaseProvenanceLine =
			OptionMenuSurface.bHasUnresolvedSelectionDetail
				? OptionMenuSurface.UnresolvedSelectionLine
				: (OptionMenuSurface.bHasSelection
					? TEXT("Current selection remains cached, but no active owned-execution split-phase label provenance preview is available.")
					: TEXT("Current selection: unresolved"));
		Surface.DetailLine = SplitPhaseDetailPreviewSurface.DetailLine;
		return Surface;
	}

	const FHyperTwistTrainingTimingPolicy RawTimingPolicy = RunState.ActiveDeck.TimingPolicy;
	const FHyperTwistTrainingTimingPolicy PreviewTimingPolicy =
		UHyperTwistTrainingLibrary::NormalizeTimingPolicy(RawTimingPolicy);

	const auto BuildPhaseProvenanceEntries = [](
		const FHyperTwistTrainingTimingPolicy& SourceTimingPolicy,
		const FHyperTwistTrainingTimingPolicy& NormalizedTimingPolicy,
		TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewPhaseEntrySurface>&
			OutEntries,
		int32& OutExplicitLabelPhaseCount,
		int32& OutFallbackLabelPhaseCount
	)
	{
		OutEntries.Reset();
		OutExplicitLabelPhaseCount = 0;
		OutFallbackLabelPhaseCount = 0;

		TArray<FHyperTwistTrainingSplitPhaseDefinition> SortedPhases =
			SourceTimingPolicy.SplitPhases;
		SortedPhases.Sort([](
			const FHyperTwistTrainingSplitPhaseDefinition& Left,
			const FHyperTwistTrainingSplitPhaseDefinition& Right
		)
		{
			if (Left.Order != Right.Order)
			{
				return Left.Order < Right.Order;
			}

			return Left.PhaseId < Right.PhaseId;
		});

		TSet<FString> SeenPhaseIds;
		int32 NextOrder = 0;
		for (const FHyperTwistTrainingSplitPhaseDefinition& PhaseDefinition : SortedPhases)
		{
			if (!PhaseDefinition.IsStructurallyValid()
				|| SeenPhaseIds.Contains(PhaseDefinition.PhaseId))
			{
				continue;
			}

			SeenPhaseIds.Add(PhaseDefinition.PhaseId);

			FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewPhaseEntrySurface
				PhaseEntry;
			PhaseEntry.PhaseId = PhaseDefinition.PhaseId;
			PhaseEntry.Order = NextOrder++;
			PhaseEntry.SourceLabel = PhaseDefinition.Label;
			PhaseEntry.bSourceLabelWasExplicit = !PhaseDefinition.Label.IsEmpty();
			PhaseEntry.bLabelFallsBackToPhaseId = !PhaseEntry.bSourceLabelWasExplicit;

			const int32 EntryIndex = OutEntries.Num();
			const FString NormalizedLabel =
				NormalizedTimingPolicy.SplitPhases.IsValidIndex(EntryIndex)
				&& NormalizedTimingPolicy.SplitPhases[EntryIndex].PhaseId
					== PhaseDefinition.PhaseId
					? NormalizedTimingPolicy.SplitPhases[EntryIndex].Label
					: (PhaseDefinition.Label.IsEmpty()
						? PhaseDefinition.PhaseId
						: PhaseDefinition.Label);
			PhaseEntry.NormalizedLabel = NormalizedLabel;
			PhaseEntry.OrderLine = FString::Printf(
				TEXT("Normalized phase order on execute: #%d"),
				PhaseEntry.Order
			);
			PhaseEntry.NormalizedLabelLine = FString::Printf(
				TEXT("Normalized phase label on execute: %s (%s)"),
				*PhaseEntry.NormalizedLabel,
				*PhaseEntry.PhaseId
			);
			PhaseEntry.LabelProvenanceLine = PhaseEntry.bSourceLabelWasExplicit
				? FString::Printf(
					TEXT("Label provenance on execute: explicit source label retained (%s)"),
					*PhaseDefinition.Label
				)
				: FString::Printf(
					TEXT("Label provenance on execute: phase-id fallback retained because the source label is empty (%s)"),
					*PhaseEntry.PhaseId
				);
			PhaseEntry.DetailLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*PhaseEntry.OrderLine,
				*PhaseEntry.NormalizedLabelLine,
				*PhaseEntry.LabelProvenanceLine
			);
			PhaseEntry.bCanPreview = true;

			if (PhaseEntry.bSourceLabelWasExplicit)
			{
				++OutExplicitLabelPhaseCount;
			}
			else
			{
				++OutFallbackLabelPhaseCount;
			}

			OutEntries.Add(MoveTemp(PhaseEntry));
		}
	};

	const auto BuildSplitPhaseCountLine = [](
		const int32 SplitPhaseCount
	) -> FString
	{
		return SplitPhaseCount > 0
			? FString::Printf(
				TEXT("Split-phase label provenance on execute: %d retained phase%s"),
				SplitPhaseCount,
				SplitPhaseCount == 1 ? TEXT("") : TEXT("s")
			)
			: FString(TEXT("Split-phase label provenance on execute: none"));
	};

	const auto BuildLabelProvenanceLine = [](
		const int32 ExplicitLabelPhaseCount,
		const int32 FallbackLabelPhaseCount
	) -> FString
	{
		return FString::Printf(
			TEXT("Label provenance on execute: %d explicit | %d phase-id fallback"),
			ExplicitLabelPhaseCount,
			FallbackLabelPhaseCount
		);
	};

	const auto BuildFallbackPhaseIdLine = [](
		const TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewPhaseEntrySurface>&
			PhaseEntries
	) -> FString
	{
		TArray<FString> FallbackPhaseIds;
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewPhaseEntrySurface&
			 PhaseEntry : PhaseEntries)
		{
			if (PhaseEntry.bLabelFallsBackToPhaseId)
			{
				FallbackPhaseIds.Add(PhaseEntry.PhaseId);
			}
		}

		return FallbackPhaseIds.Num() > 0
			? FString::Printf(
				TEXT("Phase-id fallback labels on execute: %s"),
				*FString::Join(FallbackPhaseIds, TEXT(", "))
			)
			: FString(TEXT("Phase-id fallback labels on execute: none"));
	};

	TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewPhaseEntrySurface>
		TemplatePhaseEntries;
	int32 TemplateExplicitLabelPhaseCount = 0;
	int32 TemplateFallbackLabelPhaseCount = 0;
	BuildPhaseProvenanceEntries(
		RawTimingPolicy,
		PreviewTimingPolicy,
		TemplatePhaseEntries,
		TemplateExplicitLabelPhaseCount,
		TemplateFallbackLabelPhaseCount
	);
	const int32 TemplateSplitPhaseCount = TemplatePhaseEntries.Num();
	const bool bTemplateHasSplitPhases = TemplateSplitPhaseCount > 0;
	const bool bTemplateHasFallbackLabels = TemplateFallbackLabelPhaseCount > 0;
	const FString TemplateSplitPhaseCountLine = BuildSplitPhaseCountLine(
		TemplateSplitPhaseCount
	);
	const FString TemplateLabelProvenanceLine = BuildLabelProvenanceLine(
		TemplateExplicitLabelPhaseCount,
		TemplateFallbackLabelPhaseCount
	);
	const FString TemplateFallbackPhaseIdLine = BuildFallbackPhaseIdLine(
		TemplatePhaseEntries
	);

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDetailRetentionPreviewEntrySurface&
		SplitPhaseEntry : SplitPhaseDetailPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewEntrySurface
			Entry;
		Entry.OptionId = SplitPhaseEntry.OptionId;
		Entry.Label = SplitPhaseEntry.Label;
		Entry.OptionValue = SplitPhaseEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = SplitPhaseEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = SplitPhaseEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = SplitPhaseEntry.bStartsOwnedCaseImmediately;

		switch (SplitPhaseEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				Entry.PhaseEntries = TemplatePhaseEntries;
				Entry.SplitPhaseCount = TemplateSplitPhaseCount;
				Entry.ExplicitLabelPhaseCount = TemplateExplicitLabelPhaseCount;
				Entry.FallbackLabelPhaseCount = TemplateFallbackLabelPhaseCount;
				Entry.bHasSplitPhases = bTemplateHasSplitPhases;
				Entry.bHasFallbackLabels = bTemplateHasFallbackLabels;
				Entry.SplitPhaseCountLine = TemplateSplitPhaseCountLine;
				Entry.LabelProvenanceLine = TemplateLabelProvenanceLine;
				Entry.FallbackPhaseIdLine = TemplateFallbackPhaseIdLine;
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase provenance source: exact normalized active-deck split-phase labels retained on direct covered-case start.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bHasExactSplitPhaseLabelProvenancePreview = true;
				Entry.bRetainsActiveDeckSplitPhaseLabelProvenance = true;
				Entry.bCanPreview = true;
				++Surface.DirectExactOptionCount;
				if (Entry.bHasSplitPhases)
				{
					++Surface.NonEmptySplitPhaseOptionCount;
				}
				else
				{
					++Surface.EmptySplitPhaseOptionCount;
				}
				if (Entry.bHasFallbackLabels)
				{
					++Surface.OptionsWithFallbackLabelCount;
				}
				Surface.TotalPreviewedSplitPhaseCount += Entry.SplitPhaseCount;
				Surface.ExplicitLabelPhaseCount += Entry.ExplicitLabelPhaseCount;
				Surface.FallbackLabelPhaseCount += Entry.FallbackLabelPhaseCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				Entry.PhaseEntries = TemplatePhaseEntries;
				Entry.SplitPhaseCount = TemplateSplitPhaseCount;
				Entry.ExplicitLabelPhaseCount = TemplateExplicitLabelPhaseCount;
				Entry.FallbackLabelPhaseCount = TemplateFallbackLabelPhaseCount;
				Entry.bHasSplitPhases = bTemplateHasSplitPhases;
				Entry.bHasFallbackLabels = bTemplateHasFallbackLabels;
				Entry.SplitPhaseCountLine = TemplateSplitPhaseCountLine;
				Entry.LabelProvenanceLine = TemplateLabelProvenanceLine;
				Entry.FallbackPhaseIdLine = TemplateFallbackPhaseIdLine;
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase provenance source: exact normalized source-deck split-phase labels retained on generated owned execution.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bHasExactSplitPhaseLabelProvenancePreview = true;
				Entry.bRetainsActiveDeckSplitPhaseLabelProvenance = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				if (Entry.bHasSplitPhases)
				{
					++Surface.NonEmptySplitPhaseOptionCount;
				}
				else
				{
					++Surface.EmptySplitPhaseOptionCount;
				}
				if (Entry.bHasFallbackLabels)
				{
					++Surface.OptionsWithFallbackLabelCount;
				}
				Surface.TotalPreviewedSplitPhaseCount += Entry.SplitPhaseCount;
				Surface.ExplicitLabelPhaseCount += Entry.ExplicitLabelPhaseCount;
				Surface.FallbackLabelPhaseCount += Entry.FallbackLabelPhaseCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.SplitPhaseCountLine =
					TEXT("Split-phase label provenance on execute: blocked until every required selector is resolved.");
				Entry.LabelProvenanceLine =
					TEXT("Label provenance on execute: blocked until every required selector is resolved.");
				Entry.FallbackPhaseIdLine =
					TEXT("Phase-id fallback labels on execute: blocked until every required selector is resolved.");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase provenance source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.SplitPhaseCountLine =
					TEXT("Split-phase label provenance on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.LabelProvenanceLine =
					TEXT("Label provenance on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.FallbackPhaseIdLine =
					TEXT("Phase-id fallback labels on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase provenance source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.SplitPhaseCountLine =
					TEXT("Split-phase label provenance on execute: unavailable");
				Entry.LabelProvenanceLine =
					TEXT("Label provenance on execute: unavailable");
				Entry.FallbackPhaseIdLine =
					TEXT("Phase-id fallback labels on execute: unavailable");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase provenance source: unavailable");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		const FString EntryDetail = Entry.SplitPhaseSourceLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*Entry.SplitPhaseSourceLine
			);
		Entry.DetailLine = EntryDetail;

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactSplitPhaseLabelProvenancePreview =
				Entry.bHasExactSplitPhaseLabelProvenancePreview;
			Surface.bCurrentSelectionRetainsActiveDeckSplitPhaseLabelProvenance =
				Entry.bRetainsActiveDeckSplitPhaseLabelProvenance;
			Surface.bCurrentSelectionHasSplitPhases = Entry.bHasSplitPhases;
			Surface.bCurrentSelectionHasFallbackLabels = Entry.bHasFallbackLabels;
			Surface.CurrentSelectionSplitPhaseProvenanceLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.SplitPhaseCountLine,
				*Entry.LabelProvenanceLine,
				*Entry.FallbackPhaseIdLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionSplitPhaseLabelProvenancePreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectSplitPhaseLabelProvenancePreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedSplitPhaseLabelProvenancePreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedSplitPhaseLabelProvenancePreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.SplitPhaseCountSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Split-phase label provenance: %d options with retained phases | %d options with none | %d total phases | %d blocked | %d unavailable"),
			Surface.NonEmptySplitPhaseOptionCount,
			Surface.EmptySplitPhaseOptionCount,
			Surface.TotalPreviewedSplitPhaseCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Split-phase label provenance: no imported options");
	Surface.LabelProvenanceSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Label-fallback detail: %d explicit labels | %d phase-id fallbacks | %d options with at least one fallback"),
			Surface.ExplicitLabelPhaseCount,
			Surface.FallbackLabelPhaseCount,
			Surface.OptionsWithFallbackLabelCount
		)
		: TEXT("Label-fallback detail: no imported options");

	if (Surface.CurrentSelectionSplitPhaseProvenanceLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionSplitPhaseProvenanceLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionSplitPhaseProvenanceLine =
				TEXT("Current selection has no additional owned-execution split-phase label provenance preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionSplitPhaseProvenanceLine =
				TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionSplitPhaseProvenanceLine =
				TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase phase-id/label-fallback provenance preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase phase-id/label-fallback provenance preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = SplitPhaseDetailPreviewSurface.StatusLine;
	}

	Surface.DetailLine = SplitPhaseDetailPreviewSurface.DetailLine;

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface
		SplitPhaseLabelProvenancePreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Duplicate-Pruning/Survivor Provenance Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Duplicate-Pruning/Survivor Provenance Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Duplicate-Pruning/Survivor Provenance Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase duplicate-pruning / survivor provenance preview requires a selector id from the active selector roster.");
		Surface.RawSplitPhaseCountSummaryLine = TEXT("Split-phase duplicate-pruning: n/a");
		Surface.DuplicatePruningSummaryLine = TEXT("Survivor provenance detail: n/a");
		Surface.CurrentSelectionDuplicatePruningLine = TEXT("Current selection: n/a");
		Surface.DetailLine = SplitPhaseLabelProvenancePreviewSurface.DetailLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: SplitPhaseLabelProvenancePreviewSurface.DetailLine;
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = SplitPhaseLabelProvenancePreviewSurface.StatusLine;
		Surface.RawSplitPhaseCountSummaryLine = TEXT("Split-phase duplicate-pruning: n/a");
		Surface.DuplicatePruningSummaryLine = TEXT("Survivor provenance detail: n/a");
		Surface.CurrentSelectionDuplicatePruningLine =
			OptionMenuSurface.bHasUnresolvedSelectionDetail
				? OptionMenuSurface.UnresolvedSelectionLine
				: (OptionMenuSurface.bHasSelection
					? TEXT("Current selection remains cached, but no active owned-execution split-phase duplicate-pruning preview is available.")
					: TEXT("Current selection: unresolved"));
		Surface.DetailLine = SplitPhaseLabelProvenancePreviewSurface.DetailLine;
		return Surface;
	}

	const FHyperTwistTrainingTimingPolicy RawTimingPolicy = RunState.ActiveDeck.TimingPolicy;
	const FHyperTwistTrainingTimingPolicy PreviewTimingPolicy =
		UHyperTwistTrainingLibrary::NormalizeTimingPolicy(RawTimingPolicy);

	const auto BuildInvalidReason = [](
		const FHyperTwistTrainingSplitPhaseDefinition& PhaseDefinition
	) -> FString
	{
		TArray<FString> Reasons;
		if (PhaseDefinition.PhaseId.IsEmpty())
		{
			Reasons.Add(TEXT("phase id is empty"));
		}
		if (PhaseDefinition.Order < 0)
		{
			Reasons.Add(TEXT("order is negative"));
		}

		return Reasons.Num() > 0
			? FString::Join(Reasons, TEXT("; "))
			: FString(TEXT("definition is structurally invalid"));
	};

	const auto BuildRawPhaseEntries = [&BuildInvalidReason](
		const FHyperTwistTrainingTimingPolicy& SourceTimingPolicy,
		const FHyperTwistTrainingTimingPolicy& NormalizedTimingPolicy,
		TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewRawPhaseEntrySurface>&
			OutEntries,
		int32& OutSurvivorPhaseCount,
		int32& OutDuplicatePrunedPhaseCount,
		int32& OutInvalidRawDefinitionCount
	)
	{
		struct FSurvivorMetadata
		{
			int32 NormalizedOrder = -1;
			int32 EvaluationOrder = -1;
			FString NormalizedLabel;
		};

		OutEntries.Reset();
		OutSurvivorPhaseCount = 0;
		OutDuplicatePrunedPhaseCount = 0;
		OutInvalidRawDefinitionCount = 0;

		TArray<FHyperTwistTrainingSplitPhaseDefinition> SortedPhases =
			SourceTimingPolicy.SplitPhases;
		SortedPhases.Sort([](
			const FHyperTwistTrainingSplitPhaseDefinition& Left,
			const FHyperTwistTrainingSplitPhaseDefinition& Right
		)
		{
			if (Left.Order != Right.Order)
			{
				return Left.Order < Right.Order;
			}

			return Left.PhaseId < Right.PhaseId;
		});

		TMap<FString, FSurvivorMetadata> SurvivorMetadataByPhaseId;
		int32 NextNormalizedOrder = 0;
		for (int32 SortedIndex = 0; SortedIndex < SortedPhases.Num(); ++SortedIndex)
		{
			const FHyperTwistTrainingSplitPhaseDefinition& PhaseDefinition =
				SortedPhases[SortedIndex];
			const FString DisplayPhaseId = PhaseDefinition.PhaseId.IsEmpty()
				? TEXT("<empty>")
				: PhaseDefinition.PhaseId;
			const FString DisplayLabel = PhaseDefinition.Label.IsEmpty()
				? TEXT("<empty>")
				: PhaseDefinition.Label;

			FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewRawPhaseEntrySurface
				Entry;
			Entry.PhaseId = PhaseDefinition.PhaseId;
			Entry.SourceLabel = PhaseDefinition.Label;
			Entry.RawOrder = PhaseDefinition.Order;
			Entry.EvaluationOrder = SortedIndex;
			Entry.bSourceLabelWasExplicit = !PhaseDefinition.Label.IsEmpty();
			Entry.bStructurallyValid = PhaseDefinition.IsStructurallyValid();
			Entry.RawDefinitionLine = FString::Printf(
				TEXT("Raw definition before normalize: order %d | phase id %s | label %s"),
				PhaseDefinition.Order,
				*DisplayPhaseId,
				*DisplayLabel
			);
			Entry.EvaluationOrderLine = FString::Printf(
				TEXT("Normalization evaluation order on execute: #%d"),
				SortedIndex
			);

			if (!Entry.bStructurallyValid)
			{
				Entry.bDroppedBecauseInvalid = true;
				Entry.NormalizationOutcomeLine = FString::Printf(
					TEXT("Normalization outcome on execute: skipped because the raw definition is structurally invalid (%s)"),
					*BuildInvalidReason(PhaseDefinition)
				);
				Entry.DuplicatePruningProvenanceLine =
					TEXT("Duplicate-pruning provenance on execute: invalid raw definitions never enter duplicate resolution.");
				Entry.DetailLine = FString::Printf(
					TEXT("%s | %s | %s"),
					*Entry.RawDefinitionLine,
					*Entry.NormalizationOutcomeLine,
					*Entry.DuplicatePruningProvenanceLine
				);
				Entry.bCanPreview = true;
				++OutInvalidRawDefinitionCount;
				OutEntries.Add(MoveTemp(Entry));
				continue;
			}

			if (const FSurvivorMetadata* ExistingSurvivor =
				SurvivorMetadataByPhaseId.Find(PhaseDefinition.PhaseId))
			{
				Entry.bDroppedBecauseDuplicate = true;
				Entry.NormalizedOrder = ExistingSurvivor->NormalizedOrder;
				Entry.SurvivorNormalizedLabel = ExistingSurvivor->NormalizedLabel;
				Entry.NormalizationOutcomeLine = FString::Printf(
					TEXT("Normalization outcome on execute: dropped as a duplicate raw definition for phase id %s."),
					*DisplayPhaseId
				);
				Entry.DuplicatePruningProvenanceLine = FString::Printf(
					TEXT("Duplicate-pruning provenance on execute: earlier survivor already retained phase id %s at normalized order #%d with label %s."),
					*DisplayPhaseId,
					ExistingSurvivor->NormalizedOrder,
					*ExistingSurvivor->NormalizedLabel
				);
				Entry.DetailLine = FString::Printf(
					TEXT("%s | %s | %s"),
					*Entry.RawDefinitionLine,
					*Entry.NormalizationOutcomeLine,
					*Entry.DuplicatePruningProvenanceLine
				);
				Entry.bCanPreview = true;
				++OutDuplicatePrunedPhaseCount;
				OutEntries.Add(MoveTemp(Entry));
				continue;
			}

			Entry.bSurvivesNormalization = true;
			Entry.NormalizedOrder = NextNormalizedOrder;
			Entry.SurvivorNormalizedLabel =
				NormalizedTimingPolicy.SplitPhases.IsValidIndex(NextNormalizedOrder)
				&& NormalizedTimingPolicy.SplitPhases[NextNormalizedOrder].PhaseId
					== PhaseDefinition.PhaseId
					? NormalizedTimingPolicy.SplitPhases[NextNormalizedOrder].Label
					: (PhaseDefinition.Label.IsEmpty()
						? PhaseDefinition.PhaseId
						: PhaseDefinition.Label);
			Entry.NormalizationOutcomeLine = FString::Printf(
				TEXT("Normalization outcome on execute: retained as survivor #%d with normalized label %s (%s)."),
				Entry.NormalizedOrder,
				*Entry.SurvivorNormalizedLabel,
				*DisplayPhaseId
			);
			Entry.DuplicatePruningProvenanceLine = FString::Printf(
				TEXT("Duplicate-pruning provenance on execute: first valid definition for phase id %s survives duplicate rejection."),
				*DisplayPhaseId
			);
			Entry.DetailLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.RawDefinitionLine,
				*Entry.NormalizationOutcomeLine,
				*Entry.DuplicatePruningProvenanceLine
			);
			Entry.bCanPreview = true;

			FSurvivorMetadata SurvivorMetadata;
			SurvivorMetadata.NormalizedOrder = Entry.NormalizedOrder;
			SurvivorMetadata.EvaluationOrder = Entry.EvaluationOrder;
			SurvivorMetadata.NormalizedLabel = Entry.SurvivorNormalizedLabel;
			SurvivorMetadataByPhaseId.Add(PhaseDefinition.PhaseId, MoveTemp(SurvivorMetadata));

			++NextNormalizedOrder;
			++OutSurvivorPhaseCount;
			OutEntries.Add(MoveTemp(Entry));
		}
	};

	const auto BuildRawSplitPhaseCountLine = [](
		const int32 RawSplitPhaseCount
	) -> FString
	{
		return RawSplitPhaseCount > 0
			? FString::Printf(
				TEXT("Raw split-phase definitions before normalize: %d"),
				RawSplitPhaseCount
			)
			: FString(TEXT("Raw split-phase definitions before normalize: none"));
	};

	const auto BuildSurvivorCountLine = [](
		const int32 SurvivorPhaseCount
	) -> FString
	{
		return SurvivorPhaseCount > 0
			? FString::Printf(
				TEXT("Surviving normalized split phases on execute: %d"),
				SurvivorPhaseCount
			)
			: FString(TEXT("Surviving normalized split phases on execute: none"));
	};

	const auto BuildDuplicatePruningLine = [](
		const int32 DuplicatePrunedPhaseCount
	) -> FString
	{
		return DuplicatePrunedPhaseCount > 0
			? FString::Printf(
				TEXT("Duplicate-pruned raw split-phase definitions on execute: %d"),
				DuplicatePrunedPhaseCount
			)
			: FString(TEXT("Duplicate-pruned raw split-phase definitions on execute: none"));
	};

	const auto BuildInvalidDefinitionLine = [](
		const int32 InvalidRawDefinitionCount
	) -> FString
	{
		return InvalidRawDefinitionCount > 0
			? FString::Printf(
				TEXT("Invalid raw split-phase definitions skipped on execute: %d"),
				InvalidRawDefinitionCount
			)
			: FString(TEXT("Invalid raw split-phase definitions skipped on execute: none"));
	};

	const auto BuildSurvivorPhaseIdLine = [](
		const TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewRawPhaseEntrySurface>&
			RawPhaseEntries
	) -> FString
	{
		TArray<FString> SurvivorPhaseIds;
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewRawPhaseEntrySurface&
			 Entry : RawPhaseEntries)
		{
			if (Entry.bSurvivesNormalization)
			{
				SurvivorPhaseIds.Add(Entry.PhaseId);
			}
		}

		return SurvivorPhaseIds.Num() > 0
			? FString::Printf(
				TEXT("Surviving phase ids on execute: %s"),
				*FString::Join(SurvivorPhaseIds, TEXT(", "))
			)
			: FString(TEXT("Surviving phase ids on execute: none"));
	};

	TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewRawPhaseEntrySurface>
		TemplateRawPhaseEntries;
	int32 TemplateSurvivorPhaseCount = 0;
	int32 TemplateDuplicatePrunedPhaseCount = 0;
	int32 TemplateInvalidRawDefinitionCount = 0;
	BuildRawPhaseEntries(
		RawTimingPolicy,
		PreviewTimingPolicy,
		TemplateRawPhaseEntries,
		TemplateSurvivorPhaseCount,
		TemplateDuplicatePrunedPhaseCount,
		TemplateInvalidRawDefinitionCount
	);
	const int32 TemplateRawSplitPhaseCount = TemplateRawPhaseEntries.Num();
	const FString TemplateRawSplitPhaseCountLine = BuildRawSplitPhaseCountLine(
		TemplateRawSplitPhaseCount
	);
	const FString TemplateSurvivorCountLine = BuildSurvivorCountLine(
		TemplateSurvivorPhaseCount
	);
	const FString TemplateDuplicatePruningLine = BuildDuplicatePruningLine(
		TemplateDuplicatePrunedPhaseCount
	);
	const FString TemplateInvalidDefinitionLine = BuildInvalidDefinitionLine(
		TemplateInvalidRawDefinitionCount
	);
	const FString TemplateSurvivorPhaseIdLine = BuildSurvivorPhaseIdLine(
		TemplateRawPhaseEntries
	);

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewEntrySurface&
		SplitPhaseEntry : SplitPhaseLabelProvenancePreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewEntrySurface
			Entry;
		Entry.OptionId = SplitPhaseEntry.OptionId;
		Entry.Label = SplitPhaseEntry.Label;
		Entry.OptionValue = SplitPhaseEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = SplitPhaseEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = SplitPhaseEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = SplitPhaseEntry.bStartsOwnedCaseImmediately;

		switch (SplitPhaseEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				Entry.RawPhaseEntries = TemplateRawPhaseEntries;
				Entry.RawSplitPhaseCount = TemplateRawSplitPhaseCount;
				Entry.SurvivorPhaseCount = TemplateSurvivorPhaseCount;
				Entry.DuplicatePrunedPhaseCount = TemplateDuplicatePrunedPhaseCount;
				Entry.InvalidRawDefinitionCount = TemplateInvalidRawDefinitionCount;
				Entry.bHasDuplicatePrunedPhases = TemplateDuplicatePrunedPhaseCount > 0;
				Entry.bHasInvalidRawDefinitions = TemplateInvalidRawDefinitionCount > 0;
				Entry.RawSplitPhaseCountLine = TemplateRawSplitPhaseCountLine;
				Entry.SurvivorCountLine = TemplateSurvivorCountLine;
				Entry.DuplicatePruningLine = TemplateDuplicatePruningLine;
				Entry.InvalidDefinitionLine = TemplateInvalidDefinitionLine;
				Entry.SurvivorPhaseIdLine = TemplateSurvivorPhaseIdLine;
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase duplicate-pruning provenance source: exact active-deck raw split-phase set normalized and duplicate-pruned for direct covered-case start.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bHasExactSplitPhaseDuplicatePruningPreview = true;
				Entry.bRetainsActiveDeckSplitPhaseDuplicatePruningProvenance = true;
				Entry.bCanPreview = true;
				++Surface.DirectExactOptionCount;
				if (Entry.bHasDuplicatePrunedPhases)
				{
					++Surface.OptionsWithDuplicatePruningCount;
				}
				if (Entry.bHasInvalidRawDefinitions)
				{
					++Surface.OptionsWithInvalidRawDefinitionsCount;
				}
				Surface.RawSplitPhaseDefinitionCount += Entry.RawSplitPhaseCount;
				Surface.SurvivorPhaseCount += Entry.SurvivorPhaseCount;
				Surface.DuplicatePrunedPhaseCount += Entry.DuplicatePrunedPhaseCount;
				Surface.InvalidRawDefinitionCount += Entry.InvalidRawDefinitionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				Entry.RawPhaseEntries = TemplateRawPhaseEntries;
				Entry.RawSplitPhaseCount = TemplateRawSplitPhaseCount;
				Entry.SurvivorPhaseCount = TemplateSurvivorPhaseCount;
				Entry.DuplicatePrunedPhaseCount = TemplateDuplicatePrunedPhaseCount;
				Entry.InvalidRawDefinitionCount = TemplateInvalidRawDefinitionCount;
				Entry.bHasDuplicatePrunedPhases = TemplateDuplicatePrunedPhaseCount > 0;
				Entry.bHasInvalidRawDefinitions = TemplateInvalidRawDefinitionCount > 0;
				Entry.RawSplitPhaseCountLine = TemplateRawSplitPhaseCountLine;
				Entry.SurvivorCountLine = TemplateSurvivorCountLine;
				Entry.DuplicatePruningLine = TemplateDuplicatePruningLine;
				Entry.InvalidDefinitionLine = TemplateInvalidDefinitionLine;
				Entry.SurvivorPhaseIdLine = TemplateSurvivorPhaseIdLine;
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase duplicate-pruning provenance source: exact source-deck raw split-phase set normalized and duplicate-pruned for generated owned execution.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bHasExactSplitPhaseDuplicatePruningPreview = true;
				Entry.bRetainsActiveDeckSplitPhaseDuplicatePruningProvenance = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				if (Entry.bHasDuplicatePrunedPhases)
				{
					++Surface.OptionsWithDuplicatePruningCount;
				}
				if (Entry.bHasInvalidRawDefinitions)
				{
					++Surface.OptionsWithInvalidRawDefinitionsCount;
				}
				Surface.RawSplitPhaseDefinitionCount += Entry.RawSplitPhaseCount;
				Surface.SurvivorPhaseCount += Entry.SurvivorPhaseCount;
				Surface.DuplicatePrunedPhaseCount += Entry.DuplicatePrunedPhaseCount;
				Surface.InvalidRawDefinitionCount += Entry.InvalidRawDefinitionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.RawSplitPhaseCountLine =
					TEXT("Raw split-phase definitions before normalize: blocked until every required selector is resolved.");
				Entry.SurvivorCountLine =
					TEXT("Surviving normalized split phases on execute: blocked until every required selector is resolved.");
				Entry.DuplicatePruningLine =
					TEXT("Duplicate-pruned raw split-phase definitions on execute: blocked until every required selector is resolved.");
				Entry.InvalidDefinitionLine =
					TEXT("Invalid raw split-phase definitions skipped on execute: blocked until every required selector is resolved.");
				Entry.SurvivorPhaseIdLine =
					TEXT("Surviving phase ids on execute: blocked until every required selector is resolved.");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase duplicate-pruning provenance source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.RawSplitPhaseCountLine =
					TEXT("Raw split-phase definitions before normalize: blocked until a structurally valid launch payload can be derived.");
				Entry.SurvivorCountLine =
					TEXT("Surviving normalized split phases on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.DuplicatePruningLine =
					TEXT("Duplicate-pruned raw split-phase definitions on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.InvalidDefinitionLine =
					TEXT("Invalid raw split-phase definitions skipped on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SurvivorPhaseIdLine =
					TEXT("Surviving phase ids on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase duplicate-pruning provenance source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.RawSplitPhaseCountLine =
					TEXT("Raw split-phase definitions before normalize: unavailable");
				Entry.SurvivorCountLine =
					TEXT("Surviving normalized split phases on execute: unavailable");
				Entry.DuplicatePruningLine =
					TEXT("Duplicate-pruned raw split-phase definitions on execute: unavailable");
				Entry.InvalidDefinitionLine =
					TEXT("Invalid raw split-phase definitions skipped on execute: unavailable");
				Entry.SurvivorPhaseIdLine =
					TEXT("Surviving phase ids on execute: unavailable");
				Entry.SplitPhaseSourceLine =
					TEXT("Split-phase duplicate-pruning provenance source: unavailable");
				Entry.PreviewStabilityLine = SplitPhaseEntry.PreviewStabilityLine;
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		Entry.DetailLine = Entry.SplitPhaseSourceLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*Entry.SplitPhaseSourceLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactSplitPhaseDuplicatePruningPreview =
				Entry.bHasExactSplitPhaseDuplicatePruningPreview;
			Surface.bCurrentSelectionRetainsActiveDeckSplitPhaseDuplicatePruningProvenance =
				Entry.bRetainsActiveDeckSplitPhaseDuplicatePruningProvenance;
			Surface.bCurrentSelectionHasDuplicatePrunedPhases =
				Entry.bHasDuplicatePrunedPhases;
			Surface.bCurrentSelectionHasInvalidRawDefinitions =
				Entry.bHasInvalidRawDefinitions;
			Surface.CurrentSelectionDuplicatePruningLine = FString::Printf(
				TEXT("%s | %s | %s | %s | %s"),
				*Entry.RawSplitPhaseCountLine,
				*Entry.SurvivorCountLine,
				*Entry.DuplicatePruningLine,
				*Entry.InvalidDefinitionLine,
				*Entry.SurvivorPhaseIdLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionSplitPhaseDuplicatePruningPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectSplitPhaseDuplicatePruningPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedSplitPhaseDuplicatePruningPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedSplitPhaseDuplicatePruningPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.RawSplitPhaseCountSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Split-phase duplicate-pruning: %d raw definitions | %d survivors | %d duplicate-pruned | %d invalid | %d blocked | %d unavailable"),
			Surface.RawSplitPhaseDefinitionCount,
			Surface.SurvivorPhaseCount,
			Surface.DuplicatePrunedPhaseCount,
			Surface.InvalidRawDefinitionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Split-phase duplicate-pruning: no imported options");
	Surface.DuplicatePruningSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Survivor provenance detail: %d options with duplicate-pruned rows | %d options with invalid rows"),
			Surface.OptionsWithDuplicatePruningCount,
			Surface.OptionsWithInvalidRawDefinitionsCount
		)
		: TEXT("Survivor provenance detail: no imported options");

	if (Surface.CurrentSelectionDuplicatePruningLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionDuplicatePruningLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionDuplicatePruningLine =
				TEXT("Current selection has no additional owned-execution split-phase duplicate-pruning preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionDuplicatePruningLine =
				TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionDuplicatePruningLine =
				TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase duplicate-pruning / survivor provenance preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase duplicate-pruning / survivor provenance preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = SplitPhaseLabelProvenancePreviewSurface.StatusLine;
	}

	Surface.DetailLine = SplitPhaseLabelProvenancePreviewSurface.DetailLine;

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseNormalizationSummaryPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseNormalizationSummaryPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface
		LabelProvenancePreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewSurface
		DuplicatePruningPreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseNormalizationSummaryPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Normalization Summary Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Normalization Summary Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Normalization Summary Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase normalization summary preview requires a selector id from the active selector roster.");
		Surface.NormalizationSummaryLine = TEXT("Split-phase normalization summary: n/a");
		Surface.LabelFallbackSummaryLine = TEXT("Label-fallback summary: n/a");
		Surface.PreviewPostureSummaryLine = TEXT("Preview posture: n/a");
		Surface.CurrentSelectionNormalizationSummaryLine = TEXT("Current selection: n/a");
		Surface.DetailLine = !DuplicatePruningPreviewSurface.DetailLine.IsEmpty()
			? DuplicatePruningPreviewSurface.DetailLine
			: LabelProvenancePreviewSurface.DetailLine;
		return Surface;
	}

	TMap<FString, int32> LabelEntryIndexByOptionId;
	for (int32 EntryIndex = 0;
		 EntryIndex < LabelProvenancePreviewSurface.OptionEntries.Num();
		 ++EntryIndex)
	{
		LabelEntryIndexByOptionId.FindOrAdd(
			LabelProvenancePreviewSurface.OptionEntries[EntryIndex].OptionId
		) = EntryIndex;
	}

	const auto BuildBlockedLabelLine = [](
		const FString& BlockReason
	) -> FString
	{
		return BlockReason.IsEmpty()
			? TEXT("Label provenance on execute: blocked")
			: FString::Printf(TEXT("Label provenance on execute: %s"), *BlockReason);
	};

	const auto BuildFallbackLine = [](
		const FString& FallbackReason
	) -> FString
	{
		return FallbackReason.IsEmpty()
			? TEXT("Phase-id fallback labels on execute: unavailable")
			: FallbackReason;
	};

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewEntrySurface&
		DuplicateEntry : DuplicatePruningPreviewSurface.OptionEntries)
	{
		const int32* LabelEntryIndex = LabelEntryIndexByOptionId.Find(
			DuplicateEntry.OptionId
		);
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewEntrySurface*
			LabelEntry = LabelEntryIndex != nullptr
				? &LabelProvenancePreviewSurface.OptionEntries[*LabelEntryIndex]
				: nullptr;

		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseNormalizationSummaryPreviewEntrySurface
			Entry;
		Entry.OptionId = DuplicateEntry.OptionId;
		Entry.Label = DuplicateEntry.Label;
		Entry.OptionValue = DuplicateEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = DuplicateEntry.LaunchRequestPreviewKind;
		Entry.RawSplitPhaseCountLine = DuplicateEntry.RawSplitPhaseCountLine;
		Entry.SurvivorCountLine = DuplicateEntry.SurvivorCountLine;
		Entry.DuplicatePruningLine = DuplicateEntry.DuplicatePruningLine;
		Entry.InvalidDefinitionLine = DuplicateEntry.InvalidDefinitionLine;
		Entry.RawSplitPhaseCount = DuplicateEntry.RawSplitPhaseCount;
		Entry.SurvivorPhaseCount = DuplicateEntry.SurvivorPhaseCount;
		Entry.DuplicatePrunedPhaseCount = DuplicateEntry.DuplicatePrunedPhaseCount;
		Entry.InvalidRawDefinitionCount = DuplicateEntry.InvalidRawDefinitionCount;
		Entry.bMatchesCurrentSelection = DuplicateEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = DuplicateEntry.bStartsOwnedCaseImmediately;
		Entry.bHasDuplicatePrunedPhases = DuplicateEntry.bHasDuplicatePrunedPhases;
		Entry.bHasInvalidRawDefinitions = DuplicateEntry.bHasInvalidRawDefinitions;
		Entry.bPreviewBlocked = DuplicateEntry.bPreviewBlocked;
		Entry.bCanPreview = DuplicateEntry.bCanPreview;

		if (LabelEntry != nullptr)
		{
			Entry.LabelProvenanceLine = LabelEntry->LabelProvenanceLine;
			Entry.FallbackPhaseIdLine = LabelEntry->FallbackPhaseIdLine;
			Entry.ExplicitLabelPhaseCount = LabelEntry->ExplicitLabelPhaseCount;
			Entry.FallbackLabelPhaseCount = LabelEntry->FallbackLabelPhaseCount;
			Entry.bHasFallbackLabels = LabelEntry->bHasFallbackLabels;
			Entry.bHasExactNormalizationSummaryPreview =
				DuplicateEntry.bHasExactSplitPhaseDuplicatePruningPreview
				&& LabelEntry->bHasExactSplitPhaseLabelProvenancePreview;
			Entry.bRetainsActiveDeckSplitPhaseNormalizationSummary =
				DuplicateEntry.bRetainsActiveDeckSplitPhaseDuplicatePruningProvenance
				&& LabelEntry->bRetainsActiveDeckSplitPhaseLabelProvenance;
		}
		else
		{
			Entry.LabelProvenanceLine = DuplicateEntry.bPreviewBlocked
				? BuildBlockedLabelLine(TEXT("blocked while the split-phase normalization preview cannot be fully derived"))
				: TEXT("Label provenance on execute: unavailable");
			Entry.FallbackPhaseIdLine = DuplicateEntry.bPreviewBlocked
				? TEXT("Phase-id fallback labels on execute: blocked while the split-phase normalization preview cannot be fully derived.")
				: TEXT("Phase-id fallback labels on execute: unavailable");
		}

		Entry.PreviewPostureLine = DuplicateEntry.SplitPhaseSourceLine.IsEmpty()
			? DuplicateEntry.PreviewStabilityLine
			: FString::Printf(
				TEXT("Preview posture on execute: %s | %s"),
				*DuplicateEntry.PreviewStabilityLine,
				*DuplicateEntry.SplitPhaseSourceLine
			);
		Entry.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*Entry.PreviewPostureLine,
			*Entry.DuplicatePruningLine,
			*Entry.LabelProvenanceLine
		);

		switch (Entry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				++Surface.DirectExactOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				++Surface.GeneratedExactOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				++Surface.UnavailableOptionCount;
				break;
		}

		Surface.RawSplitPhaseDefinitionCount += Entry.RawSplitPhaseCount;
		Surface.SurvivorPhaseCount += Entry.SurvivorPhaseCount;
		Surface.DuplicatePrunedPhaseCount += Entry.DuplicatePrunedPhaseCount;
		Surface.InvalidRawDefinitionCount += Entry.InvalidRawDefinitionCount;
		Surface.ExplicitLabelPhaseCount += Entry.ExplicitLabelPhaseCount;
		Surface.FallbackLabelPhaseCount += Entry.FallbackLabelPhaseCount;
		if (Entry.bHasFallbackLabels)
		{
			++Surface.OptionsWithFallbackLabelCount;
		}
		if (Entry.bHasDuplicatePrunedPhases)
		{
			++Surface.OptionsWithDuplicatePruningCount;
		}
		if (Entry.bHasInvalidRawDefinitions)
		{
			++Surface.OptionsWithInvalidRawDefinitionsCount;
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactSplitPhaseNormalizationSummaryPreview =
				Entry.bHasExactNormalizationSummaryPreview;
			Surface.bCurrentSelectionRetainsActiveDeckSplitPhaseNormalizationSummary =
				Entry.bRetainsActiveDeckSplitPhaseNormalizationSummary;
			Surface.bCurrentSelectionHasFallbackLabels = Entry.bHasFallbackLabels;
			Surface.bCurrentSelectionHasDuplicatePrunedPhases =
				Entry.bHasDuplicatePrunedPhases;
			Surface.bCurrentSelectionHasInvalidRawDefinitions =
				Entry.bHasInvalidRawDefinitions;
			Surface.CurrentSelectionNormalizationSummaryLine = FString::Printf(
				TEXT("%s | %s | %s | %s | %s | %s"),
				*Entry.RawSplitPhaseCountLine,
				*Entry.SurvivorCountLine,
				*Entry.DuplicatePruningLine,
				*Entry.InvalidDefinitionLine,
				*Entry.LabelProvenanceLine,
				*BuildFallbackLine(Entry.FallbackPhaseIdLine)
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionSplitPhaseNormalizationSummaryPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectSplitPhaseNormalizationSummaryPreviewOptions =
		Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedSplitPhaseNormalizationSummaryPreviewOptions =
		Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedSplitPhaseNormalizationSummaryPreviewOptions =
		Surface.BlockedOptionCount > 0;

	Surface.NormalizationSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Split-phase normalization summary: %d raw definitions | %d survivors | %d duplicate-pruned | %d invalid | %d blocked | %d unavailable"),
			Surface.RawSplitPhaseDefinitionCount,
			Surface.SurvivorPhaseCount,
			Surface.DuplicatePrunedPhaseCount,
			Surface.InvalidRawDefinitionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Split-phase normalization summary: no imported options");
	Surface.LabelFallbackSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Label-fallback summary: %d explicit labels | %d phase-id fallbacks | %d options with fallback | %d options with duplicate-pruned rows | %d options with invalid rows"),
			Surface.ExplicitLabelPhaseCount,
			Surface.FallbackLabelPhaseCount,
			Surface.OptionsWithFallbackLabelCount,
			Surface.OptionsWithDuplicatePruningCount,
			Surface.OptionsWithInvalidRawDefinitionsCount
		)
		: TEXT("Label-fallback summary: no imported options");
	Surface.PreviewPostureSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Preview posture: %d direct exact | %d generated exact | %d blocked | %d unavailable"),
			Surface.DirectExactOptionCount,
			Surface.GeneratedExactOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Preview posture: no imported options");

	if (Surface.CurrentSelectionNormalizationSummaryLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionNormalizationSummaryLine =
				OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionNormalizationSummaryLine =
				TEXT("Current selection has no additional owned-execution split-phase normalization summary preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionNormalizationSummaryLine =
				TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionNormalizationSummaryLine =
				TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase normalization summary preview exposes %d direct exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase normalization summary preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = DuplicatePruningPreviewSurface.StatusLine;
	}

	Surface.DetailLine = !DuplicatePruningPreviewSurface.DetailLine.IsEmpty()
		? DuplicatePruningPreviewSurface.DetailLine
		: LabelProvenancePreviewSurface.DetailLine;

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseNormalizationSummaryPreviewSurface
		NormalizationSummaryPreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseNormalizationSummaryPreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface
		LabelProvenancePreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewSurface
		DuplicatePruningPreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewSurface
		Surface;
	Surface.SelectorId = NormalizationSummaryPreviewSurface.SelectorId;
	Surface.SelectorLabel = NormalizationSummaryPreviewSurface.SelectorLabel;
	Surface.BindingLabel = NormalizationSummaryPreviewSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Raw-Row/Normalized-Phase Fusion Preview");
	Surface.StatusLine = NormalizationSummaryPreviewSurface.StatusLine;
	Surface.NormalizationSummaryLine =
		NormalizationSummaryPreviewSurface.NormalizationSummaryLine;
	Surface.LabelFallbackSummaryLine =
		NormalizationSummaryPreviewSurface.LabelFallbackSummaryLine;
	Surface.PreviewPostureSummaryLine =
		NormalizationSummaryPreviewSurface.PreviewPostureSummaryLine;
	Surface.CurrentSelectionFusionLine =
		NormalizationSummaryPreviewSurface.CurrentSelectionNormalizationSummaryLine;
	Surface.DetailLine = NormalizationSummaryPreviewSurface.DetailLine;
	Surface.DirectExactOptionCount =
		NormalizationSummaryPreviewSurface.DirectExactOptionCount;
	Surface.GeneratedExactOptionCount =
		NormalizationSummaryPreviewSurface.GeneratedExactOptionCount;
	Surface.BlockedOptionCount =
		NormalizationSummaryPreviewSurface.BlockedOptionCount;
	Surface.UnavailableOptionCount =
		NormalizationSummaryPreviewSurface.UnavailableOptionCount;
	Surface.RawSplitPhaseDefinitionCount =
		NormalizationSummaryPreviewSurface.RawSplitPhaseDefinitionCount;
	Surface.SurvivorPhaseCount =
		NormalizationSummaryPreviewSurface.SurvivorPhaseCount;
	Surface.DuplicatePrunedPhaseCount =
		NormalizationSummaryPreviewSurface.DuplicatePrunedPhaseCount;
	Surface.InvalidRawDefinitionCount =
		NormalizationSummaryPreviewSurface.InvalidRawDefinitionCount;
	Surface.ExplicitLabelPhaseCount =
		NormalizationSummaryPreviewSurface.ExplicitLabelPhaseCount;
	Surface.FallbackLabelPhaseCount =
		NormalizationSummaryPreviewSurface.FallbackLabelPhaseCount;
	Surface.OptionsWithFallbackLabelCount =
		NormalizationSummaryPreviewSurface.OptionsWithFallbackLabelCount;
	Surface.OptionsWithDuplicatePruningCount =
		NormalizationSummaryPreviewSurface.OptionsWithDuplicatePruningCount;
	Surface.OptionsWithInvalidRawDefinitionsCount =
		NormalizationSummaryPreviewSurface.OptionsWithInvalidRawDefinitionsCount;
	Surface.bHasSelector = NormalizationSummaryPreviewSurface.bHasSelector;
	Surface.bHasOwnedExecutionSplitPhaseFusionPreviewOptions =
		NormalizationSummaryPreviewSurface
			.bHasOwnedExecutionSplitPhaseNormalizationSummaryPreviewOptions;
	Surface.bHasDirectSplitPhaseFusionPreviewOptions =
		NormalizationSummaryPreviewSurface
			.bHasDirectSplitPhaseNormalizationSummaryPreviewOptions;
	Surface.bHasGeneratedSplitPhaseFusionPreviewOptions =
		NormalizationSummaryPreviewSurface
			.bHasGeneratedSplitPhaseNormalizationSummaryPreviewOptions;
	Surface.bHasBlockedSplitPhaseFusionPreviewOptions =
		NormalizationSummaryPreviewSurface
			.bHasBlockedSplitPhaseNormalizationSummaryPreviewOptions;
	Surface.bCurrentSelectionHasExactSplitPhaseFusionPreview =
		NormalizationSummaryPreviewSurface
			.bCurrentSelectionHasExactSplitPhaseNormalizationSummaryPreview;
	Surface.bCurrentSelectionRetainsActiveDeckSplitPhaseFusion =
		NormalizationSummaryPreviewSurface
			.bCurrentSelectionRetainsActiveDeckSplitPhaseNormalizationSummary;
	Surface.bCurrentSelectionHasFallbackLabels =
		NormalizationSummaryPreviewSurface.bCurrentSelectionHasFallbackLabels;
	Surface.bCurrentSelectionHasDuplicatePrunedPhases =
		NormalizationSummaryPreviewSurface
			.bCurrentSelectionHasDuplicatePrunedPhases;
	Surface.bCurrentSelectionHasInvalidRawDefinitions =
		NormalizationSummaryPreviewSurface
			.bCurrentSelectionHasInvalidRawDefinitions;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Raw-Row/Normalized-Phase Fusion Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Raw-Row/Normalized-Phase Fusion Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	TMap<FString, int32> LabelEntryIndexByOptionId;
	for (int32 EntryIndex = 0;
		 EntryIndex < LabelProvenancePreviewSurface.OptionEntries.Num();
		 ++EntryIndex)
	{
		LabelEntryIndexByOptionId.FindOrAdd(
			LabelProvenancePreviewSurface.OptionEntries[EntryIndex].OptionId
		) = EntryIndex;
	}

	const auto BuildFusionUnavailableLabelLine = [](
		const FString& Reason
	) -> FString
	{
		return Reason.IsEmpty()
			? TEXT("Normalized label provenance on execute: unavailable")
			: Reason;
	};

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewEntrySurface&
		DuplicateEntry : DuplicatePruningPreviewSurface.OptionEntries)
	{
		const int32* LabelEntryIndex = LabelEntryIndexByOptionId.Find(
			DuplicateEntry.OptionId
		);
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewEntrySurface*
			LabelEntry = LabelEntryIndex != nullptr
				? &LabelProvenancePreviewSurface.OptionEntries[*LabelEntryIndex]
				: nullptr;

		TMap<FString, int32> LabelPhaseIndexByPhaseId;
		if (LabelEntry != nullptr)
		{
			for (int32 PhaseIndex = 0;
				 PhaseIndex < LabelEntry->PhaseEntries.Num();
				 ++PhaseIndex)
			{
				LabelPhaseIndexByPhaseId.FindOrAdd(
					LabelEntry->PhaseEntries[PhaseIndex].PhaseId
				) = PhaseIndex;
			}
		}

		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewEntrySurface
			Entry;
		Entry.OptionId = DuplicateEntry.OptionId;
		Entry.Label = DuplicateEntry.Label;
		Entry.OptionValue = DuplicateEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = DuplicateEntry.LaunchRequestPreviewKind;
		Entry.RawSplitPhaseCountLine = DuplicateEntry.RawSplitPhaseCountLine;
		Entry.SurvivorCountLine = DuplicateEntry.SurvivorCountLine;
		Entry.DuplicatePruningLine = DuplicateEntry.DuplicatePruningLine;
		Entry.InvalidDefinitionLine = DuplicateEntry.InvalidDefinitionLine;
		Entry.LabelProvenanceLine = LabelEntry != nullptr
			? LabelEntry->LabelProvenanceLine
			: TEXT("Label provenance on execute: unavailable");
		Entry.FallbackPhaseIdLine = LabelEntry != nullptr
			? LabelEntry->FallbackPhaseIdLine
			: TEXT("Phase-id fallback labels on execute: unavailable");
		Entry.RawSplitPhaseCount = DuplicateEntry.RawSplitPhaseCount;
		Entry.SurvivorPhaseCount = DuplicateEntry.SurvivorPhaseCount;
		Entry.DuplicatePrunedPhaseCount = DuplicateEntry.DuplicatePrunedPhaseCount;
		Entry.InvalidRawDefinitionCount = DuplicateEntry.InvalidRawDefinitionCount;
		Entry.ExplicitLabelPhaseCount = LabelEntry != nullptr
			? LabelEntry->ExplicitLabelPhaseCount
			: 0;
		Entry.FallbackLabelPhaseCount = LabelEntry != nullptr
			? LabelEntry->FallbackLabelPhaseCount
			: 0;
		Entry.bMatchesCurrentSelection = DuplicateEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately =
			DuplicateEntry.bStartsOwnedCaseImmediately;
		Entry.bHasExactFusionPreview =
			DuplicateEntry.bHasExactSplitPhaseDuplicatePruningPreview
			&& LabelEntry != nullptr
			&& LabelEntry->bHasExactSplitPhaseLabelProvenancePreview;
		Entry.bRetainsActiveDeckSplitPhaseFusion =
			DuplicateEntry.bRetainsActiveDeckSplitPhaseDuplicatePruningProvenance
			&& LabelEntry != nullptr
			&& LabelEntry->bRetainsActiveDeckSplitPhaseLabelProvenance;
		Entry.bHasFallbackLabels = LabelEntry != nullptr
			&& LabelEntry->bHasFallbackLabels;
		Entry.bHasDuplicatePrunedPhases =
			DuplicateEntry.bHasDuplicatePrunedPhases;
		Entry.bHasInvalidRawDefinitions =
			DuplicateEntry.bHasInvalidRawDefinitions;
		Entry.bPreviewBlocked = DuplicateEntry.bPreviewBlocked;
		Entry.bCanPreview = DuplicateEntry.bCanPreview;
		Entry.PreviewPostureLine = DuplicateEntry.SplitPhaseSourceLine.IsEmpty()
			? DuplicateEntry.PreviewStabilityLine
			: FString::Printf(
				TEXT("Preview posture on execute: %s | %s"),
				*DuplicateEntry.PreviewStabilityLine,
				*DuplicateEntry.SplitPhaseSourceLine
			);
		Entry.FusionSummaryLine = FString::Printf(
			TEXT("Raw-row / normalized-phase fusion on execute: %d raw rows | %d survivors | %d explicit labels | %d phase-id fallbacks"),
			Entry.RawSplitPhaseCount,
			Entry.SurvivorPhaseCount,
			Entry.ExplicitLabelPhaseCount,
			Entry.FallbackLabelPhaseCount
		);

		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseDuplicatePruningSurvivorProvenancePreviewRawPhaseEntrySurface&
			RawRow : DuplicateEntry.RawPhaseEntries)
		{
			FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewRowSurface
				FusedRow;
			FusedRow.PhaseId = RawRow.PhaseId;
			FusedRow.SourceLabel = RawRow.SourceLabel;
			FusedRow.RawOrder = RawRow.RawOrder;
			FusedRow.EvaluationOrder = RawRow.EvaluationOrder;
			FusedRow.NormalizedOrder = RawRow.NormalizedOrder;
			FusedRow.RawDefinitionLine = RawRow.RawDefinitionLine;
			FusedRow.NormalizationOutcomeLine = RawRow.NormalizationOutcomeLine;
			FusedRow.DuplicatePruningProvenanceLine =
				RawRow.DuplicatePruningProvenanceLine;
			FusedRow.bSourceLabelWasExplicit = RawRow.bSourceLabelWasExplicit;
			FusedRow.bSurvivesNormalization = RawRow.bSurvivesNormalization;
			FusedRow.bDroppedBecauseDuplicate = RawRow.bDroppedBecauseDuplicate;
			FusedRow.bDroppedBecauseInvalid = RawRow.bDroppedBecauseInvalid;
			FusedRow.bCanPreview = RawRow.bCanPreview;

			if (RawRow.bSurvivesNormalization
				&& LabelEntry != nullptr
				&& LabelPhaseIndexByPhaseId.Contains(RawRow.PhaseId))
			{
				const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhasePhaseIdLabelFallbackProvenancePreviewPhaseEntrySurface&
					LabelPhase =
						LabelEntry->PhaseEntries[LabelPhaseIndexByPhaseId[RawRow.PhaseId]];
				FusedRow.NormalizedOrder = LabelPhase.Order;
				FusedRow.NormalizedLabel = LabelPhase.NormalizedLabel;
				FusedRow.LabelProvenanceLine = LabelPhase.LabelProvenanceLine;
				FusedRow.bLabelFallsBackToPhaseId =
					LabelPhase.bLabelFallsBackToPhaseId;
				FusedRow.bHasNormalizedPhaseDetail = true;
				FusedRow.FusedRowLine = FString::Printf(
					TEXT("Raw row / normalized phase fusion on execute: evaluation #%d survives as normalized phase #%d with label %s (%s)."),
					FusedRow.EvaluationOrder,
					FusedRow.NormalizedOrder,
					*FusedRow.NormalizedLabel,
					*RawRow.PhaseId
				);
			}
			else if (RawRow.bSurvivesNormalization)
			{
				FusedRow.NormalizedLabel = RawRow.SurvivorNormalizedLabel;
				FusedRow.LabelProvenanceLine = RawRow.SourceLabel.IsEmpty()
					? FString::Printf(
						TEXT("Normalized label provenance on execute: phase-id fallback retained because the source label is empty (%s)"),
						*RawRow.PhaseId
					)
					: FString::Printf(
						TEXT("Normalized label provenance on execute: explicit source label retained (%s)"),
						*RawRow.SourceLabel
					);
				FusedRow.bLabelFallsBackToPhaseId = RawRow.SourceLabel.IsEmpty();
				FusedRow.bHasNormalizedPhaseDetail = !FusedRow.NormalizedLabel.IsEmpty();
				FusedRow.FusedRowLine = FString::Printf(
					TEXT("Raw row / normalized phase fusion on execute: evaluation #%d survives as normalized phase #%d with label %s (%s)."),
					FusedRow.EvaluationOrder,
					FusedRow.NormalizedOrder,
					*FusedRow.NormalizedLabel,
					*RawRow.PhaseId
				);
			}
			else if (RawRow.bDroppedBecauseDuplicate)
			{
				FusedRow.LabelProvenanceLine = FString::Printf(
					TEXT("Normalized label provenance on execute: unavailable for this raw row because phase id %s was duplicate-pruned before normalized phase detail was retained."),
					*RawRow.PhaseId
				);
				FusedRow.FusedRowLine = FString::Printf(
					TEXT("Raw row / normalized phase fusion on execute: evaluation #%d is duplicate-pruned, so fused normalized phase detail remains attached to the first valid surviving row for %s."),
					FusedRow.EvaluationOrder,
					*RawRow.PhaseId
				);
			}
			else if (RawRow.bDroppedBecauseInvalid)
			{
				FusedRow.LabelProvenanceLine =
					TEXT("Normalized label provenance on execute: unavailable for this raw row because structurally invalid definitions are skipped before normalized phase detail is retained.");
				FusedRow.FusedRowLine = FString::Printf(
					TEXT("Raw row / normalized phase fusion on execute: evaluation #%d never reaches normalized phase detail because the raw row is structurally invalid."),
					FusedRow.EvaluationOrder
				);
			}
			else
			{
				FusedRow.LabelProvenanceLine =
					BuildFusionUnavailableLabelLine(TEXT("Normalized label provenance on execute: unavailable"));
				FusedRow.FusedRowLine =
					TEXT("Raw row / normalized phase fusion on execute: unavailable");
			}

			FusedRow.DetailLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*FusedRow.NormalizationOutcomeLine,
				*FusedRow.LabelProvenanceLine,
				*FusedRow.FusedRowLine
			);
			Entry.FusedRows.Add(MoveTemp(FusedRow));
		}

		Entry.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*Entry.PreviewPostureLine,
			*Entry.FusionSummaryLine,
			*Entry.LabelProvenanceLine
		);
		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionCanonicalInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionCanonicalInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewSurface
		FusionPreviewSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionCanonicalInspectSurface
		Surface;
	Surface.SelectorId = FusionPreviewSurface.SelectorId;
	Surface.SelectorLabel = FusionPreviewSurface.SelectorLabel;
	Surface.BindingLabel = FusionPreviewSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Canonical Inspect");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;
	Surface.bHasSelection = OptionMenuSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		OptionMenuSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: OptionMenuSurface.SelectionLine;
	Surface.CurrentSelectionCanonicalInspectLine =
		FusionPreviewSurface.CurrentSelectionFusionLine;
	Surface.DetailLine = FusionPreviewSurface.DetailLine;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Canonical Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Canonical Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (Surface.CurrentSelectionSelectionLine.IsEmpty())
	{
		Surface.CurrentSelectionSelectionLine = OptionMenuSurface.bHasSelector
			? TEXT("Selection: unresolved")
			: TEXT("Selection: n/a");
	}

	if (Surface.CurrentSelectionCanonicalInspectLine.IsEmpty())
	{
		Surface.CurrentSelectionCanonicalInspectLine =
			OptionMenuSurface.bHasUnresolvedSelectionDetail
				? OptionMenuSurface.UnresolvedSelectionLine
				: OptionMenuSurface.bHasSelection
					? TEXT("Current selection has no additional owned-execution split-phase canonical inspect preview.")
					: OptionMenuSurface.bHasSelector
						? TEXT("Current selection: unresolved")
						: TEXT("Current selection: n/a");
	}

	if (OptionMenuSurface.bSelectionMatchesAvailableOption)
	{
		Surface.CurrentSelectionOptionId = OptionMenuSurface.MatchedOptionId;
		Surface.CurrentSelectionOptionLabel = OptionMenuSurface.MatchedOptionLabel;
		Surface.CurrentSelectionOptionValue = OptionMenuSurface.MatchedOptionValue;
	}

	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewEntrySurface*
		MatchingEntry = nullptr;
	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewEntrySurface&
		Entry : FusionPreviewSurface.OptionEntries)
	{
		if (Entry.bMatchesCurrentSelection)
		{
			MatchingEntry = &Entry;
			break;
		}
	}

	if (MatchingEntry != nullptr)
	{
		Surface.bHasCurrentSelectionCanonicalInspectEntry = true;
		Surface.CurrentSelectionOptionId = MatchingEntry->OptionId;
		Surface.CurrentSelectionOptionLabel = MatchingEntry->Label;
		Surface.CurrentSelectionOptionValue = MatchingEntry->OptionValue;
		Surface.LaunchRequestPreviewKind = MatchingEntry->LaunchRequestPreviewKind;
		Surface.RawSplitPhaseCountLine = MatchingEntry->RawSplitPhaseCountLine;
		Surface.SurvivorCountLine = MatchingEntry->SurvivorCountLine;
		Surface.DuplicatePruningLine = MatchingEntry->DuplicatePruningLine;
		Surface.InvalidDefinitionLine = MatchingEntry->InvalidDefinitionLine;
		Surface.LabelProvenanceLine = MatchingEntry->LabelProvenanceLine;
		Surface.FallbackPhaseIdLine = MatchingEntry->FallbackPhaseIdLine;
		Surface.FusionSummaryLine = MatchingEntry->FusionSummaryLine;
		Surface.PreviewPostureLine = MatchingEntry->PreviewPostureLine;
		Surface.FusedRows = MatchingEntry->FusedRows;
		Surface.RawSplitPhaseCount = MatchingEntry->RawSplitPhaseCount;
		Surface.SurvivorPhaseCount = MatchingEntry->SurvivorPhaseCount;
		Surface.DuplicatePrunedPhaseCount =
			MatchingEntry->DuplicatePrunedPhaseCount;
		Surface.InvalidRawDefinitionCount =
			MatchingEntry->InvalidRawDefinitionCount;
		Surface.ExplicitLabelPhaseCount =
			MatchingEntry->ExplicitLabelPhaseCount;
		Surface.FallbackLabelPhaseCount =
			MatchingEntry->FallbackLabelPhaseCount;
		Surface.bStartsOwnedCaseImmediately =
			MatchingEntry->bStartsOwnedCaseImmediately;
		Surface.bHasExactCurrentSelectionCanonicalInspect =
			MatchingEntry->bHasExactFusionPreview;
		Surface.bRetainsActiveDeckSplitPhaseFusion =
			MatchingEntry->bRetainsActiveDeckSplitPhaseFusion;
		Surface.bHasFallbackLabels = MatchingEntry->bHasFallbackLabels;
		Surface.bHasDuplicatePrunedPhases =
			MatchingEntry->bHasDuplicatePrunedPhases;
		Surface.bHasInvalidRawDefinitions =
			MatchingEntry->bHasInvalidRawDefinitions;
		Surface.bPreviewBlocked = MatchingEntry->bPreviewBlocked;
		Surface.bCanPreview = MatchingEntry->bCanPreview;
		Surface.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*Surface.CurrentSelectionSelectionLine,
			*Surface.CurrentSelectionCanonicalInspectLine,
			*Surface.PreviewPostureLine
		);

		if (Surface.bPreviewBlocked)
		{
			Surface.StatusLine =
				TEXT("Generated-mode selector option owned-execution split-phase current-selection canonical inspect resolves the active selection, but execute-time fused inspection remains blocked.");
		}
		else if (Surface.bCanPreview)
		{
			Surface.StatusLine = FString::Printf(
				TEXT("Generated-mode selector option owned-execution split-phase current-selection canonical inspect exposes %d fused row%s for the active selection."),
				Surface.FusedRows.Num(),
				Surface.FusedRows.Num() == 1 ? TEXT("") : TEXT("s")
			);
		}
		else
		{
			Surface.StatusLine =
				TEXT("Generated-mode selector option owned-execution split-phase current-selection canonical inspect resolves the active selection, but no fused rows are currently previewable.");
		}

		return Surface;
	}

	if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.PreviewPostureLine =
			TEXT("Preview posture on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection canonical inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.PreviewPostureLine =
			TEXT("Preview posture on execute: unavailable for the current selection.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection canonical inspect is active, but the current selection does not expose fused split-phase detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.PreviewPostureLine =
			TEXT("Preview posture on execute: unresolved");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection canonical inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.PreviewPostureLine = TEXT("Preview posture on execute: n/a");
		Surface.StatusLine = FusionPreviewSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionCanonicalInspectLine,
		*Surface.PreviewPostureLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionCanonicalInspectSurface
		CanonicalInspectSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionCanonicalInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface
		Surface;
	Surface.SelectorId = CanonicalInspectSurface.SelectorId;
	Surface.SelectorLabel = CanonicalInspectSurface.SelectorLabel;
	Surface.BindingLabel = CanonicalInspectSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Survivor-Phase Roster Inspect");
	Surface.bHasSelector = CanonicalInspectSurface.bHasSelector;
	Surface.bHasSelection = CanonicalInspectSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		CanonicalInspectSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		CanonicalInspectSurface.CurrentSelectionSelectionLine;
	Surface.CurrentSelectionOptionId =
		CanonicalInspectSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		CanonicalInspectSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		CanonicalInspectSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		CanonicalInspectSurface.LaunchRequestPreviewKind;
	Surface.bStartsOwnedCaseImmediately =
		CanonicalInspectSurface.bStartsOwnedCaseImmediately;
	Surface.bHasExactCurrentSelectionSurvivorPhaseRoster =
		CanonicalInspectSurface.bHasExactCurrentSelectionCanonicalInspect;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		CanonicalInspectSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bPreviewBlocked = CanonicalInspectSurface.bPreviewBlocked;
	Surface.bCanPreview = CanonicalInspectSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Survivor-Phase Roster Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Survivor-Phase Roster Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewRowSurface&
		FusedRow : CanonicalInspectSurface.FusedRows)
	{
		if (!FusedRow.bSurvivesNormalization || !FusedRow.bHasNormalizedPhaseDetail)
		{
			continue;
		}

		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectPhaseSurface
			PhaseSurface;
		PhaseSurface.PhaseId = FusedRow.PhaseId;
		PhaseSurface.SourceLabel = FusedRow.SourceLabel;
		PhaseSurface.NormalizedLabel = FusedRow.NormalizedLabel;
		PhaseSurface.EvaluationOrder = FusedRow.EvaluationOrder;
		PhaseSurface.NormalizedOrder = FusedRow.NormalizedOrder;
		PhaseSurface.LabelProvenanceLine = FusedRow.LabelProvenanceLine;
		PhaseSurface.bSourceLabelWasExplicit = FusedRow.bSourceLabelWasExplicit;
		PhaseSurface.bLabelFallsBackToPhaseId =
			FusedRow.bLabelFallsBackToPhaseId;
		PhaseSurface.bCanPreview = FusedRow.bCanPreview;
		PhaseSurface.OrderLine = FusedRow.NormalizedOrder >= 0
			? FString::Printf(
				TEXT("Normalized survivor-phase order on execute: #%d"),
				FusedRow.NormalizedOrder
			)
			: TEXT("Normalized survivor-phase order on execute: unavailable");
		PhaseSurface.LabelLine = FString::Printf(
			TEXT("Normalized survivor-phase label on execute: %s (%s)"),
			*FusedRow.NormalizedLabel,
			*FusedRow.PhaseId
		);
		PhaseSurface.SurvivorRosterLine = FString::Printf(
			TEXT("Current-selection survivor-phase roster on execute: evaluation #%d survives as normalized phase #%d with label %s (%s)."),
			FusedRow.EvaluationOrder,
			FusedRow.NormalizedOrder,
			*FusedRow.NormalizedLabel,
			*FusedRow.PhaseId
		);
		PhaseSurface.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*PhaseSurface.OrderLine,
			*PhaseSurface.LabelProvenanceLine,
			*PhaseSurface.SurvivorRosterLine
		);
		Surface.SurvivorPhases.Add(MoveTemp(PhaseSurface));
	}

	Surface.SurvivorPhaseCount = Surface.SurvivorPhases.Num();
	Surface.bHasCurrentSelectionSurvivorPhaseRoster =
		Surface.SurvivorPhaseCount > 0;

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectPhaseSurface&
		PhaseSurface : Surface.SurvivorPhases)
	{
		if (PhaseSurface.bLabelFallsBackToPhaseId)
		{
			++Surface.FallbackLabelPhaseCount;
		}
		else
		{
			++Surface.ExplicitLabelPhaseCount;
		}
	}
	Surface.bHasFallbackLabels = Surface.FallbackLabelPhaseCount > 0;

	Surface.SurvivorPhaseCountLine = Surface.bHasCurrentSelectionSurvivorPhaseRoster
		? FString::Printf(
			TEXT("Current-selection surviving normalized phases on execute: %d retained phase%s"),
			Surface.SurvivorPhaseCount,
			Surface.SurvivorPhaseCount == 1 ? TEXT("") : TEXT("s")
		)
		: (CanonicalInspectSurface.bHasCurrentSelectionCanonicalInspectEntry
			&& !CanonicalInspectSurface.bPreviewBlocked
			? TEXT("Current-selection surviving normalized phases on execute: none")
			: TEXT("Current-selection surviving normalized phases on execute: unavailable"));

	if (Surface.SurvivorPhases.Num() > 0)
	{
		TArray<FString> OrderedPhaseLabels;
		OrderedPhaseLabels.Reserve(Surface.SurvivorPhases.Num());
		TArray<FString> NormalizedLabels;
		NormalizedLabels.Reserve(Surface.SurvivorPhases.Num());
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectPhaseSurface&
			PhaseSurface : Surface.SurvivorPhases)
		{
			OrderedPhaseLabels.Add(
				FString::Printf(TEXT("#%d %s"), PhaseSurface.NormalizedOrder, *PhaseSurface.NormalizedLabel)
			);
			NormalizedLabels.Add(
				FString::Printf(TEXT("%s (%s)"), *PhaseSurface.NormalizedLabel, *PhaseSurface.PhaseId)
			);
		}

		Surface.OrderSummaryLine = FString::Printf(
			TEXT("Current-selection normalized survivor-phase order on execute: %s"),
			*FString::Join(OrderedPhaseLabels, TEXT(" | "))
		);
		Surface.LabelSummaryLine = FString::Printf(
			TEXT("Current-selection normalized survivor-phase labels on execute: %s"),
			*FString::Join(NormalizedLabels, TEXT(", "))
		);
		Surface.CurrentSelectionSurvivorRosterLine = FString::Printf(
			TEXT("%s | %d explicit labels | %d phase-id fallbacks"),
			*Surface.SurvivorPhaseCountLine,
			Surface.ExplicitLabelPhaseCount,
			Surface.FallbackLabelPhaseCount
		);
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.OrderSummaryLine = TEXT("Current-selection normalized survivor-phase order on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.LabelSummaryLine = TEXT("Current-selection normalized survivor-phase labels on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.CurrentSelectionSurvivorRosterLine =
			OptionMenuSurface.UnresolvedSelectionLine;
	}
	else if (CanonicalInspectSurface.bPreviewBlocked)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection normalized survivor-phase order on execute: blocked until execute-time fused inspection is available.");
		Surface.LabelSummaryLine =
			TEXT("Current-selection normalized survivor-phase labels on execute: blocked until execute-time fused inspection is available.");
		Surface.CurrentSelectionSurvivorRosterLine =
			CanonicalInspectSurface.CurrentSelectionCanonicalInspectLine;
	}
	else if (CanonicalInspectSurface.bHasCurrentSelectionCanonicalInspectEntry)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection normalized survivor-phase order on execute: none");
		Surface.LabelSummaryLine =
			TEXT("Current-selection normalized survivor-phase labels on execute: none");
		Surface.CurrentSelectionSurvivorRosterLine =
			TEXT("Current-selection survivor-phase roster on execute: none");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection normalized survivor-phase order on execute: unavailable");
		Surface.LabelSummaryLine =
			TEXT("Current-selection normalized survivor-phase labels on execute: unavailable");
		Surface.CurrentSelectionSurvivorRosterLine =
			TEXT("Current selection has no additional owned-execution split-phase survivor-phase roster preview.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection normalized survivor-phase order on execute: unresolved");
		Surface.LabelSummaryLine =
			TEXT("Current-selection normalized survivor-phase labels on execute: unresolved");
		Surface.CurrentSelectionSurvivorRosterLine =
			TEXT("Current selection: unresolved");
	}
	else
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection normalized survivor-phase order on execute: n/a");
		Surface.LabelSummaryLine =
			TEXT("Current-selection normalized survivor-phase labels on execute: n/a");
		Surface.CurrentSelectionSurvivorRosterLine =
			TEXT("Current selection: n/a");
	}

	if (Surface.bHasCurrentSelectionSurvivorPhaseRoster)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection survivor-phase roster inspect exposes %d surviving normalized phase%s for the active selection."),
			Surface.SurvivorPhaseCount,
			Surface.SurvivorPhaseCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection survivor-phase roster inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (CanonicalInspectSurface.bPreviewBlocked)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection survivor-phase roster inspect resolves the active selection, but execute-time survivor-phase inspection remains blocked.");
	}
	else if (CanonicalInspectSurface.bHasCurrentSelectionCanonicalInspectEntry)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection survivor-phase roster inspect resolves the active selection, but no normalized surviving phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection survivor-phase roster inspect is active, but the current selection does not expose survivor-phase detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection survivor-phase roster inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.StatusLine = CanonicalInspectSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionSurvivorRosterLine,
		*Surface.OrderSummaryLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionDroppedRowAuditInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionDroppedRowAuditInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionCanonicalInspectSurface
		CanonicalInspectSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionCanonicalInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionDroppedRowAuditInspectSurface
		Surface;
	Surface.SelectorId = CanonicalInspectSurface.SelectorId;
	Surface.SelectorLabel = CanonicalInspectSurface.SelectorLabel;
	Surface.BindingLabel = CanonicalInspectSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Dropped-Row Audit Inspect");
	Surface.bHasSelector = CanonicalInspectSurface.bHasSelector;
	Surface.bHasSelection = CanonicalInspectSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		CanonicalInspectSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		CanonicalInspectSurface.CurrentSelectionSelectionLine;
	Surface.CurrentSelectionOptionId =
		CanonicalInspectSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		CanonicalInspectSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		CanonicalInspectSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		CanonicalInspectSurface.LaunchRequestPreviewKind;
	Surface.DuplicatePruningLine =
		CanonicalInspectSurface.DuplicatePruningLine;
	Surface.InvalidDefinitionLine =
		CanonicalInspectSurface.InvalidDefinitionLine;
	Surface.PreviewPostureLine =
		CanonicalInspectSurface.PreviewPostureLine;
	Surface.bStartsOwnedCaseImmediately =
		CanonicalInspectSurface.bStartsOwnedCaseImmediately;
	Surface.bHasExactCurrentSelectionDroppedRowAudit =
		CanonicalInspectSurface.bHasExactCurrentSelectionCanonicalInspect;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		CanonicalInspectSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bHasDuplicatePrunedRows =
		CanonicalInspectSurface.bHasDuplicatePrunedPhases;
	Surface.bHasInvalidRawRows =
		CanonicalInspectSurface.bHasInvalidRawDefinitions;
	Surface.bPreviewBlocked = CanonicalInspectSurface.bPreviewBlocked;
	Surface.bCanPreview = CanonicalInspectSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Dropped-Row Audit Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Dropped-Row Audit Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseRawRowNormalizedPhaseFusionPreviewRowSurface&
		FusedRow : CanonicalInspectSurface.FusedRows)
	{
		if (!FusedRow.bDroppedBecauseDuplicate && !FusedRow.bDroppedBecauseInvalid)
		{
			continue;
		}

		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionDroppedRowAuditInspectRowSurface
			RowSurface;
		RowSurface.PhaseId = FusedRow.PhaseId;
		RowSurface.SourceLabel = FusedRow.SourceLabel;
		RowSurface.RawOrder = FusedRow.RawOrder;
		RowSurface.EvaluationOrder = FusedRow.EvaluationOrder;
		RowSurface.RawDefinitionLine = FusedRow.RawDefinitionLine;
		RowSurface.NormalizationOutcomeLine = FusedRow.NormalizationOutcomeLine;
		RowSurface.DuplicatePruningProvenanceLine =
			FusedRow.DuplicatePruningProvenanceLine;
		RowSurface.LabelProvenanceLine = FusedRow.LabelProvenanceLine;
		RowSurface.bSourceLabelWasExplicit = FusedRow.bSourceLabelWasExplicit;
		RowSurface.bDroppedBecauseDuplicate =
			FusedRow.bDroppedBecauseDuplicate;
		RowSurface.bDroppedBecauseInvalid =
			FusedRow.bDroppedBecauseInvalid;
		RowSurface.bCanPreview = FusedRow.bCanPreview;

		if (RowSurface.bDroppedBecauseDuplicate)
		{
			RowSurface.DroppedRowAuditLine = FString::Printf(
				TEXT("Current-selection dropped-row audit on execute: evaluation #%d for phase id %s is duplicate-pruned before normalized phase detail is retained."),
				RowSurface.EvaluationOrder,
				*RowSurface.PhaseId
			);
		}
		else
		{
			RowSurface.DroppedRowAuditLine = FString::Printf(
				TEXT("Current-selection dropped-row audit on execute: evaluation #%d never reaches normalized phase detail because the raw row is structurally invalid."),
				RowSurface.EvaluationOrder
			);
		}

		RowSurface.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*RowSurface.NormalizationOutcomeLine,
			*RowSurface.LabelProvenanceLine,
			*RowSurface.DroppedRowAuditLine
		);
		Surface.DroppedRows.Add(MoveTemp(RowSurface));
	}

	Surface.DroppedRowCount = Surface.DroppedRows.Num();
	Surface.bHasCurrentSelectionDroppedRowAudit =
		Surface.DroppedRowCount > 0;

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionDroppedRowAuditInspectRowSurface&
		RowSurface : Surface.DroppedRows)
	{
		if (RowSurface.bDroppedBecauseDuplicate)
		{
			++Surface.DuplicatePrunedRowCount;
		}
		if (RowSurface.bDroppedBecauseInvalid)
		{
			++Surface.InvalidRawRowCount;
		}
	}

	Surface.DroppedRowCountLine = Surface.bHasCurrentSelectionDroppedRowAudit
		? FString::Printf(
			TEXT("Current-selection dropped raw rows on execute: %d row%s"),
			Surface.DroppedRowCount,
			Surface.DroppedRowCount == 1 ? TEXT("") : TEXT("s")
		)
		: (CanonicalInspectSurface.bHasCurrentSelectionCanonicalInspectEntry
			&& !CanonicalInspectSurface.bPreviewBlocked
			? TEXT("Current-selection dropped raw rows on execute: none")
			: TEXT("Current-selection dropped raw rows on execute: unavailable"));

	if (Surface.DroppedRows.Num() > 0)
	{
		Surface.CurrentSelectionDroppedRowAuditLine = FString::Printf(
			TEXT("%s | %d duplicate-pruned | %d invalid"),
			*Surface.DroppedRowCountLine,
			Surface.DuplicatePrunedRowCount,
			Surface.InvalidRawRowCount
		);
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.CurrentSelectionDroppedRowAuditLine =
			OptionMenuSurface.UnresolvedSelectionLine;
	}
	else if (CanonicalInspectSurface.bPreviewBlocked)
	{
		Surface.CurrentSelectionDroppedRowAuditLine =
			CanonicalInspectSurface.CurrentSelectionCanonicalInspectLine;
	}
	else if (CanonicalInspectSurface.bHasCurrentSelectionCanonicalInspectEntry)
	{
		Surface.CurrentSelectionDroppedRowAuditLine =
			TEXT("Current-selection dropped-row audit on execute: none");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.CurrentSelectionDroppedRowAuditLine =
			TEXT("Current selection has no additional owned-execution split-phase dropped-row audit preview.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.CurrentSelectionDroppedRowAuditLine =
			TEXT("Current selection: unresolved");
	}
	else
	{
		Surface.CurrentSelectionDroppedRowAuditLine =
			TEXT("Current selection: n/a");
	}

	if (Surface.bHasCurrentSelectionDroppedRowAudit)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection dropped-row audit inspect exposes %d dropped raw row%s for the active selection."),
			Surface.DroppedRowCount,
			Surface.DroppedRowCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection dropped-row audit inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (CanonicalInspectSurface.bPreviewBlocked)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection dropped-row audit inspect resolves the active selection, but execute-time dropped-row inspection remains blocked.");
	}
	else if (CanonicalInspectSurface.bHasCurrentSelectionCanonicalInspectEntry)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection dropped-row audit inspect resolves the active selection, and no dropped raw rows are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection dropped-row audit inspect is active, but the current selection does not expose dropped-row detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection dropped-row audit inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.StatusLine = CanonicalInspectSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionDroppedRowAuditLine,
		*Surface.DroppedRowCountLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface
		SurvivorRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectSurface
		Surface;
	Surface.SelectorId = SurvivorRosterSurface.SelectorId;
	Surface.SelectorLabel = SurvivorRosterSurface.SelectorLabel;
	Surface.BindingLabel = SurvivorRosterSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Phase-Id Fallback Roster Inspect");
	Surface.bHasSelector = SurvivorRosterSurface.bHasSelector;
	Surface.bHasSelection = SurvivorRosterSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		SurvivorRosterSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		SurvivorRosterSurface.CurrentSelectionSelectionLine;
	Surface.CurrentSelectionOptionId =
		SurvivorRosterSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		SurvivorRosterSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		SurvivorRosterSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		SurvivorRosterSurface.LaunchRequestPreviewKind;
	Surface.bStartsOwnedCaseImmediately =
		SurvivorRosterSurface.bStartsOwnedCaseImmediately;
	Surface.bHasExactCurrentSelectionPhaseIdFallbackRoster =
		SurvivorRosterSurface.bHasExactCurrentSelectionSurvivorPhaseRoster;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		SurvivorRosterSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bPreviewBlocked = SurvivorRosterSurface.bPreviewBlocked;
	Surface.bCanPreview = SurvivorRosterSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Phase-Id Fallback Roster Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Phase-Id Fallback Roster Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectPhaseSurface&
		SurvivorPhase : SurvivorRosterSurface.SurvivorPhases)
	{
		if (!SurvivorPhase.bLabelFallsBackToPhaseId)
		{
			continue;
		}

		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectPhaseSurface
			PhaseSurface;
		PhaseSurface.PhaseId = SurvivorPhase.PhaseId;
		PhaseSurface.SourceLabel = SurvivorPhase.SourceLabel;
		PhaseSurface.NormalizedLabel = SurvivorPhase.NormalizedLabel;
		PhaseSurface.EvaluationOrder = SurvivorPhase.EvaluationOrder;
		PhaseSurface.NormalizedOrder = SurvivorPhase.NormalizedOrder;
		PhaseSurface.OrderLine = SurvivorPhase.OrderLine;
		PhaseSurface.LabelLine = SurvivorPhase.LabelLine;
		PhaseSurface.LabelProvenanceLine = SurvivorPhase.LabelProvenanceLine;
		PhaseSurface.PhaseIdFallbackRosterLine = FString::Printf(
			TEXT("Current-selection phase-id fallback roster on execute: evaluation #%d survives as normalized phase #%d with phase-id fallback label %s (%s)."),
			SurvivorPhase.EvaluationOrder,
			SurvivorPhase.NormalizedOrder,
			*SurvivorPhase.NormalizedLabel,
			*SurvivorPhase.PhaseId
		);
		PhaseSurface.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*PhaseSurface.OrderLine,
			*PhaseSurface.LabelProvenanceLine,
			*PhaseSurface.PhaseIdFallbackRosterLine
		);
		PhaseSurface.bCanPreview = SurvivorPhase.bCanPreview;
		Surface.FallbackPhases.Add(MoveTemp(PhaseSurface));
	}

	Surface.FallbackPhaseCount = Surface.FallbackPhases.Num();
	Surface.bHasCurrentSelectionPhaseIdFallbackRoster =
		Surface.FallbackPhaseCount > 0;

	Surface.FallbackPhaseCountLine = Surface.bHasCurrentSelectionPhaseIdFallbackRoster
		? FString::Printf(
			TEXT("Current-selection phase-id fallback phases on execute: %d retained phase%s"),
			Surface.FallbackPhaseCount,
			Surface.FallbackPhaseCount == 1 ? TEXT("") : TEXT("s")
		)
		: (SurvivorRosterSurface.bHasCurrentSelectionSurvivorPhaseRoster
			&& !SurvivorRosterSurface.bPreviewBlocked
			? TEXT("Current-selection phase-id fallback phases on execute: none")
			: TEXT("Current-selection phase-id fallback phases on execute: unavailable"));

	if (Surface.FallbackPhases.Num() > 0)
	{
		TArray<FString> OrderedPhaseLabels;
		OrderedPhaseLabels.Reserve(Surface.FallbackPhases.Num());
		TArray<FString> NormalizedLabels;
		NormalizedLabels.Reserve(Surface.FallbackPhases.Num());
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectPhaseSurface&
			PhaseSurface : Surface.FallbackPhases)
		{
			OrderedPhaseLabels.Add(
				FString::Printf(TEXT("#%d %s"), PhaseSurface.NormalizedOrder, *PhaseSurface.NormalizedLabel)
			);
			NormalizedLabels.Add(
				FString::Printf(TEXT("%s (%s)"), *PhaseSurface.NormalizedLabel, *PhaseSurface.PhaseId)
			);
		}

		Surface.OrderSummaryLine = FString::Printf(
			TEXT("Current-selection phase-id fallback order on execute: %s"),
			*FString::Join(OrderedPhaseLabels, TEXT(" | "))
		);
		Surface.LabelSummaryLine = FString::Printf(
			TEXT("Current-selection phase-id fallback labels on execute: %s"),
			*FString::Join(NormalizedLabels, TEXT(", "))
		);
		Surface.CurrentSelectionPhaseIdFallbackRosterLine = Surface.FallbackPhaseCountLine;
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.LabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.CurrentSelectionPhaseIdFallbackRosterLine =
			OptionMenuSurface.UnresolvedSelectionLine;
	}
	else if (SurvivorRosterSurface.bPreviewBlocked)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: blocked until execute-time survivor-phase inspection is available.");
		Surface.LabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: blocked until execute-time survivor-phase inspection is available.");
		Surface.CurrentSelectionPhaseIdFallbackRosterLine =
			SurvivorRosterSurface.CurrentSelectionSurvivorRosterLine;
	}
	else if (SurvivorRosterSurface.bHasCurrentSelectionSurvivorPhaseRoster)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: none");
		Surface.LabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: none");
		Surface.CurrentSelectionPhaseIdFallbackRosterLine =
			TEXT("Current-selection phase-id fallback roster on execute: none");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: unavailable");
		Surface.LabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: unavailable");
		Surface.CurrentSelectionPhaseIdFallbackRosterLine =
			TEXT("Current selection has no additional owned-execution split-phase phase-id fallback roster preview.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: unresolved");
		Surface.LabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: unresolved");
		Surface.CurrentSelectionPhaseIdFallbackRosterLine =
			TEXT("Current selection: unresolved");
	}
	else
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: n/a");
		Surface.LabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: n/a");
		Surface.CurrentSelectionPhaseIdFallbackRosterLine =
			TEXT("Current selection: n/a");
	}

	if (Surface.bHasCurrentSelectionPhaseIdFallbackRoster)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection phase-id fallback roster inspect exposes %d fallback phase%s for the active selection."),
			Surface.FallbackPhaseCount,
			Surface.FallbackPhaseCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection phase-id fallback roster inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (SurvivorRosterSurface.bPreviewBlocked)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection phase-id fallback roster inspect resolves the active selection, but execute-time fallback-phase inspection remains blocked.");
	}
	else if (SurvivorRosterSurface.bHasCurrentSelectionSurvivorPhaseRoster)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection phase-id fallback roster inspect resolves the active selection, and no phase-id fallback phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection phase-id fallback roster inspect is active, but the current selection does not expose fallback-phase detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection phase-id fallback roster inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.StatusLine = SurvivorRosterSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionPhaseIdFallbackRosterLine,
		*Surface.OrderSummaryLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface
		SurvivorRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectSurface
		Surface;
	Surface.SelectorId = SurvivorRosterSurface.SelectorId;
	Surface.SelectorLabel = SurvivorRosterSurface.SelectorLabel;
	Surface.BindingLabel = SurvivorRosterSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Explicit-Label Roster Inspect");
	Surface.bHasSelector = SurvivorRosterSurface.bHasSelector;
	Surface.bHasSelection = SurvivorRosterSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		SurvivorRosterSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		SurvivorRosterSurface.CurrentSelectionSelectionLine;
	Surface.CurrentSelectionOptionId =
		SurvivorRosterSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		SurvivorRosterSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		SurvivorRosterSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		SurvivorRosterSurface.LaunchRequestPreviewKind;
	Surface.bStartsOwnedCaseImmediately =
		SurvivorRosterSurface.bStartsOwnedCaseImmediately;
	Surface.bHasExactCurrentSelectionExplicitLabelRoster =
		SurvivorRosterSurface.bHasExactCurrentSelectionSurvivorPhaseRoster;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		SurvivorRosterSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bPreviewBlocked = SurvivorRosterSurface.bPreviewBlocked;
	Surface.bCanPreview = SurvivorRosterSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Explicit-Label Roster Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Explicit-Label Roster Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectPhaseSurface&
		SurvivorPhase : SurvivorRosterSurface.SurvivorPhases)
	{
		if (SurvivorPhase.bLabelFallsBackToPhaseId)
		{
			continue;
		}

		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectPhaseSurface
			PhaseSurface;
		PhaseSurface.PhaseId = SurvivorPhase.PhaseId;
		PhaseSurface.SourceLabel = SurvivorPhase.SourceLabel;
		PhaseSurface.NormalizedLabel = SurvivorPhase.NormalizedLabel;
		PhaseSurface.EvaluationOrder = SurvivorPhase.EvaluationOrder;
		PhaseSurface.NormalizedOrder = SurvivorPhase.NormalizedOrder;
		PhaseSurface.OrderLine = SurvivorPhase.OrderLine;
		PhaseSurface.LabelLine = SurvivorPhase.LabelLine;
		PhaseSurface.LabelProvenanceLine = SurvivorPhase.LabelProvenanceLine;
		PhaseSurface.ExplicitLabelRosterLine = FString::Printf(
			TEXT("Current-selection explicit-label roster on execute: evaluation #%d survives as normalized phase #%d with explicit label %s (%s)."),
			SurvivorPhase.EvaluationOrder,
			SurvivorPhase.NormalizedOrder,
			*SurvivorPhase.NormalizedLabel,
			*SurvivorPhase.PhaseId
		);
		PhaseSurface.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*PhaseSurface.OrderLine,
			*PhaseSurface.LabelProvenanceLine,
			*PhaseSurface.ExplicitLabelRosterLine
		);
		PhaseSurface.bCanPreview = SurvivorPhase.bCanPreview;
		Surface.ExplicitLabelPhases.Add(MoveTemp(PhaseSurface));
	}

	Surface.ExplicitLabelPhaseCount = Surface.ExplicitLabelPhases.Num();
	Surface.bHasCurrentSelectionExplicitLabelRoster =
		Surface.ExplicitLabelPhaseCount > 0;

	Surface.ExplicitLabelPhaseCountLine = Surface.bHasCurrentSelectionExplicitLabelRoster
		? FString::Printf(
			TEXT("Current-selection explicit-label phases on execute: %d retained phase%s"),
			Surface.ExplicitLabelPhaseCount,
			Surface.ExplicitLabelPhaseCount == 1 ? TEXT("") : TEXT("s")
		)
		: (SurvivorRosterSurface.bHasCurrentSelectionSurvivorPhaseRoster
			&& !SurvivorRosterSurface.bPreviewBlocked
			? TEXT("Current-selection explicit-label phases on execute: none")
			: TEXT("Current-selection explicit-label phases on execute: unavailable"));

	if (Surface.ExplicitLabelPhases.Num() > 0)
	{
		TArray<FString> OrderedPhaseLabels;
		OrderedPhaseLabels.Reserve(Surface.ExplicitLabelPhases.Num());
		TArray<FString> NormalizedLabels;
		NormalizedLabels.Reserve(Surface.ExplicitLabelPhases.Num());
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectPhaseSurface&
			PhaseSurface : Surface.ExplicitLabelPhases)
		{
			OrderedPhaseLabels.Add(
				FString::Printf(TEXT("#%d %s"), PhaseSurface.NormalizedOrder, *PhaseSurface.NormalizedLabel)
			);
			NormalizedLabels.Add(
				FString::Printf(TEXT("%s (%s)"), *PhaseSurface.NormalizedLabel, *PhaseSurface.PhaseId)
			);
		}

		Surface.OrderSummaryLine = FString::Printf(
			TEXT("Current-selection explicit-label order on execute: %s"),
			*FString::Join(OrderedPhaseLabels, TEXT(" | "))
		);
		Surface.LabelSummaryLine = FString::Printf(
			TEXT("Current-selection explicit labels on execute: %s"),
			*FString::Join(NormalizedLabels, TEXT(", "))
		);
		Surface.CurrentSelectionExplicitLabelRosterLine =
			Surface.ExplicitLabelPhaseCountLine;
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.LabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.CurrentSelectionExplicitLabelRosterLine =
			OptionMenuSurface.UnresolvedSelectionLine;
	}
	else if (SurvivorRosterSurface.bPreviewBlocked)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: blocked until execute-time survivor-phase inspection is available.");
		Surface.LabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: blocked until execute-time survivor-phase inspection is available.");
		Surface.CurrentSelectionExplicitLabelRosterLine =
			SurvivorRosterSurface.CurrentSelectionSurvivorRosterLine;
	}
	else if (SurvivorRosterSurface.bHasCurrentSelectionSurvivorPhaseRoster)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: none");
		Surface.LabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: none");
		Surface.CurrentSelectionExplicitLabelRosterLine =
			TEXT("Current-selection explicit-label roster on execute: none");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: unavailable");
		Surface.LabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: unavailable");
		Surface.CurrentSelectionExplicitLabelRosterLine =
			TEXT("Current selection has no additional owned-execution split-phase explicit-label roster preview.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: unresolved");
		Surface.LabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: unresolved");
		Surface.CurrentSelectionExplicitLabelRosterLine =
			TEXT("Current selection: unresolved");
	}
	else
	{
		Surface.OrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: n/a");
		Surface.LabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: n/a");
		Surface.CurrentSelectionExplicitLabelRosterLine =
			TEXT("Current selection: n/a");
	}

	if (Surface.bHasCurrentSelectionExplicitLabelRoster)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection explicit-label roster inspect exposes %d explicit-label phase%s for the active selection."),
			Surface.ExplicitLabelPhaseCount,
			Surface.ExplicitLabelPhaseCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection explicit-label roster inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (SurvivorRosterSurface.bPreviewBlocked)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection explicit-label roster inspect resolves the active selection, but execute-time explicit-label inspection remains blocked.");
	}
	else if (SurvivorRosterSurface.bHasCurrentSelectionSurvivorPhaseRoster)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection explicit-label roster inspect resolves the active selection, and no explicit-label phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection explicit-label roster inspect is active, but the current selection does not expose explicit-label detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection explicit-label roster inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.StatusLine = SurvivorRosterSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionExplicitLabelRosterLine,
		*Surface.OrderSummaryLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionSummaryInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionSummaryInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface
		SurvivorRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionSurvivorPhaseRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectSurface
		FallbackRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectSurface
		ExplicitLabelRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionSummaryInspectSurface
		Surface;
	Surface.SelectorId = SurvivorRosterSurface.SelectorId;
	Surface.SelectorLabel = SurvivorRosterSurface.SelectorLabel;
	Surface.BindingLabel = SurvivorRosterSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Summary Inspect");
	Surface.bHasSelector = SurvivorRosterSurface.bHasSelector;
	Surface.bHasSelection = SurvivorRosterSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		SurvivorRosterSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		SurvivorRosterSurface.CurrentSelectionSelectionLine;
	Surface.CurrentSelectionOptionId =
		SurvivorRosterSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		SurvivorRosterSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		SurvivorRosterSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		SurvivorRosterSurface.LaunchRequestPreviewKind;
	Surface.ExplicitLabelPhaseCount =
		ExplicitLabelRosterSurface.ExplicitLabelPhaseCount;
	Surface.FallbackPhaseCount =
		FallbackRosterSurface.FallbackPhaseCount;
	Surface.bStartsOwnedCaseImmediately =
		SurvivorRosterSurface.bStartsOwnedCaseImmediately;
	Surface.bHasExactCurrentSelectionLabelProvenancePartitionSummary =
		SurvivorRosterSurface.bHasExactCurrentSelectionSurvivorPhaseRoster;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		SurvivorRosterSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bHasExplicitLabelPartition = Surface.ExplicitLabelPhaseCount > 0;
	Surface.bHasFallbackLabelPartition = Surface.FallbackPhaseCount > 0;
	Surface.bHasMixedLabelProvenancePartition =
		Surface.bHasExplicitLabelPartition && Surface.bHasFallbackLabelPartition;
	Surface.bHasCurrentSelectionLabelProvenancePartitionSummary =
		SurvivorRosterSurface.bHasCurrentSelectionSurvivorPhaseRoster;
	Surface.bPreviewBlocked = SurvivorRosterSurface.bPreviewBlocked;
	Surface.bCanPreview = SurvivorRosterSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Summary Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Summary Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (Surface.bHasCurrentSelectionLabelProvenancePartitionSummary)
	{
		Surface.CurrentSelectionLabelProvenancePartitionSummaryLine = FString::Printf(
			TEXT("Current-selection label-provenance partition on execute: %d explicit-label phase%s | %d phase-id fallback phase%s"),
			Surface.ExplicitLabelPhaseCount,
			Surface.ExplicitLabelPhaseCount == 1 ? TEXT("") : TEXT("s"),
			Surface.FallbackPhaseCount,
			Surface.FallbackPhaseCount == 1 ? TEXT("") : TEXT("s")
		);
		Surface.ExplicitLabelPhaseCountLine =
			Surface.bHasExplicitLabelPartition
				? ExplicitLabelRosterSurface.ExplicitLabelPhaseCountLine
				: TEXT("Current-selection explicit-label phases on execute: none");
		Surface.FallbackPhaseCountLine =
			Surface.bHasFallbackLabelPartition
				? FallbackRosterSurface.FallbackPhaseCountLine
				: TEXT("Current-selection phase-id fallback phases on execute: none");
		Surface.ExplicitLabelOrderSummaryLine =
			Surface.bHasExplicitLabelPartition
				? ExplicitLabelRosterSurface.OrderSummaryLine
				: TEXT("Current-selection explicit-label order on execute: none");
		Surface.FallbackOrderSummaryLine =
			Surface.bHasFallbackLabelPartition
				? FallbackRosterSurface.OrderSummaryLine
				: TEXT("Current-selection phase-id fallback order on execute: none");
		Surface.ExplicitLabelSummaryLine =
			Surface.bHasExplicitLabelPartition
				? ExplicitLabelRosterSurface.LabelSummaryLine
				: TEXT("Current-selection explicit labels on execute: none");
		Surface.FallbackLabelSummaryLine =
			Surface.bHasFallbackLabelPartition
				? FallbackRosterSurface.LabelSummaryLine
				: TEXT("Current-selection phase-id fallback labels on execute: none");
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.CurrentSelectionLabelProvenancePartitionSummaryLine =
			OptionMenuSurface.UnresolvedSelectionLine;
		Surface.ExplicitLabelPhaseCountLine =
			ExplicitLabelRosterSurface.ExplicitLabelPhaseCountLine;
		Surface.FallbackPhaseCountLine =
			FallbackRosterSurface.FallbackPhaseCountLine;
		Surface.ExplicitLabelOrderSummaryLine =
			ExplicitLabelRosterSurface.OrderSummaryLine;
		Surface.FallbackOrderSummaryLine =
			FallbackRosterSurface.OrderSummaryLine;
		Surface.ExplicitLabelSummaryLine =
			ExplicitLabelRosterSurface.LabelSummaryLine;
		Surface.FallbackLabelSummaryLine =
			FallbackRosterSurface.LabelSummaryLine;
	}
	else if (SurvivorRosterSurface.bPreviewBlocked)
	{
		Surface.CurrentSelectionLabelProvenancePartitionSummaryLine =
			SurvivorRosterSurface.CurrentSelectionSurvivorRosterLine;
		Surface.ExplicitLabelPhaseCountLine =
			ExplicitLabelRosterSurface.ExplicitLabelPhaseCountLine;
		Surface.FallbackPhaseCountLine =
			FallbackRosterSurface.FallbackPhaseCountLine;
		Surface.ExplicitLabelOrderSummaryLine =
			ExplicitLabelRosterSurface.OrderSummaryLine;
		Surface.FallbackOrderSummaryLine =
			FallbackRosterSurface.OrderSummaryLine;
		Surface.ExplicitLabelSummaryLine =
			ExplicitLabelRosterSurface.LabelSummaryLine;
		Surface.FallbackLabelSummaryLine =
			FallbackRosterSurface.LabelSummaryLine;
	}
	else if (SurvivorRosterSurface.bHasExactCurrentSelectionSurvivorPhaseRoster)
	{
		Surface.CurrentSelectionLabelProvenancePartitionSummaryLine =
			TEXT("Current-selection label-provenance partition on execute: none");
		Surface.ExplicitLabelPhaseCountLine =
			TEXT("Current-selection explicit-label phases on execute: none");
		Surface.FallbackPhaseCountLine =
			TEXT("Current-selection phase-id fallback phases on execute: none");
		Surface.ExplicitLabelOrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: none");
		Surface.FallbackOrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: none");
		Surface.ExplicitLabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: none");
		Surface.FallbackLabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: none");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.CurrentSelectionLabelProvenancePartitionSummaryLine =
			TEXT("Current selection has no additional owned-execution split-phase label-provenance partition summary preview.");
		Surface.ExplicitLabelPhaseCountLine =
			ExplicitLabelRosterSurface.ExplicitLabelPhaseCountLine;
		Surface.FallbackPhaseCountLine =
			FallbackRosterSurface.FallbackPhaseCountLine;
		Surface.ExplicitLabelOrderSummaryLine =
			ExplicitLabelRosterSurface.OrderSummaryLine;
		Surface.FallbackOrderSummaryLine =
			FallbackRosterSurface.OrderSummaryLine;
		Surface.ExplicitLabelSummaryLine =
			ExplicitLabelRosterSurface.LabelSummaryLine;
		Surface.FallbackLabelSummaryLine =
			FallbackRosterSurface.LabelSummaryLine;
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.CurrentSelectionLabelProvenancePartitionSummaryLine =
			TEXT("Current selection: unresolved");
		Surface.ExplicitLabelPhaseCountLine =
			TEXT("Current-selection explicit-label phases on execute: unresolved");
		Surface.FallbackPhaseCountLine =
			TEXT("Current-selection phase-id fallback phases on execute: unresolved");
		Surface.ExplicitLabelOrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: unresolved");
		Surface.FallbackOrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: unresolved");
		Surface.ExplicitLabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: unresolved");
		Surface.FallbackLabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: unresolved");
	}
	else
	{
		Surface.CurrentSelectionLabelProvenancePartitionSummaryLine =
			TEXT("Current selection: n/a");
		Surface.ExplicitLabelPhaseCountLine =
			TEXT("Current-selection explicit-label phases on execute: n/a");
		Surface.FallbackPhaseCountLine =
			TEXT("Current-selection phase-id fallback phases on execute: n/a");
		Surface.ExplicitLabelOrderSummaryLine =
			TEXT("Current-selection explicit-label order on execute: n/a");
		Surface.FallbackOrderSummaryLine =
			TEXT("Current-selection phase-id fallback order on execute: n/a");
		Surface.ExplicitLabelSummaryLine =
			TEXT("Current-selection explicit labels on execute: n/a");
		Surface.FallbackLabelSummaryLine =
			TEXT("Current-selection phase-id fallback labels on execute: n/a");
	}

	if (Surface.bHasCurrentSelectionLabelProvenancePartitionSummary)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition summary inspect exposes %d explicit-label phase%s and %d phase-id fallback phase%s for the active selection."),
			Surface.ExplicitLabelPhaseCount,
			Surface.ExplicitLabelPhaseCount == 1 ? TEXT("") : TEXT("s"),
			Surface.FallbackPhaseCount,
			Surface.FallbackPhaseCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition summary inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (SurvivorRosterSurface.bPreviewBlocked)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition summary inspect resolves the active selection, but execute-time label-provenance partition summary remains blocked.");
	}
	else if (SurvivorRosterSurface.bHasExactCurrentSelectionSurvivorPhaseRoster)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition summary inspect resolves the active selection, and no surviving phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition summary inspect is active, but the current selection does not expose partition detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition summary inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.StatusLine = SurvivorRosterSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionLabelProvenancePartitionSummaryLine,
		*Surface.ExplicitLabelPhaseCountLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionRosterPairInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionRosterPairInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionSummaryInspectSurface
		PartitionSummarySurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionSummaryInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectSurface
		ExplicitLabelRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectSurface
		FallbackRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionRosterPairInspectSurface
		Surface;
	Surface.SelectorId = PartitionSummarySurface.SelectorId;
	Surface.SelectorLabel = PartitionSummarySurface.SelectorLabel;
	Surface.BindingLabel = PartitionSummarySurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Roster-Pair Inspect");
	Surface.bHasSelector = PartitionSummarySurface.bHasSelector;
	Surface.bHasSelection = PartitionSummarySurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		PartitionSummarySurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		PartitionSummarySurface.CurrentSelectionSelectionLine;
	Surface.CurrentSelectionOptionId =
		PartitionSummarySurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		PartitionSummarySurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		PartitionSummarySurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		PartitionSummarySurface.LaunchRequestPreviewKind;
	Surface.ExplicitLabelPhaseCount =
		PartitionSummarySurface.ExplicitLabelPhaseCount;
	Surface.FallbackPhaseCount =
		PartitionSummarySurface.FallbackPhaseCount;
	Surface.bStartsOwnedCaseImmediately =
		PartitionSummarySurface.bStartsOwnedCaseImmediately;
	Surface.bHasExactCurrentSelectionLabelProvenancePartitionRosterPair =
		PartitionSummarySurface.bHasExactCurrentSelectionLabelProvenancePartitionSummary;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		PartitionSummarySurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bHasExplicitLabelPartition =
		PartitionSummarySurface.bHasExplicitLabelPartition;
	Surface.bHasFallbackLabelPartition =
		PartitionSummarySurface.bHasFallbackLabelPartition;
	Surface.bHasMixedLabelProvenancePartition =
		PartitionSummarySurface.bHasMixedLabelProvenancePartition;
	Surface.bHasCurrentSelectionLabelProvenancePartitionRosterPair =
		PartitionSummarySurface.bHasCurrentSelectionLabelProvenancePartitionSummary;
	Surface.bPreviewBlocked = PartitionSummarySurface.bPreviewBlocked;
	Surface.bCanPreview = PartitionSummarySurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Roster-Pair Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Roster-Pair Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	Surface.ExplicitLabelPhases = ExplicitLabelRosterSurface.ExplicitLabelPhases;
	Surface.FallbackPhases = FallbackRosterSurface.FallbackPhases;
	Surface.CurrentSelectionLabelProvenancePartitionRosterPairLine =
		PartitionSummarySurface.CurrentSelectionLabelProvenancePartitionSummaryLine;
	Surface.ExplicitLabelPhaseCountLine =
		PartitionSummarySurface.ExplicitLabelPhaseCountLine;
	Surface.FallbackPhaseCountLine =
		PartitionSummarySurface.FallbackPhaseCountLine;
	Surface.ExplicitLabelOrderSummaryLine =
		PartitionSummarySurface.ExplicitLabelOrderSummaryLine;
	Surface.FallbackOrderSummaryLine =
		PartitionSummarySurface.FallbackOrderSummaryLine;
	Surface.ExplicitLabelSummaryLine =
		PartitionSummarySurface.ExplicitLabelSummaryLine;
	Surface.FallbackLabelSummaryLine =
		PartitionSummarySurface.FallbackLabelSummaryLine;

	if (Surface.bHasCurrentSelectionLabelProvenancePartitionRosterPair)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition roster-pair inspect exposes %d explicit-label phase%s and %d phase-id fallback phase%s for the active selection."),
			Surface.ExplicitLabelPhaseCount,
			Surface.ExplicitLabelPhaseCount == 1 ? TEXT("") : TEXT("s"),
			Surface.FallbackPhaseCount,
			Surface.FallbackPhaseCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition roster-pair inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (PartitionSummarySurface.bPreviewBlocked)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition roster-pair inspect resolves the active selection, but execute-time roster-pair inspection remains blocked.");
	}
	else if (PartitionSummarySurface.bHasExactCurrentSelectionLabelProvenancePartitionSummary)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition roster-pair inspect resolves the active selection, and no surviving phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition roster-pair inspect is active, but the current selection does not expose roster-pair detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition roster-pair inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.StatusLine = PartitionSummarySurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionLabelProvenancePartitionRosterPairLine,
		*Surface.ExplicitLabelPhaseCountLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionSummaryInspectSurface
		PartitionSummarySurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionSummaryInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionRosterPairInspectSurface
		RosterPairSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionRosterPairInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface
		Surface;
	Surface.SelectorId = PartitionSummarySurface.SelectorId;
	Surface.SelectorLabel = PartitionSummarySurface.SelectorLabel;
	Surface.BindingLabel = PartitionSummarySurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Inspect");
	Surface.bHasSelector = PartitionSummarySurface.bHasSelector;
	Surface.bHasSelection = PartitionSummarySurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		PartitionSummarySurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		PartitionSummarySurface.CurrentSelectionSelectionLine;
	Surface.CurrentSelectionOptionId =
		PartitionSummarySurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		PartitionSummarySurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		PartitionSummarySurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		PartitionSummarySurface.LaunchRequestPreviewKind;
	Surface.ExplicitLabelPhaseCount =
		PartitionSummarySurface.ExplicitLabelPhaseCount;
	Surface.FallbackPhaseCount =
		PartitionSummarySurface.FallbackPhaseCount;
	Surface.ExplicitLabelPhaseCountLine =
		PartitionSummarySurface.ExplicitLabelPhaseCountLine;
	Surface.FallbackPhaseCountLine =
		PartitionSummarySurface.FallbackPhaseCountLine;
	Surface.bStartsOwnedCaseImmediately =
		PartitionSummarySurface.bStartsOwnedCaseImmediately;
	Surface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRoster =
		PartitionSummarySurface.bHasExactCurrentSelectionLabelProvenancePartitionSummary;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		PartitionSummarySurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bHasExplicitLabelPartition =
		PartitionSummarySurface.bHasExplicitLabelPartition;
	Surface.bHasFallbackLabelPartition =
		PartitionSummarySurface.bHasFallbackLabelPartition;
	Surface.bHasMixedLabelProvenancePartition =
		PartitionSummarySurface.bHasMixedLabelProvenancePartition;
	Surface.bPreviewBlocked = PartitionSummarySurface.bPreviewBlocked;
	Surface.bCanPreview = PartitionSummarySurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Inspect: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Inspect: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	const auto AddMergedPhase = [&Surface](
		const auto& SourcePhase,
		const bool bBelongsToExplicitLabelPartition
	)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface
			PhaseSurface;
		PhaseSurface.PhaseId = SourcePhase.PhaseId;
		PhaseSurface.SourceLabel = SourcePhase.SourceLabel;
		PhaseSurface.NormalizedLabel = SourcePhase.NormalizedLabel;
		PhaseSurface.EvaluationOrder = SourcePhase.EvaluationOrder;
		PhaseSurface.NormalizedOrder = SourcePhase.NormalizedOrder;
		PhaseSurface.OrderLine = SourcePhase.OrderLine;
		PhaseSurface.LabelLine = SourcePhase.LabelLine;
		PhaseSurface.LabelProvenanceLine = SourcePhase.LabelProvenanceLine;
		PhaseSurface.bBelongsToExplicitLabelPartition =
			bBelongsToExplicitLabelPartition;
		PhaseSurface.bBelongsToFallbackLabelPartition =
			!bBelongsToExplicitLabelPartition;
		PhaseSurface.bSourceLabelWasExplicit =
			bBelongsToExplicitLabelPartition;
		PhaseSurface.bLabelFallsBackToPhaseId =
			!bBelongsToExplicitLabelPartition;
		PhaseSurface.bCanPreview = SourcePhase.bCanPreview;

		const FString PartitionTag = bBelongsToExplicitLabelPartition
			? TEXT("explicit-label")
			: TEXT("phase-id fallback");
		PhaseSurface.LabelProvenancePartitionLine =
			bBelongsToExplicitLabelPartition
				? FString::Printf(
					TEXT("Current-selection label-provenance partition on execute: normalized phase #%d remains in the explicit-label partition."),
					PhaseSurface.NormalizedOrder
				)
				: FString::Printf(
					TEXT("Current-selection label-provenance partition on execute: normalized phase #%d remains in the phase-id fallback partition."),
					PhaseSurface.NormalizedOrder
				);
		PhaseSurface.MergedOrderedRosterLine = FString::Printf(
			TEXT("Current-selection merged ordered label-provenance roster on execute: normalized phase #%d %s (%s) remains in the %s partition."),
			PhaseSurface.NormalizedOrder,
			*PhaseSurface.NormalizedLabel,
			*PhaseSurface.PhaseId,
			*PartitionTag
		);
		PhaseSurface.DetailLine = FString::Printf(
			TEXT("%s | %s | %s"),
			*PhaseSurface.OrderLine,
			*PhaseSurface.LabelProvenancePartitionLine,
			*PhaseSurface.MergedOrderedRosterLine
		);
		Surface.MergedOrderedPhases.Add(MoveTemp(PhaseSurface));
	};

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionExplicitLabelRosterInspectPhaseSurface&
		PhaseSurface : RosterPairSurface.ExplicitLabelPhases)
	{
		AddMergedPhase(PhaseSurface, true);
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionPhaseIdFallbackRosterInspectPhaseSurface&
		PhaseSurface : RosterPairSurface.FallbackPhases)
	{
		AddMergedPhase(PhaseSurface, false);
	}

	Surface.MergedOrderedPhases.Sort([](
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface& Left,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface& Right
	)
	{
		const int32 LeftNormalizedOrder =
			Left.NormalizedOrder >= 0 ? Left.NormalizedOrder : MAX_int32;
		const int32 RightNormalizedOrder =
			Right.NormalizedOrder >= 0 ? Right.NormalizedOrder : MAX_int32;
		if (LeftNormalizedOrder != RightNormalizedOrder)
		{
			return LeftNormalizedOrder < RightNormalizedOrder;
		}

		const int32 LeftEvaluationOrder =
			Left.EvaluationOrder >= 0 ? Left.EvaluationOrder : MAX_int32;
		const int32 RightEvaluationOrder =
			Right.EvaluationOrder >= 0 ? Right.EvaluationOrder : MAX_int32;
		if (LeftEvaluationOrder != RightEvaluationOrder)
		{
			return LeftEvaluationOrder < RightEvaluationOrder;
		}

		if (Left.bBelongsToExplicitLabelPartition
			!= Right.bBelongsToExplicitLabelPartition)
		{
			return Left.bBelongsToExplicitLabelPartition;
		}

		return Left.PhaseId < Right.PhaseId;
	});

	Surface.MergedOrderedPhaseCount = Surface.MergedOrderedPhases.Num();
	Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRoster =
		Surface.MergedOrderedPhaseCount > 0;

	Surface.MergedOrderedPhaseCountLine =
		Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRoster
			? FString::Printf(
				TEXT("Current-selection merged ordered retained phases on execute: %d phase%s"),
				Surface.MergedOrderedPhaseCount,
				Surface.MergedOrderedPhaseCount == 1 ? TEXT("") : TEXT("s")
			)
			: (PartitionSummarySurface.bHasExactCurrentSelectionLabelProvenancePartitionSummary
				&& !PartitionSummarySurface.bPreviewBlocked
				? TEXT("Current-selection merged ordered retained phases on execute: none")
				: TEXT("Current-selection merged ordered retained phases on execute: unavailable"));

	if (Surface.MergedOrderedPhases.Num() > 0)
	{
		TArray<FString> OrderedPhaseLabels;
		OrderedPhaseLabels.Reserve(Surface.MergedOrderedPhases.Num());
		TArray<FString> PartitionTaggedLabels;
		PartitionTaggedLabels.Reserve(Surface.MergedOrderedPhases.Num());
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface&
			PhaseSurface : Surface.MergedOrderedPhases)
		{
			const FString PartitionTag = PhaseSurface.bBelongsToExplicitLabelPartition
				? TEXT("explicit label")
				: TEXT("phase-id fallback");
			OrderedPhaseLabels.Add(
				FString::Printf(
					TEXT("#%d %s [%s]"),
					PhaseSurface.NormalizedOrder,
					*PhaseSurface.NormalizedLabel,
					*PartitionTag
				)
			);
			PartitionTaggedLabels.Add(
				FString::Printf(
					TEXT("%s (%s, %s)"),
					*PhaseSurface.NormalizedLabel,
					*PhaseSurface.PhaseId,
					*PartitionTag
				)
			);
		}

		Surface.MergedOrderSummaryLine = FString::Printf(
			TEXT("Current-selection merged ordered label-provenance order on execute: %s"),
			*FString::Join(OrderedPhaseLabels, TEXT(" | "))
		);
		Surface.MergedLabelSummaryLine = FString::Printf(
			TEXT("Current-selection merged ordered labels on execute: %s"),
			*FString::Join(PartitionTaggedLabels, TEXT(", "))
		);
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine =
			FString::Printf(
				TEXT("%s | %d explicit-label | %d phase-id fallback"),
				*Surface.MergedOrderedPhaseCountLine,
				Surface.ExplicitLabelPhaseCount,
				Surface.FallbackPhaseCount
			);
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.MergedOrderSummaryLine =
			TEXT("Current-selection merged ordered label-provenance order on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MergedLabelSummaryLine =
			TEXT("Current-selection merged ordered labels on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine =
			OptionMenuSurface.UnresolvedSelectionLine;
	}
	else if (PartitionSummarySurface.bPreviewBlocked)
	{
		Surface.MergedOrderSummaryLine =
			TEXT("Current-selection merged ordered label-provenance order on execute: blocked until execute-time roster fusion is available.");
		Surface.MergedLabelSummaryLine =
			TEXT("Current-selection merged ordered labels on execute: blocked until execute-time roster fusion is available.");
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine =
			PartitionSummarySurface.CurrentSelectionLabelProvenancePartitionSummaryLine;
	}
	else if (PartitionSummarySurface.bHasExactCurrentSelectionLabelProvenancePartitionSummary)
	{
		Surface.MergedOrderSummaryLine =
			TEXT("Current-selection merged ordered label-provenance order on execute: none");
		Surface.MergedLabelSummaryLine =
			TEXT("Current-selection merged ordered labels on execute: none");
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine =
			TEXT("Current-selection label-provenance partition merged ordered roster on execute: none");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.MergedOrderSummaryLine =
			TEXT("Current-selection merged ordered label-provenance order on execute: unavailable");
		Surface.MergedLabelSummaryLine =
			TEXT("Current-selection merged ordered labels on execute: unavailable");
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine =
			TEXT("Current selection has no additional owned-execution split-phase merged ordered label-provenance roster preview.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.MergedOrderSummaryLine =
			TEXT("Current-selection merged ordered label-provenance order on execute: unresolved");
		Surface.MergedLabelSummaryLine =
			TEXT("Current-selection merged ordered labels on execute: unresolved");
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine =
			TEXT("Current selection: unresolved");
	}
	else
	{
		Surface.MergedOrderSummaryLine =
			TEXT("Current-selection merged ordered label-provenance order on execute: n/a");
		Surface.MergedLabelSummaryLine =
			TEXT("Current-selection merged ordered labels on execute: n/a");
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine =
			TEXT("Current selection: n/a");
	}

	if (Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRoster)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition merged ordered roster inspect exposes %d retained phase%s in one ordered list for the active selection."),
			Surface.MergedOrderedPhaseCount,
			Surface.MergedOrderedPhaseCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition merged ordered roster inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (PartitionSummarySurface.bPreviewBlocked)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition merged ordered roster inspect resolves the active selection, but execute-time merged ordered roster inspection remains blocked.");
	}
	else if (PartitionSummarySurface.bHasExactCurrentSelectionLabelProvenancePartitionSummary)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition merged ordered roster inspect resolves the active selection, and no surviving phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasSelection)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition merged ordered roster inspect is active, but the current selection does not expose merged ordered roster detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection label-provenance partition merged ordered roster inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.StatusLine = PartitionSummarySurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine,
		*Surface.MergedOrderSummaryLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const FString& PhaseId,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface
		MergedOrderedRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupInspectSurface
		Surface;
	Surface.SelectorId = MergedOrderedRosterSurface.SelectorId;
	Surface.SelectorLabel = MergedOrderedRosterSurface.SelectorLabel;
	Surface.BindingLabel = MergedOrderedRosterSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Phase-Id Lookup Inspect");
	Surface.bHasSelector = MergedOrderedRosterSurface.bHasSelector;
	Surface.bHasSelection = MergedOrderedRosterSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		MergedOrderedRosterSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		MergedOrderedRosterSurface.CurrentSelectionSelectionLine;
	Surface.LookupPhaseId = PhaseId;
	Surface.bHasLookupPhaseId = !PhaseId.IsEmpty();
	Surface.MergedOrderedPhaseCountLine =
		MergedOrderedRosterSurface.MergedOrderedPhaseCountLine;
	Surface.CurrentSelectionOptionId =
		MergedOrderedRosterSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		MergedOrderedRosterSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		MergedOrderedRosterSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		MergedOrderedRosterSurface.LaunchRequestPreviewKind;
	Surface.bStartsOwnedCaseImmediately =
		MergedOrderedRosterSurface.bStartsOwnedCaseImmediately;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		MergedOrderedRosterSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bPreviewBlocked = MergedOrderedRosterSurface.bPreviewBlocked;
	Surface.bCanPreview = MergedOrderedRosterSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		const FString SelectorHeadlineValue = OptionMenuSurface.SelectorLabel.IsEmpty()
			? SelectorId
			: OptionMenuSurface.SelectorLabel;
		Surface.Headline = Surface.bHasLookupPhaseId
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Phase-Id Lookup Inspect: %s [%s]"),
				*SelectorHeadlineValue,
				*PhaseId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Phase-Id Lookup Inspect: %s"),
				*SelectorHeadlineValue
			);
	}

	if (Surface.bHasLookupPhaseId)
	{
		if (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface*
			MatchedPhase = MergedOrderedRosterSurface.MergedOrderedPhases.FindByPredicate(
				[&PhaseId](
					const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface& PhaseSurface
				)
				{
					return PhaseSurface.PhaseId == PhaseId;
				}
			))
		{
			Surface.MatchedPhase = *MatchedPhase;
			Surface.MatchedNormalizedOrder = MatchedPhase->NormalizedOrder;
			Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookup =
				true;
			Surface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookup =
				MergedOrderedRosterSurface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRoster;
			Surface.bMatchedExplicitLabelPartition =
				MatchedPhase->bBelongsToExplicitLabelPartition;
			Surface.bMatchedFallbackLabelPartition =
				MatchedPhase->bBelongsToFallbackLabelPartition;
			Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
				FString::Printf(
					TEXT("Current-selection merged ordered phase-id lookup on execute: phase id %s resolves to normalized phase #%d with label %s."),
					*MatchedPhase->PhaseId,
					MatchedPhase->NormalizedOrder,
					*MatchedPhase->NormalizedLabel
				);
			Surface.MatchedPhaseOrderLine = MatchedPhase->OrderLine;
			Surface.MatchedPhaseLabelLine = MatchedPhase->LabelLine;
			Surface.MatchedPhasePartitionLine =
				MatchedPhase->LabelProvenancePartitionLine;
		}
	}

	if (Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookup)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect exposes retained phase id %s for the active selection."),
			*Surface.LookupPhaseId
		);
	}
	else if (!Surface.bHasLookupPhaseId)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			TEXT("Current-selection merged ordered phase-id lookup on execute: no phase id requested.");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: unavailable");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: unavailable");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: unavailable");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect is active, but no phase id was requested.");
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			OptionMenuSurface.UnresolvedSelectionLine;
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (MergedOrderedRosterSurface.bPreviewBlocked)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			MergedOrderedRosterSurface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine;
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect resolves the active selection, but execute-time phase-id lookup remains blocked.");
	}
	else if (MergedOrderedRosterSurface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRoster)
	{
		Surface.bLookupMissesRetainedRoster = true;
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			FString::Printf(
				TEXT("Current-selection merged ordered phase-id lookup on execute: phase id %s is not retained in the merged ordered roster."),
				*PhaseId
			);
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: no retained phase matches that phase id");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: no retained phase matches that phase id");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: no retained phase matches that phase id");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect resolves the active selection, but the requested phase id is not retained.");
	}
	else if (MergedOrderedRosterSurface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRoster)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			TEXT("Current-selection merged ordered phase-id lookup on execute: none");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: none");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: none");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: none");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect resolves the active selection, and no surviving phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			TEXT("Current selection has no additional owned-execution split-phase merged ordered roster phase-id lookup preview.");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: unavailable");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: unavailable");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: unavailable");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect is active, but the current selection does not expose merged ordered roster lookup detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			TEXT("Current selection: unresolved");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: unresolved");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: unresolved");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: unresolved");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster phase-id lookup inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine =
			TEXT("Current selection: n/a");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested phase order on execute: n/a");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested phase label on execute: n/a");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested phase partition on execute: n/a");
		Surface.StatusLine = MergedOrderedRosterSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterPhaseIdLookupLine,
		*Surface.MatchedPhasePartitionLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const int32 NormalizedOrder,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface
		MergedOrderedRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupInspectSurface
		Surface;
	Surface.SelectorId = MergedOrderedRosterSurface.SelectorId;
	Surface.SelectorLabel = MergedOrderedRosterSurface.SelectorLabel;
	Surface.BindingLabel = MergedOrderedRosterSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Normalized-Order Lookup Inspect");
	Surface.bHasSelector = MergedOrderedRosterSurface.bHasSelector;
	Surface.bHasSelection = MergedOrderedRosterSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		MergedOrderedRosterSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		MergedOrderedRosterSurface.CurrentSelectionSelectionLine;
	Surface.LookupNormalizedOrder = NormalizedOrder;
	Surface.bHasLookupNormalizedOrder = NormalizedOrder >= 0;
	Surface.MergedOrderedPhaseCountLine =
		MergedOrderedRosterSurface.MergedOrderedPhaseCountLine;
	Surface.CurrentSelectionOptionId =
		MergedOrderedRosterSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		MergedOrderedRosterSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		MergedOrderedRosterSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		MergedOrderedRosterSurface.LaunchRequestPreviewKind;
	Surface.bStartsOwnedCaseImmediately =
		MergedOrderedRosterSurface.bStartsOwnedCaseImmediately;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		MergedOrderedRosterSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bPreviewBlocked = MergedOrderedRosterSurface.bPreviewBlocked;
	Surface.bCanPreview = MergedOrderedRosterSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		const FString SelectorHeadlineValue = OptionMenuSurface.SelectorLabel.IsEmpty()
			? SelectorId
			: OptionMenuSurface.SelectorLabel;
		Surface.Headline = Surface.bHasLookupNormalizedOrder
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Normalized-Order Lookup Inspect: %s [#%d]"),
				*SelectorHeadlineValue,
				NormalizedOrder
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Normalized-Order Lookup Inspect: %s"),
				*SelectorHeadlineValue
			);
	}

	if (Surface.bHasLookupNormalizedOrder)
	{
		if (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface*
			MatchedPhase = MergedOrderedRosterSurface.MergedOrderedPhases.FindByPredicate(
				[NormalizedOrder](
					const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface& PhaseSurface
				)
				{
					return PhaseSurface.NormalizedOrder == NormalizedOrder;
				}
			))
		{
			Surface.MatchedPhase = *MatchedPhase;
			Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookup =
				true;
			Surface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookup =
				MergedOrderedRosterSurface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRoster;
			Surface.bMatchedExplicitLabelPartition =
				MatchedPhase->bBelongsToExplicitLabelPartition;
			Surface.bMatchedFallbackLabelPartition =
				MatchedPhase->bBelongsToFallbackLabelPartition;
			Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
				FString::Printf(
					TEXT("Current-selection merged ordered normalized-order lookup on execute: normalized phase #%d resolves to phase id %s with label %s."),
					MatchedPhase->NormalizedOrder,
					*MatchedPhase->PhaseId,
					*MatchedPhase->NormalizedLabel
				);
			Surface.MatchedPhaseOrderLine = MatchedPhase->OrderLine;
			Surface.MatchedPhaseIdLine = FString::Printf(
				TEXT("Requested normalized phase id on execute: %s"),
				*MatchedPhase->PhaseId
			);
			Surface.MatchedPhaseLabelLine = MatchedPhase->LabelLine;
			Surface.MatchedPhasePartitionLine =
				MatchedPhase->LabelProvenancePartitionLine;
		}
	}

	if (Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookup)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect exposes retained normalized phase #%d for the active selection."),
			Surface.LookupNormalizedOrder
		);
	}
	else if (!Surface.bHasLookupNormalizedOrder)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			TEXT("Current-selection merged ordered normalized-order lookup on execute: no normalized order requested.");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: unavailable");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: unavailable");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: unavailable");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: unavailable");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect is active, but no normalized order was requested.");
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			OptionMenuSurface.UnresolvedSelectionLine;
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (MergedOrderedRosterSurface.bPreviewBlocked)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			MergedOrderedRosterSurface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine;
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect resolves the active selection, but execute-time normalized-order lookup remains blocked.");
	}
	else if (MergedOrderedRosterSurface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRoster)
	{
		Surface.bLookupMissesRetainedRoster = true;
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			FString::Printf(
				TEXT("Current-selection merged ordered normalized-order lookup on execute: normalized phase #%d is not retained in the merged ordered roster."),
				NormalizedOrder
			);
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: no retained phase matches that normalized order");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: no retained phase matches that normalized order");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: no retained phase matches that normalized order");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: no retained phase matches that normalized order");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect resolves the active selection, but the requested normalized order is not retained.");
	}
	else if (MergedOrderedRosterSurface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRoster)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			TEXT("Current-selection merged ordered normalized-order lookup on execute: none");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: none");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: none");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: none");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: none");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect resolves the active selection, and no surviving phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			TEXT("Current selection has no additional owned-execution split-phase merged ordered roster normalized-order lookup preview.");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: unavailable");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: unavailable");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: unavailable");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: unavailable");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect is active, but the current selection does not expose merged ordered roster lookup detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			TEXT("Current selection: unresolved");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: unresolved");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: unresolved");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: unresolved");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: unresolved");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster normalized-order lookup inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine =
			TEXT("Current selection: n/a");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested normalized phase order on execute: n/a");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested normalized phase id on execute: n/a");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested normalized phase label on execute: n/a");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested normalized phase partition on execute: n/a");
		Surface.StatusLine = MergedOrderedRosterSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterNormalizedOrderLookupLine,
		*Surface.MatchedPhasePartitionLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupInspectSurface
UHyperTwistTrainingCoachLibrary::
	DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupInspectSurface(
		const FHyperTwistTrainingRunState& RunState,
		const FString& SelectorId,
		const int32 EvaluationOrder,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
			OptionLaunchRequestPreviewSurface
	)
{
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface
		MergedOrderedRosterSurface =
			DeriveCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectSurface(
				RunState,
				SelectorId,
				OptionMenuSurface,
				OptionLaunchRequestPreviewSurface
			);

	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupInspectSurface
		Surface;
	Surface.SelectorId = MergedOrderedRosterSurface.SelectorId;
	Surface.SelectorLabel = MergedOrderedRosterSurface.SelectorLabel;
	Surface.BindingLabel = MergedOrderedRosterSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Evaluation-Order Lookup Inspect");
	Surface.bHasSelector = MergedOrderedRosterSurface.bHasSelector;
	Surface.bHasSelection = MergedOrderedRosterSurface.bHasSelection;
	Surface.bSelectionMatchesAvailableOption =
		MergedOrderedRosterSurface.bSelectionMatchesAvailableOption;
	Surface.CurrentSelectionSelectionLine =
		MergedOrderedRosterSurface.CurrentSelectionSelectionLine;
	Surface.LookupEvaluationOrder = EvaluationOrder;
	Surface.bHasLookupEvaluationOrder = EvaluationOrder >= 0;
	Surface.MergedOrderedPhaseCountLine =
		MergedOrderedRosterSurface.MergedOrderedPhaseCountLine;
	Surface.CurrentSelectionOptionId =
		MergedOrderedRosterSurface.CurrentSelectionOptionId;
	Surface.CurrentSelectionOptionLabel =
		MergedOrderedRosterSurface.CurrentSelectionOptionLabel;
	Surface.CurrentSelectionOptionValue =
		MergedOrderedRosterSurface.CurrentSelectionOptionValue;
	Surface.LaunchRequestPreviewKind =
		MergedOrderedRosterSurface.LaunchRequestPreviewKind;
	Surface.bStartsOwnedCaseImmediately =
		MergedOrderedRosterSurface.bStartsOwnedCaseImmediately;
	Surface.bRetainsActiveDeckSplitPhaseFusion =
		MergedOrderedRosterSurface.bRetainsActiveDeckSplitPhaseFusion;
	Surface.bPreviewBlocked = MergedOrderedRosterSurface.bPreviewBlocked;
	Surface.bCanPreview = MergedOrderedRosterSurface.bCanPreview;

	if (!SelectorId.IsEmpty())
	{
		const FString SelectorHeadlineValue = OptionMenuSurface.SelectorLabel.IsEmpty()
			? SelectorId
			: OptionMenuSurface.SelectorLabel;
		Surface.Headline = Surface.bHasLookupEvaluationOrder
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Evaluation-Order Lookup Inspect: %s [evaluation #%d]"),
				*SelectorHeadlineValue,
				EvaluationOrder
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Split-Phase Current-Selection Label-Provenance Partition Merged Ordered Roster Evaluation-Order Lookup Inspect: %s"),
				*SelectorHeadlineValue
			);
	}

	if (Surface.bHasLookupEvaluationOrder)
	{
		if (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface*
			MatchedPhase = MergedOrderedRosterSurface.MergedOrderedPhases.FindByPredicate(
				[EvaluationOrder](
					const FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionSplitPhaseCurrentSelectionLabelProvenancePartitionMergedOrderedRosterInspectPhaseSurface& PhaseSurface
				)
				{
					return PhaseSurface.EvaluationOrder == EvaluationOrder;
				}
			))
		{
			Surface.MatchedPhase = *MatchedPhase;
			Surface.MatchedNormalizedOrder = MatchedPhase->NormalizedOrder;
			Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookup =
				true;
			Surface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookup =
				MergedOrderedRosterSurface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRoster;
			Surface.bMatchedExplicitLabelPartition =
				MatchedPhase->bBelongsToExplicitLabelPartition;
			Surface.bMatchedFallbackLabelPartition =
				MatchedPhase->bBelongsToFallbackLabelPartition;
			Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
				FString::Printf(
					TEXT("Current-selection merged ordered evaluation-order lookup on execute: evaluation phase #%d resolves to phase id %s with normalized phase #%d and label %s."),
					MatchedPhase->EvaluationOrder,
					*MatchedPhase->PhaseId,
					MatchedPhase->NormalizedOrder,
					*MatchedPhase->NormalizedLabel
				);
			Surface.MatchedPhaseOrderLine = MatchedPhase->OrderLine;
			Surface.MatchedPhaseIdLine = FString::Printf(
				TEXT("Requested evaluation-order phase id on execute: %s"),
				*MatchedPhase->PhaseId
			);
			Surface.MatchedPhaseLabelLine = MatchedPhase->LabelLine;
			Surface.MatchedPhasePartitionLine =
				MatchedPhase->LabelProvenancePartitionLine;
		}
	}

	if (Surface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookup)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect exposes retained evaluation phase #%d for the active selection."),
			Surface.LookupEvaluationOrder
		);
	}
	else if (!Surface.bHasLookupEvaluationOrder)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			TEXT("Current-selection merged ordered evaluation-order lookup on execute: no evaluation order requested.");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: unavailable");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: unavailable");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: unavailable");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: unavailable");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect is active, but no evaluation order was requested.");
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			OptionMenuSurface.UnresolvedSelectionLine;
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: unavailable until the cached selection resolves to an imported option.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect is active, but the cached selection no longer matches an imported option.");
	}
	else if (MergedOrderedRosterSurface.bPreviewBlocked)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			MergedOrderedRosterSurface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterLine;
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: blocked until execute-time merged ordered roster inspection is available.");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect resolves the active selection, but execute-time evaluation-order lookup remains blocked.");
	}
	else if (MergedOrderedRosterSurface.bHasCurrentSelectionLabelProvenancePartitionMergedOrderedRoster)
	{
		Surface.bLookupMissesRetainedRoster = true;
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			FString::Printf(
				TEXT("Current-selection merged ordered evaluation-order lookup on execute: evaluation phase #%d is not retained in the merged ordered roster."),
				EvaluationOrder
			);
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: no retained phase matches that evaluation order");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: no retained phase matches that evaluation order");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: no retained phase matches that evaluation order");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: no retained phase matches that evaluation order");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect resolves the active selection, but the requested evaluation order is not retained.");
	}
	else if (MergedOrderedRosterSurface.bHasExactCurrentSelectionLabelProvenancePartitionMergedOrderedRoster)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			TEXT("Current-selection merged ordered evaluation-order lookup on execute: none");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: none");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: none");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: none");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: none");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect resolves the active selection, and no surviving phases are currently retained.");
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			TEXT("Current selection has no additional owned-execution split-phase merged ordered roster evaluation-order lookup preview.");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: unavailable");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: unavailable");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: unavailable");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: unavailable");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect is active, but the current selection does not expose merged ordered roster lookup detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			TEXT("Current selection: unresolved");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: unresolved");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: unresolved");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: unresolved");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: unresolved");
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution split-phase current-selection merged ordered roster evaluation-order lookup inspect is active, but this selector is currently unresolved.");
	}
	else
	{
		Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine =
			TEXT("Current selection: n/a");
		Surface.MatchedPhaseOrderLine =
			TEXT("Requested evaluation phase order on execute: n/a");
		Surface.MatchedPhaseIdLine =
			TEXT("Requested evaluation-order phase id on execute: n/a");
		Surface.MatchedPhaseLabelLine =
			TEXT("Requested evaluation-order phase label on execute: n/a");
		Surface.MatchedPhasePartitionLine =
			TEXT("Requested evaluation-order phase partition on execute: n/a");
		Surface.StatusLine = MergedOrderedRosterSurface.StatusLine;
	}

	Surface.DetailLine = FString::Printf(
		TEXT("%s | %s | %s"),
		*Surface.CurrentSelectionSelectionLine,
		*Surface.CurrentSelectionLabelProvenancePartitionMergedOrderedRosterEvaluationOrderLookupLine,
		*Surface.MatchedPhasePartitionLine
	);

	return Surface;
}

FHyperTwistTrainingCoachQueueControlSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachQueueControlSurface(
	const FHyperTwistTrainingCoachSessionQueueState& QueueState,
	const FHyperTwistTrainingCoachPanelState& PanelState
)
{
	FHyperTwistTrainingCoachQueueControlSurface Surface;
	Surface.DeferActionLabel = TEXT("defer_queue_entry");
	Surface.PromoteActionLabel = TEXT("promote_deferred_queue_entry");

	const FHyperTwistTrainingCoachSessionQueueStateEntry* ActiveQueueEntry =
		HyperTwistTrainingCoachLibraryInternal::FindQueueEntryById(
			QueueState,
			PanelState.ActiveQueueEntryId
		);
	const FHyperTwistTrainingCoachSessionQueueStateEntry* DeferredQueueEntry =
		HyperTwistTrainingCoachLibraryInternal::FindPreferredDeferredQueueEntry(
			QueueState,
			PanelState
		);

	Surface.DeferTargetEntryId = ActiveQueueEntry != nullptr ? ActiveQueueEntry->EntryId : FString();
	Surface.PromoteTargetEntryId = DeferredQueueEntry != nullptr ? DeferredQueueEntry->EntryId : FString();
	Surface.bCanDefer = ActiveQueueEntry != nullptr;
	Surface.bCanPromote = DeferredQueueEntry != nullptr;
	Surface.DeferAvailabilityLine =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachQueueDeferAvailabilityLine(
			PanelState,
			ActiveQueueEntry
		);
	Surface.PromoteAvailabilityLine =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachQueuePromoteAvailabilityLine(
			PanelState,
			DeferredQueueEntry
		);

	return Surface;
}

FHyperTwistTrainingCoachQueueRecoveryPostureSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachQueueRecoveryPostureSurface(
	const FHyperTwistCoachSchedulePolicySummary& SchedulePolicySummary,
	const FHyperTwistTrainingCoachSessionQueueExecutionSummary& QueueExecutionSummary,
	const FHyperTwistTrainingCoachPanelState& PanelState,
	const FHyperTwistTrainingCoachPrimaryActionSurface& PrimaryActionSurface,
	const FHyperTwistTrainingCoachQueueControlSurface& QueueControlSurface
)
{
	auto DescribeRecoveryAction = [](const EHyperTwistTrainingQueueRecoveryAction Action) -> FString
	{
		switch (Action)
		{
		case EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred:
			return TEXT("prefer promote-deferred recovery");
		case EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery:
			return TEXT("prefer launch-recovery");
		default:
			return TEXT("no upstream recovery preference");
		}
	};

	FHyperTwistTrainingCoachQueueRecoveryPostureSurface Surface;
	Surface.Headline = TEXT("Queue Recovery");
	Surface.PreferredRecoveryAction = PanelState.PreferredQueueRecoveryAction;
	Surface.PreferredGuidanceLane = PanelState.PreferredGuidanceLane;
	Surface.PressureScore = FMath::Max(
		SchedulePolicySummary.ReschedulePressureScore,
		QueueExecutionSummary.ExecutionPressureScore
	);
	Surface.bHasRecoveryPressure =
		Surface.PressureScore > 0.0f
		|| PanelState.bHasDeferredQueueWork
		|| QueueExecutionSummary.bHasOutstandingDeferredWork
		|| QueueExecutionSummary.bHasCompletionGap
		|| SchedulePolicySummary.bNeedsManualRescheduleReview
		|| SchedulePolicySummary.bHasExpiredDeferrals
		|| SchedulePolicySummary.bHasArchiveAwareDeferrals
		|| SchedulePolicySummary.bHasBlockedFollowUpDeferrals
		|| PanelState.PreferredQueueRecoveryAction != EHyperTwistTrainingQueueRecoveryAction::None
		|| HyperTwistTrainingCoachLibraryInternal::IsQueueRecoveryMemorySource(
			PanelState.PreferredGuidanceSourceLabel
		);

	const bool bPrefersPromoteUpstream =
		PanelState.PreferredQueueRecoveryAction
		== EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred;
	const bool bPrefersLaunchUpstream =
		PanelState.PreferredQueueRecoveryAction
		== EHyperTwistTrainingQueueRecoveryAction::LaunchRecovery;

	if (bPrefersPromoteUpstream && QueueControlSurface.bCanPromote)
	{
		Surface.PostureKind = EHyperTwistTrainingCoachQueuePostureKind::Promote;
	}
	else if (PrimaryActionSurface.bCanExecute
		&& (bPrefersLaunchUpstream
			|| !QueueControlSurface.bCanPromote
			|| PanelState.PreferredQueueRecoveryAction
				== EHyperTwistTrainingQueueRecoveryAction::None))
	{
		Surface.PostureKind = EHyperTwistTrainingCoachQueuePostureKind::Continue;
	}
	else if (QueueControlSurface.bCanPromote)
	{
		Surface.PostureKind = EHyperTwistTrainingCoachQueuePostureKind::Promote;
	}
	else if (PrimaryActionSurface.bCanExecute)
	{
		Surface.PostureKind = EHyperTwistTrainingCoachQueuePostureKind::Continue;
	}
	else if (QueueControlSurface.bCanDefer)
	{
		Surface.PostureKind = EHyperTwistTrainingCoachQueuePostureKind::Defer;
	}

	switch (Surface.PostureKind)
	{
	case EHyperTwistTrainingCoachQueuePostureKind::Continue:
		Surface.PreferredActionLabel = PrimaryActionSurface.ActionLabel;
		Surface.PreferredActionSourceLabel = PrimaryActionSurface.ActionSourceLabel;
		Surface.bCanExecutePreferredAction = PrimaryActionSurface.bCanExecute;
		if (bPrefersLaunchUpstream)
		{
			Surface.StatusLine = FString::Printf(
				TEXT("Queue recovery keeps continue live as the preferred launch-recovery posture: %s"),
				PrimaryActionSurface.AvailabilityLine.IsEmpty()
					? TEXT("Continue is actionable")
					: *PrimaryActionSurface.AvailabilityLine
			);
		}
		else if (bPrefersPromoteUpstream && !QueueControlSurface.bCanPromote)
		{
			Surface.StatusLine = FString::Printf(
				TEXT("Queue recovery falls back to continue because no deferred promote target is currently actionable: %s"),
				PrimaryActionSurface.AvailabilityLine.IsEmpty()
					? TEXT("Continue is actionable")
					: *PrimaryActionSurface.AvailabilityLine
			);
		}
		else if (Surface.bHasRecoveryPressure)
		{
			Surface.StatusLine = FString::Printf(
				TEXT("Queue recovery keeps continue as the live actionable posture: %s"),
				PrimaryActionSurface.AvailabilityLine.IsEmpty()
					? TEXT("Continue is actionable")
					: *PrimaryActionSurface.AvailabilityLine
			);
		}
		else
		{
			Surface.StatusLine = FString::Printf(
				TEXT("Queue posture is stable; continue remains the live coach action: %s"),
				PrimaryActionSurface.AvailabilityLine.IsEmpty()
					? TEXT("Continue is actionable")
					: *PrimaryActionSurface.AvailabilityLine
			);
		}
		break;
	case EHyperTwistTrainingCoachQueuePostureKind::Promote:
		Surface.PreferredActionLabel = QueueControlSurface.PromoteActionLabel;
		Surface.PreferredActionSourceLabel = QueueControlSurface.PromoteActionSourceLabel;
		Surface.bCanExecutePreferredAction = QueueControlSurface.bCanPromote;
		Surface.StatusLine = bPrefersPromoteUpstream
			? FString::Printf(
				TEXT("Queue recovery prefers deferred promotion: %s"),
				QueueControlSurface.PromoteAvailabilityLine.IsEmpty()
					? TEXT("Promote is actionable")
					: *QueueControlSurface.PromoteAvailabilityLine
			)
			: FString::Printf(
				TEXT("Continue is not currently the preferred recovery path, so deferred promotion becomes the live posture: %s"),
				QueueControlSurface.PromoteAvailabilityLine.IsEmpty()
					? TEXT("Promote is actionable")
					: *QueueControlSurface.PromoteAvailabilityLine
			);
		break;
	case EHyperTwistTrainingCoachQueuePostureKind::Defer:
		Surface.PreferredActionLabel = QueueControlSurface.DeferActionLabel;
		Surface.bCanExecutePreferredAction = QueueControlSurface.bCanDefer;
		Surface.StatusLine = FString::Printf(
			TEXT("No continue or promote target is currently actionable; defer is the available queue-pressure release control: %s"),
			QueueControlSurface.DeferAvailabilityLine.IsEmpty()
				? TEXT("Defer is actionable")
				: *QueueControlSurface.DeferAvailabilityLine
		);
		break;
	default:
		Surface.StatusLine = Surface.bHasRecoveryPressure
			? TEXT("Queue recovery pressure is present, but no continue, defer, or promote control is currently actionable.")
			: TEXT("Queue recovery pressure is not currently active.");
		break;
	}

	const FString GuidanceLaneLabel = HyperTwistTrainingCoachLibraryInternal::DescribeGuidanceLane(
		PanelState.PreferredGuidanceLane
	);
	const FString GuidanceSourceLabel = PanelState.PreferredGuidanceSourceLabel.IsEmpty()
		? TEXT("n/a")
		: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
			PanelState.PreferredGuidanceSourceLabel
		);
	const FString RecoveryActionSourceLabel = PanelState.PreferredQueueRecoveryActionSourceLabel.IsEmpty()
		? TEXT("n/a")
		: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
			PanelState.PreferredQueueRecoveryActionSourceLabel
		);
	Surface.DetailLine = FString::Printf(
		TEXT("Upstream: %s | Lane: %s | Guidance source: %s | Recovery action source: %s | Pressure %.2f | Runnable queue: %s | Deferred work: %s | Outstanding deferred: %s | Completion gap: %s | Manual review: %s | Blocked follow-up: %s | Archive-aware: %s | Dominant reason: %s"),
		*DescribeRecoveryAction(PanelState.PreferredQueueRecoveryAction),
		*GuidanceLaneLabel,
		*GuidanceSourceLabel,
		*RecoveryActionSourceLabel,
		Surface.PressureScore,
		PanelState.bHasRunnableQueueEntry ? TEXT("yes") : TEXT("no"),
		PanelState.bHasDeferredQueueWork ? TEXT("yes") : TEXT("no"),
		QueueExecutionSummary.bHasOutstandingDeferredWork ? TEXT("yes") : TEXT("no"),
		QueueExecutionSummary.bHasCompletionGap ? TEXT("yes") : TEXT("no"),
		SchedulePolicySummary.bNeedsManualRescheduleReview ? TEXT("yes") : TEXT("no"),
		SchedulePolicySummary.bHasBlockedFollowUpDeferrals ? TEXT("yes") : TEXT("no"),
		SchedulePolicySummary.bHasArchiveAwareDeferrals ? TEXT("yes") : TEXT("no"),
		SchedulePolicySummary.DominantDeferralReasonLabel.IsEmpty()
			? TEXT("n/a")
			: *SchedulePolicySummary.DominantDeferralReasonLabel
	);
	if (!PanelState.QueueSuppressionLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Suppression: %s"),
			*PanelState.QueueSuppressionLine
		);
	}

	return Surface;
}

FHyperTwistTrainingCoachHandoffContinuationSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachHandoffContinuationSurface(
	const FHyperTwistTrainingCoachPanelState& PanelState,
	const FHyperTwistTrainingCoachPrimaryActionSurface& PrimaryActionSurface,
	const FHyperTwistTrainingCoachQueueControlSurface& QueueControlSurface,
	const FHyperTwistTrainingCoachQueueRecoveryPostureSurface& QueueRecoveryPostureSurface
)
{
	FHyperTwistTrainingCoachHandoffContinuationSurface Surface;
	Surface.Headline = TEXT("Coach Handoff");
	Surface.ContinuationKind = PrimaryActionSurface.ActionKind;
	Surface.QueuePostureKind = QueueRecoveryPostureSurface.PostureKind;
	Surface.bHasActionableContinuation = PrimaryActionSurface.bCanExecute;
	Surface.ContinuationActionLabel = PrimaryActionSurface.bCanExecute
		? PrimaryActionSurface.ActionLabel
		: FString();
	Surface.ContinuationAvailabilityLine = PrimaryActionSurface.AvailabilityLine;
	Surface.ContinuationSourceLabel = PrimaryActionSurface.bCanExecute
		? PrimaryActionSurface.ActionSourceLabel
		: FString();
	Surface.QueueRecoveryStatusLine = QueueRecoveryPostureSurface.StatusLine;
	Surface.bQueueRecoveryOverridesContinuation =
		PrimaryActionSurface.bCanExecute
		&& (QueueRecoveryPostureSurface.PostureKind
				== EHyperTwistTrainingCoachQueuePostureKind::Promote
			|| QueueRecoveryPostureSurface.PostureKind
				== EHyperTwistTrainingCoachQueuePostureKind::Defer);

	const FString ContinuationKindLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachHandoffKind(
			PrimaryActionSurface.ActionKind
		);
	const FString QueuePostureLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachQueuePostureKind(
			QueueRecoveryPostureSurface.PostureKind
		);
	const FString GuidanceLaneLabel = HyperTwistTrainingCoachLibraryInternal::DescribeGuidanceLane(
		PanelState.PreferredGuidanceLane
	);
	const FString ContinuationSourceDescription = Surface.ContinuationSourceLabel.IsEmpty()
		? TEXT("n/a")
		: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
			Surface.ContinuationSourceLabel
		);
	const FString PreferredHandoffSourceDescription = PanelState.PreferredCoachHandoffSourceLabel.IsEmpty()
		? TEXT("n/a")
		: HyperTwistTrainingCoachLibraryInternal::DescribeCoachMemorySourceLabel(
			PanelState.PreferredCoachHandoffSourceLabel
		);

	if (Surface.bQueueRecoveryOverridesContinuation)
	{
		Surface.StatusLine =
			QueueRecoveryPostureSurface.PostureKind
				== EHyperTwistTrainingCoachQueuePostureKind::Promote
			? FString::Printf(
				TEXT("Continuation: %s coach work is ready, but queue recovery prefers deferred promotion before another run."),
				*ContinuationKindLabel
			)
			: FString::Printf(
				TEXT("Continuation: %s coach work is ready, but queue recovery is currently holding the next step on defer control."),
				*ContinuationKindLabel
			);
	}
	else
	{
		switch (PrimaryActionSurface.ActionKind)
		{
		case EHyperTwistTrainingCoachHandoffKind::Queue:
			Surface.StatusLine = FString::Printf(
				TEXT("Continuation: queued coach work is the live next handoff. Source: %s"),
				*ContinuationSourceDescription
			);
			break;
		case EHyperTwistTrainingCoachHandoffKind::FollowUp:
			Surface.StatusLine = FString::Printf(
				TEXT("Continuation: follow-up coach work is the live next handoff. Source: %s"),
				*ContinuationSourceDescription
			);
			break;
		case EHyperTwistTrainingCoachHandoffKind::Recommended:
			Surface.StatusLine = FString::Printf(
				TEXT("Continuation: recommended coach work is the live next handoff. Source: %s"),
				*ContinuationSourceDescription
			);
			break;
		default:
			if (QueueRecoveryPostureSurface.PostureKind
				== EHyperTwistTrainingCoachQueuePostureKind::Promote)
			{
				Surface.StatusLine = TEXT(
					"Continuation: no queued, follow-up, or recommended coach run is currently actionable; queue recovery prefers deferred promotion next."
				);
			}
			else if (QueueRecoveryPostureSurface.PostureKind
				== EHyperTwistTrainingCoachQueuePostureKind::Defer)
			{
				Surface.StatusLine = TEXT(
					"Continuation: no queued, follow-up, or recommended coach run is currently actionable; defer is the available queue-recovery control."
				);
			}
			else if (PanelState.bHasActiveRun)
			{
				Surface.StatusLine = TEXT(
					"Continuation: finish or clear the active run before another coach handoff becomes actionable."
				);
			}
			else if (QueueRecoveryPostureSurface.bHasRecoveryPressure)
			{
				Surface.StatusLine = TEXT(
					"Continuation: no queued, follow-up, or recommended coach run is currently actionable; queue recovery pressure remains active."
				);
			}
			else
			{
				Surface.StatusLine = TEXT(
					"Continuation: no queued, follow-up, or recommended coach run is currently actionable."
				);
			}
			break;
		}
	}

	Surface.DetailLine = FString::Printf(
		TEXT("Live continuation: %s | Primary CTA: %s | Availability: %s | Queue posture: %s | Queue recovery: %s | Preferred handoff: %s from %s | Guidance lane: %s"),
		*ContinuationKindLabel,
		PrimaryActionSurface.bCanExecute
				&& !PrimaryActionSurface.ActionLabel.IsEmpty()
			? *PrimaryActionSurface.ActionLabel
			: TEXT("n/a"),
		PrimaryActionSurface.AvailabilityLine.IsEmpty()
			? TEXT("n/a")
			: *PrimaryActionSurface.AvailabilityLine,
		*QueuePostureLabel,
		QueueRecoveryPostureSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *QueueRecoveryPostureSurface.StatusLine,
		*HyperTwistTrainingCoachLibraryInternal::DescribeCoachHandoffKind(
			PanelState.PreferredCoachHandoffKind
		),
		*PreferredHandoffSourceDescription,
		*GuidanceLaneLabel
	);
	if (!PrimaryActionSurface.DetailLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Primary detail: %s"),
			*PrimaryActionSurface.DetailLine
		);
	}
	if (QueueRecoveryPostureSurface.PostureKind
		== EHyperTwistTrainingCoachQueuePostureKind::Promote
		&& !QueueControlSurface.PromoteAvailabilityLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Promote: %s"),
			*QueueControlSurface.PromoteAvailabilityLine
		);
	}
	else if (QueueRecoveryPostureSurface.PostureKind
		== EHyperTwistTrainingCoachQueuePostureKind::Defer
		&& !QueueControlSurface.DeferAvailabilityLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Defer: %s"),
			*QueueControlSurface.DeferAvailabilityLine
		);
	}

	return Surface;
}

FHyperTwistTrainingCoachFocusProvenanceSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachFocusProvenanceSurface(
	const FHyperTwistTrainingCoachPanelState& PanelState,
	const FHyperTwistTrainingCoachPrimaryActionSurface& PrimaryActionSurface,
	const FHyperTwistTrainingCoachQueueControlSurface& QueueControlSurface,
	const FHyperTwistTrainingCoachQueueRecoveryPostureSurface& QueueRecoveryPostureSurface,
	const FHyperTwistTrainingCoachHandoffContinuationSurface& HandoffContinuationSurface
)
{
	FHyperTwistTrainingCoachFocusProvenanceSurface Surface;
	Surface.Headline = TEXT("Coach Focus");
	Surface.FocusHeadline = !PrimaryActionSurface.Headline.IsEmpty()
		? PrimaryActionSurface.Headline
		: PanelState.Headline;
	Surface.FocusDeckId = !PrimaryActionSurface.FocusDeckId.IsEmpty()
		? PrimaryActionSurface.FocusDeckId
		: PanelState.FocusDeckId;
	Surface.FocusMethodSegmentId = !PrimaryActionSurface.FocusMethodSegmentId.IsEmpty()
		? PrimaryActionSurface.FocusMethodSegmentId
		: PanelState.FocusMethodSegmentId;
	Surface.ContinuationKind = HandoffContinuationSurface.ContinuationKind;
	Surface.QueuePostureKind = QueueRecoveryPostureSurface.PostureKind;
	Surface.PreferredGuidanceLane = PanelState.PreferredGuidanceLane;
	Surface.bHasFocusTarget =
		!Surface.FocusDeckId.IsEmpty() || !Surface.FocusMethodSegmentId.IsEmpty();

	if (HandoffContinuationSurface.bQueueRecoveryOverridesContinuation)
	{
		if (QueueRecoveryPostureSurface.PostureKind
			== EHyperTwistTrainingCoachQueuePostureKind::Promote)
		{
			Surface.ActiveActionLabel = QueueControlSurface.PromoteActionLabel;
			Surface.ActiveSourceLabel = !QueueControlSurface.PromoteActionSourceLabel.IsEmpty()
				? QueueControlSurface.PromoteActionSourceLabel
				: (!QueueRecoveryPostureSurface.PreferredActionSourceLabel.IsEmpty()
					? QueueRecoveryPostureSurface.PreferredActionSourceLabel
					: PanelState.PreferredQueueRecoveryActionSourceLabel);
		}
		else if (QueueRecoveryPostureSurface.PostureKind
			== EHyperTwistTrainingCoachQueuePostureKind::Defer)
		{
			Surface.ActiveActionLabel = QueueControlSurface.DeferActionLabel;
			Surface.ActiveSourceLabel = !QueueRecoveryPostureSurface.PreferredActionSourceLabel.IsEmpty()
				? QueueRecoveryPostureSurface.PreferredActionSourceLabel
				: (!PanelState.PreferredQueueRecoveryActionSourceLabel.IsEmpty()
					? PanelState.PreferredQueueRecoveryActionSourceLabel
					: PanelState.PreferredCoachHandoffSourceLabel);
		}
	}
	else if (HandoffContinuationSurface.bHasActionableContinuation)
	{
		Surface.ActiveActionLabel = HandoffContinuationSurface.ContinuationActionLabel;
		Surface.ActiveSourceLabel = !HandoffContinuationSurface.ContinuationSourceLabel.IsEmpty()
			? HandoffContinuationSurface.ContinuationSourceLabel
			: PanelState.PreferredCoachHandoffSourceLabel;
	}
	else if (QueueRecoveryPostureSurface.bCanExecutePreferredAction)
	{
		Surface.ActiveActionLabel = QueueRecoveryPostureSurface.PreferredActionLabel;
		Surface.ActiveSourceLabel = !QueueRecoveryPostureSurface.PreferredActionSourceLabel.IsEmpty()
			? QueueRecoveryPostureSurface.PreferredActionSourceLabel
			: PanelState.PreferredQueueRecoveryActionSourceLabel;
	}

	Surface.ActiveSourceDescription =
		HyperTwistTrainingCoachLibraryInternal::DescribeGameplayCoachSourceLabel(
			Surface.ActiveSourceLabel
		);
	Surface.GuidanceSourceDescription =
		HyperTwistTrainingCoachLibraryInternal::DescribeGameplayCoachSourceLabel(
			PanelState.PreferredGuidanceSourceLabel
		);
	Surface.HandoffSourceDescription =
		HyperTwistTrainingCoachLibraryInternal::DescribeGameplayCoachSourceLabel(
			PanelState.PreferredCoachHandoffSourceLabel
		);
	Surface.QueueSourceDescription =
		HyperTwistTrainingCoachLibraryInternal::DescribeGameplayCoachSourceLabel(
			PanelState.NextQueueSourceLabel
		);
	Surface.RecoverySourceDescription =
		HyperTwistTrainingCoachLibraryInternal::DescribeGameplayCoachSourceLabel(
			PanelState.PreferredQueueRecoveryActionSourceLabel
		);
	Surface.LaunchBudgetSourceDescription =
		HyperTwistTrainingCoachLibraryInternal::DescribeGameplayCoachSourceLabel(
			PanelState.PreferredLaunchBudgetSourceLabel
		);
	Surface.bHasUpstreamProvenance =
		!Surface.ActiveSourceLabel.IsEmpty()
		|| !PanelState.PreferredGuidanceSourceLabel.IsEmpty()
		|| !PanelState.PreferredCoachHandoffSourceLabel.IsEmpty()
		|| !PanelState.NextQueueSourceLabel.IsEmpty()
		|| !PanelState.PreferredQueueRecoveryActionSourceLabel.IsEmpty()
		|| !PanelState.PreferredLaunchBudgetSourceLabel.IsEmpty();

	const FString FocusTargetLabel = HyperTwistTrainingCoachLibraryInternal::DescribeCoachFocusTargetLabel(
		Surface.FocusDeckId,
		Surface.FocusMethodSegmentId
	);
	const FString ContinuationKindLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachHandoffKind(
			Surface.ContinuationKind
		);
	const FString QueuePostureLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachQueuePostureKind(
			Surface.QueuePostureKind
		);
	const FString GuidanceLaneLabel = HyperTwistTrainingCoachLibraryInternal::DescribeGuidanceLane(
		Surface.PreferredGuidanceLane
	);

	Surface.FocusSummaryLine = FString::Printf(
		TEXT("Focus target: %s | Active action: %s | Continuation: %s"),
		*FocusTargetLabel,
		Surface.ActiveActionLabel.IsEmpty() ? TEXT("none") : *Surface.ActiveActionLabel,
		*ContinuationKindLabel
	);
	if (!Surface.FocusHeadline.IsEmpty())
	{
		Surface.FocusSummaryLine += FString::Printf(
			TEXT(" | Headline: %s"),
			*Surface.FocusHeadline
		);
	}

	Surface.ProvenanceSummaryLine = FString::Printf(
		TEXT("Active provenance: %s | Guidance: %s | Handoff: %s | Recovery: %s"),
		*Surface.ActiveSourceDescription,
		*Surface.GuidanceSourceDescription,
		*Surface.HandoffSourceDescription,
		*Surface.RecoverySourceDescription
	);

	Surface.DetailLine = FString::Printf(
		TEXT("Queue posture: %s | Preferred lane: %s | Queue source: %s | Launch budget source: %s | Handoff status: %s | Queue recovery: %s"),
		*QueuePostureLabel,
		*GuidanceLaneLabel,
		*Surface.QueueSourceDescription,
		*Surface.LaunchBudgetSourceDescription,
		HandoffContinuationSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *HandoffContinuationSurface.StatusLine,
		QueueRecoveryPostureSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *QueueRecoveryPostureSurface.StatusLine
	);
	if (!HandoffContinuationSurface.DetailLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Continuation detail: %s"),
			*HandoffContinuationSurface.DetailLine
		);
	}

	return Surface;
}

FHyperTwistTrainingCoachWorkloadBudgetSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachWorkloadBudgetSurface(
	const FHyperTwistTrainingCoachPanelState& PanelState,
	const FHyperTwistTrainingCoachQueueRecoveryPostureSurface& QueueRecoveryPostureSurface,
	const FHyperTwistTrainingCoachHandoffContinuationSurface& HandoffContinuationSurface,
	const FHyperTwistTrainingCoachFocusProvenanceSurface& FocusProvenanceSurface
)
{
	FHyperTwistTrainingCoachWorkloadBudgetSurface Surface;
	Surface.Headline = TEXT("Coach Workload");
	Surface.SignalCount = FMath::Max(PanelState.SignalCount, 0);
	Surface.FocusCaseCount = FMath::Max(PanelState.FocusCaseCount, 0);
	Surface.SuggestedLaunchCaseBudget = FMath::Max(PanelState.SuggestedLaunchCaseBudget, 0);
	Surface.TotalQueueEntryCount = FMath::Max(PanelState.TotalQueueEntryCount, 0);
	Surface.ReadyQueueEntryCount = FMath::Max(PanelState.ReadyQueueEntryCount, 0);
	Surface.DeferredQueueEntryCount = FMath::Max(PanelState.DeferredQueueEntryCount, 0);
	Surface.FollowUpQueueEntryCount = FMath::Max(PanelState.FollowUpQueueEntryCount, 0);
	Surface.PressureScore = FMath::Max(QueueRecoveryPostureSurface.PressureScore, 0.0f);
	Surface.ContinuationKind = HandoffContinuationSurface.ContinuationKind;
	Surface.QueuePostureKind = QueueRecoveryPostureSurface.PostureKind;
	Surface.bHasFocusPressure = Surface.SignalCount > 0 || Surface.FocusCaseCount > 0;
	Surface.bHasQueueLoad = Surface.TotalQueueEntryCount > 0
		|| Surface.ReadyQueueEntryCount > 0
		|| Surface.DeferredQueueEntryCount > 0
		|| Surface.FollowUpQueueEntryCount > 0;
	Surface.bHasLaunchBudget = Surface.SuggestedLaunchCaseBudget > 0
		|| !PanelState.LaunchBudgetReasonLine.IsEmpty();
	Surface.bHasQueuePressure = QueueRecoveryPostureSurface.bHasRecoveryPressure
		|| QueueRecoveryPostureSurface.PostureKind
			!= EHyperTwistTrainingCoachQueuePostureKind::None
		|| Surface.PressureScore > 0.0f;

	const FString ContinuationKindLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachHandoffKind(
			Surface.ContinuationKind
		);
	const FString QueuePostureLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachQueuePostureKind(
			Surface.QueuePostureKind
		);

	Surface.StatusLine = FString::Printf(
		TEXT("Workload: %d signals across %d focus cases | Queue: %d total (%d ready, %d deferred, %d follow-up) | Continuation: %s"),
		Surface.SignalCount,
		Surface.FocusCaseCount,
		Surface.TotalQueueEntryCount,
		Surface.ReadyQueueEntryCount,
		Surface.DeferredQueueEntryCount,
		Surface.FollowUpQueueEntryCount,
		*ContinuationKindLabel
	);
	if (Surface.SuggestedLaunchCaseBudget > 0)
	{
		Surface.StatusLine += FString::Printf(
			TEXT(" | Launch cases: %d"),
			Surface.SuggestedLaunchCaseBudget
		);
	}
	if (Surface.bHasQueuePressure)
	{
		Surface.StatusLine += FString::Printf(
			TEXT(" | Pressure: %.2f"),
			Surface.PressureScore
		);
	}

	Surface.FocusPressureLine = FString::Printf(
		TEXT("Focus: %d signals | Cases: %d%s"),
		Surface.SignalCount,
		Surface.FocusCaseCount,
		Surface.SuggestedLaunchCaseBudget > 0
			? *FString::Printf(
				TEXT(" | Launch cases: %d"),
				Surface.SuggestedLaunchCaseBudget)
			: TEXT("")
	);

	Surface.QueueLoadLine = !PanelState.QueueStatusLine.IsEmpty()
		? PanelState.QueueStatusLine
		: FString::Printf(
			TEXT("Queue: %d total, %d ready, %d deferred"),
			Surface.TotalQueueEntryCount,
			Surface.ReadyQueueEntryCount,
			Surface.DeferredQueueEntryCount
		);
	Surface.QueueLoadLine += FString::Printf(
		TEXT(" | Follow-up entries: %d"),
		Surface.FollowUpQueueEntryCount
	);

	Surface.BudgetLine = Surface.SuggestedLaunchCaseBudget > 0
		? FString::Printf(
			TEXT("Launch budget: %d cases"),
			Surface.SuggestedLaunchCaseBudget
		)
		: TEXT("Launch budget: no explicit case budget");
	if (!FocusProvenanceSurface.LaunchBudgetSourceDescription.IsEmpty()
		&& FocusProvenanceSurface.LaunchBudgetSourceDescription != TEXT("n/a"))
	{
		Surface.BudgetLine += FString::Printf(
			TEXT(" | Source: %s"),
			*FocusProvenanceSurface.LaunchBudgetSourceDescription
		);
	}
	if (!PanelState.LaunchBudgetReasonLine.IsEmpty())
	{
		Surface.BudgetLine += FString::Printf(
			TEXT(" | Reason: %s"),
			*PanelState.LaunchBudgetReasonLine
		);
	}

	Surface.DetailLine = FString::Printf(
		TEXT("Queue posture: %s | Focus summary: %s | Queue status: %s | Continuation status: %s | Queue recovery: %s"),
		*QueuePostureLabel,
		FocusProvenanceSurface.FocusSummaryLine.IsEmpty()
			? TEXT("n/a")
			: *FocusProvenanceSurface.FocusSummaryLine,
		PanelState.QueueStatusLine.IsEmpty()
			? TEXT("n/a")
			: *PanelState.QueueStatusLine,
		HandoffContinuationSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *HandoffContinuationSurface.StatusLine,
		QueueRecoveryPostureSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *QueueRecoveryPostureSurface.StatusLine
	);

	return Surface;
}

FHyperTwistTrainingCoachReadinessEligibilitySurface
UHyperTwistTrainingCoachLibrary::DeriveCoachReadinessEligibilitySurface(
	const FHyperTwistTrainingCoachPanelState& PanelState,
	const FHyperTwistTrainingCoachPrimaryActionSurface& PrimaryActionSurface,
	const FHyperTwistTrainingCoachQueueControlSurface& QueueControlSurface,
	const FHyperTwistTrainingCoachQueueRecoveryPostureSurface& QueueRecoveryPostureSurface,
	const FHyperTwistTrainingCoachHandoffContinuationSurface& HandoffContinuationSurface,
	const FHyperTwistTrainingCoachFocusProvenanceSurface& FocusProvenanceSurface,
	const FHyperTwistTrainingCoachWorkloadBudgetSurface& WorkloadBudgetSurface
)
{
	auto ResolveFirstNonEmpty = [](
		const FString& First,
		const FString& Second,
		const FString& Third
	) -> FString
	{
		if (!First.IsEmpty())
		{
			return First;
		}
		if (!Second.IsEmpty())
		{
			return Second;
		}

		return Third;
	};

	FHyperTwistTrainingCoachReadinessEligibilitySurface Surface;
	Surface.Headline = TEXT("Coach Readiness");
	Surface.ContinuationKind = HandoffContinuationSurface.ContinuationKind;
	Surface.QueuePostureKind = QueueRecoveryPostureSurface.PostureKind;
	Surface.bBlockedByActiveRun = PanelState.bHasActiveRun;
	Surface.bBlockedByQueueSuppression = !PanelState.QueueSuppressionLine.IsEmpty();
	Surface.bNeedsVerificationAttention = PanelState.bRepositoryVerificationNeedsAttention;

	const bool bHasReadinessPressure = PanelState.bHasCoachGuidance
		|| PanelState.bHasFollowUpGuidance
		|| PanelState.bHasQueueWork
		|| PanelState.bHasDeferredQueueWork
		|| QueueRecoveryPostureSurface.bHasRecoveryPressure
		|| WorkloadBudgetSurface.bHasFocusPressure
		|| WorkloadBudgetSurface.bHasQueueLoad
		|| WorkloadBudgetSurface.bHasLaunchBudget;

	if (HandoffContinuationSurface.bHasActionableContinuation
		&& !HandoffContinuationSurface.bQueueRecoveryOverridesContinuation)
	{
		Surface.EligibilityKind = EHyperTwistTrainingCoachEligibilityKind::PrimaryAction;
		Surface.bHasActionableControl = true;
		Surface.ActionLabel = !HandoffContinuationSurface.ContinuationActionLabel.IsEmpty()
			? HandoffContinuationSurface.ContinuationActionLabel
			: PrimaryActionSurface.ActionLabel;
		Surface.ActionSourceLabel = ResolveFirstNonEmpty(
			HandoffContinuationSurface.ContinuationSourceLabel,
			PrimaryActionSurface.ActionSourceLabel,
			PanelState.PreferredCoachHandoffSourceLabel
		);
		Surface.StatusLine = TEXT("Readiness: primary coach continuation is actionable now.");
		Surface.EligibilityLine = ResolveFirstNonEmpty(
			HandoffContinuationSurface.StatusLine,
			PrimaryActionSurface.AvailabilityLine,
			TEXT("Coach continuation is actionable now.")
		);
	}
	else if (QueueRecoveryPostureSurface.PostureKind
			== EHyperTwistTrainingCoachQueuePostureKind::Promote
		&& QueueControlSurface.bCanPromote)
	{
		Surface.EligibilityKind = EHyperTwistTrainingCoachEligibilityKind::Promote;
		Surface.bHasActionableControl = true;
		Surface.ActionLabel = QueueControlSurface.PromoteActionLabel;
		Surface.ActionSourceLabel = ResolveFirstNonEmpty(
			QueueControlSurface.PromoteActionSourceLabel,
			QueueRecoveryPostureSurface.PreferredActionSourceLabel,
			PanelState.PreferredQueueRecoveryActionSourceLabel
		);
		Surface.StatusLine =
			TEXT("Readiness: deferred promotion is the actionable next coach control.");
		Surface.EligibilityLine = ResolveFirstNonEmpty(
			QueueRecoveryPostureSurface.StatusLine,
			QueueControlSurface.PromoteAvailabilityLine,
			TEXT("Deferred promotion is actionable now.")
		);
	}
	else if (QueueRecoveryPostureSurface.PostureKind
			== EHyperTwistTrainingCoachQueuePostureKind::Defer
		&& QueueControlSurface.bCanDefer)
	{
		Surface.EligibilityKind = EHyperTwistTrainingCoachEligibilityKind::Defer;
		Surface.bHasActionableControl = true;
		Surface.ActionLabel = QueueControlSurface.DeferActionLabel;
		Surface.ActionSourceLabel = ResolveFirstNonEmpty(
			QueueRecoveryPostureSurface.PreferredActionSourceLabel,
			PanelState.PreferredQueueRecoveryActionSourceLabel,
			PanelState.PreferredCoachHandoffSourceLabel
		);
		Surface.StatusLine =
			TEXT("Readiness: defer is the actionable queue-pressure release control.");
		Surface.EligibilityLine = ResolveFirstNonEmpty(
			QueueRecoveryPostureSurface.StatusLine,
			QueueControlSurface.DeferAvailabilityLine,
			TEXT("Defer is actionable now.")
		);
	}
	else if (PanelState.bHasActiveRun)
	{
		Surface.EligibilityKind = EHyperTwistTrainingCoachEligibilityKind::ActiveRunBlocked;
		Surface.bHasBlockingCondition = true;
		Surface.StatusLine =
			TEXT("Readiness: coach continuation is blocked while a training run is already active.");
		Surface.EligibilityLine = ResolveFirstNonEmpty(
			HandoffContinuationSurface.StatusLine,
			PrimaryActionSurface.AvailabilityLine,
			TEXT("Finish or clear the active run before another coach action can start.")
		);
		Surface.BlockedReasonLine =
			TEXT("A training run is already active.");
	}
	else if (!PanelState.QueueSuppressionLine.IsEmpty())
	{
		Surface.EligibilityKind = EHyperTwistTrainingCoachEligibilityKind::QueueSuppressed;
		Surface.bHasBlockingCondition = true;
		Surface.StatusLine =
			TEXT("Readiness: no coach action is currently actionable because queue suppression is still active.");
		Surface.EligibilityLine = PanelState.QueueSuppressionLine;
		Surface.BlockedReasonLine = PanelState.QueueSuppressionLine;
	}
	else
	{
		Surface.EligibilityKind = EHyperTwistTrainingCoachEligibilityKind::NoEligibleAction;
		Surface.bHasBlockingCondition = bHasReadinessPressure;
		if (bHasReadinessPressure)
		{
			Surface.StatusLine = TEXT("Readiness: no coach control is actionable right now.");
			Surface.EligibilityLine = ResolveFirstNonEmpty(
				HandoffContinuationSurface.StatusLine,
				QueueRecoveryPostureSurface.StatusLine,
				ResolveFirstNonEmpty(
					PrimaryActionSurface.AvailabilityLine,
					PanelState.SecondaryLine,
					TEXT("No coach control is currently actionable.")
				)
			);
			Surface.BlockedReasonLine = ResolveFirstNonEmpty(
				QueueRecoveryPostureSurface.StatusLine,
				PrimaryActionSurface.AvailabilityLine,
				Surface.EligibilityLine
			);
		}
		else
		{
			Surface.StatusLine =
				TEXT("Readiness: coach lane is idle and no action is currently needed.");
			Surface.EligibilityLine = ResolveFirstNonEmpty(
				WorkloadBudgetSurface.StatusLine,
				PanelState.SecondaryLine,
				TEXT("No queued, follow-up, or recommended coach work is currently materialized.")
			);
		}
	}

	Surface.ActionSourceDescription =
		HyperTwistTrainingCoachLibraryInternal::DescribeGameplayCoachSourceLabel(
			Surface.ActionSourceLabel
		);

	const FString EligibilityKindLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachEligibilityKind(
			Surface.EligibilityKind
		);
	const FString QueuePostureLabel =
		HyperTwistTrainingCoachLibraryInternal::DescribeCoachQueuePostureKind(
			Surface.QueuePostureKind
		);

	Surface.DetailLine = FString::Printf(
		TEXT("Eligibility: %s | Action: %s | Source: %s | Continuation: %s | Queue posture: %s | Workload: %s | Verification: %s | Recognition: %s | Review: %s"),
		*EligibilityKindLabel,
		Surface.ActionLabel.IsEmpty() ? TEXT("none") : *Surface.ActionLabel,
		*Surface.ActionSourceDescription,
		HandoffContinuationSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *HandoffContinuationSurface.StatusLine,
		*QueuePostureLabel,
		WorkloadBudgetSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *WorkloadBudgetSurface.StatusLine,
		PanelState.VerificationStatusLine.IsEmpty()
			? TEXT("n/a")
			: *PanelState.VerificationStatusLine,
		PanelState.RecognitionStatusLine.IsEmpty()
			? TEXT("n/a")
			: *PanelState.RecognitionStatusLine,
		PanelState.ReviewPolicyStatusLine.IsEmpty()
			? TEXT("n/a")
			: *PanelState.ReviewPolicyStatusLine
	);
	if (!FocusProvenanceSurface.FocusSummaryLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Focus: %s"),
			*FocusProvenanceSurface.FocusSummaryLine
		);
	}
	if (!Surface.BlockedReasonLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Blocked reason: %s"),
			*Surface.BlockedReasonLine
		);
	}

	return Surface;
}

FHyperTwistTrainingCoachVerificationRecognitionReviewContextSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachVerificationRecognitionReviewContextSurface(
	const FHyperTwistTrainingCoachPanelState& PanelState,
	const FHyperTwistTrainingCoachFocusProvenanceSurface& FocusProvenanceSurface,
	const FHyperTwistTrainingCoachWorkloadBudgetSurface& WorkloadBudgetSurface,
	const FHyperTwistTrainingCoachReadinessEligibilitySurface& ReadinessEligibilitySurface
)
{
	FHyperTwistTrainingCoachVerificationRecognitionReviewContextSurface Surface;
	Surface.Headline = TEXT("Coach Context");
	Surface.VerificationLine = !PanelState.VerificationStatusLine.IsEmpty()
		? PanelState.VerificationStatusLine
		: TEXT("Verification: n/a");
	Surface.RecognitionLine = !PanelState.RecognitionStatusLine.IsEmpty()
		? PanelState.RecognitionStatusLine
		: TEXT("Recognition: n/a");
	Surface.RecognitionDetailLine = !PanelState.RecognitionDetailLine.IsEmpty()
		? PanelState.RecognitionDetailLine
		: TEXT("Recognition detail: n/a");
	Surface.ReviewPolicyLine = !PanelState.ReviewPolicyStatusLine.IsEmpty()
		? PanelState.ReviewPolicyStatusLine
		: TEXT("Review: n/a");
	Surface.ReviewPolicyDetailLine = !PanelState.ReviewPolicyDetailLine.IsEmpty()
		? PanelState.ReviewPolicyDetailLine
		: TEXT("Review detail: n/a");
	Surface.PreferredGuidanceLane = FocusProvenanceSurface.PreferredGuidanceLane;
	Surface.bVerificationPassed = PanelState.bRepositoryVerificationPassed;
	Surface.bVerificationNeedsAttention = PanelState.bRepositoryVerificationNeedsAttention;
	Surface.RecognitionProviderLabel =
		HyperTwistTrainingCoachLibraryInternal::ExtractDelimitedStatusFieldValue(
			Surface.RecognitionLine,
			TEXT("Recognition:")
		);
	Surface.RecognitionTransportState =
		HyperTwistTrainingCoachLibraryInternal::ExtractDelimitedStatusFieldValue(
			Surface.RecognitionLine,
			TEXT("Service:")
		);
	Surface.bRecognitionReady = Surface.RecognitionTransportState.Equals(
		TEXT("ready"),
		ESearchCase::IgnoreCase
	);
	Surface.ReviewPolicyStateLabel =
		HyperTwistTrainingCoachLibraryInternal::ExtractDelimitedStatusFieldValue(
			Surface.ReviewPolicyLine,
			TEXT("Review:")
		);
	Surface.ReviewPolicyLabel =
		HyperTwistTrainingCoachLibraryInternal::ExtractDelimitedStatusFieldValue(
			Surface.ReviewPolicyLine,
			TEXT("Policy:")
		);
	Surface.ReviewDeliveryModeLabel =
		HyperTwistTrainingCoachLibraryInternal::ExtractDelimitedStatusFieldValue(
			Surface.ReviewPolicyLine,
			TEXT("Mode:")
		);
	const FString RecognitionReviewPreference =
		HyperTwistTrainingCoachLibraryInternal::ExtractDelimitedStatusFieldValue(
			Surface.ReviewPolicyLine,
			TEXT("Recognition review:")
		);
	Surface.bPreferRecognitionReview = RecognitionReviewPreference.Equals(
		TEXT("preferred"),
		ESearchCase::IgnoreCase
	);
	Surface.bHasMaterializedReviewPolicy = !Surface.ReviewPolicyStateLabel.IsEmpty()
		&& !Surface.ReviewPolicyStateLabel.Equals(
			TEXT("no active review policy is materialized"),
			ESearchCase::IgnoreCase
		);

	const FString VerificationSummary = Surface.bVerificationPassed
		? TEXT("passed")
		: (Surface.bVerificationNeedsAttention ? TEXT("needs attention") : TEXT("not run yet"));
	const FString RecognitionProviderSummary = Surface.RecognitionProviderLabel.IsEmpty()
		? TEXT("n/a")
		: Surface.RecognitionProviderLabel;
	const FString RecognitionTransportSummary = Surface.RecognitionTransportState.IsEmpty()
		? TEXT("n/a")
		: Surface.RecognitionTransportState;
	const FString ReviewStateSummary = Surface.ReviewPolicyStateLabel.IsEmpty()
		? TEXT("n/a")
		: Surface.ReviewPolicyStateLabel;

	Surface.StatusLine = FString::Printf(
		TEXT("Context: verification %s | recognition %s (%s) | review %s"),
		*VerificationSummary,
		*RecognitionProviderSummary,
		*RecognitionTransportSummary,
		*ReviewStateSummary
	);
	if (!Surface.ReviewPolicyLabel.IsEmpty())
	{
		Surface.StatusLine += FString::Printf(
			TEXT(" | policy: %s"),
			*Surface.ReviewPolicyLabel
		);
	}
	if (Surface.bPreferRecognitionReview)
	{
		Surface.StatusLine += TEXT(" | recognition review preferred");
	}

	const FString GuidanceLaneLabel = HyperTwistTrainingCoachLibraryInternal::DescribeGuidanceLane(
		Surface.PreferredGuidanceLane
	);
	Surface.DetailLine = FString::Printf(
		TEXT("Readiness: %s | Workload: %s | Verification: %s | Recognition detail: %s | Review detail: %s | Guidance lane: %s"),
		ReadinessEligibilitySurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *ReadinessEligibilitySurface.StatusLine,
		WorkloadBudgetSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *WorkloadBudgetSurface.StatusLine,
		*Surface.VerificationLine,
		*Surface.RecognitionDetailLine,
		*Surface.ReviewPolicyDetailLine,
		*GuidanceLaneLabel
	);
	if (!FocusProvenanceSurface.ProvenanceSummaryLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Provenance: %s"),
			*FocusProvenanceSurface.ProvenanceSummaryLine
		);
	}
	if (!ReadinessEligibilitySurface.BlockedReasonLine.IsEmpty())
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Blocked: %s"),
			*ReadinessEligibilitySurface.BlockedReasonLine
		);
	}

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeLaunchExecutionContextSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeLaunchExecutionContextSurface(
	const FHyperTwistTrainingCoachPanelState& PanelState,
	const FHyperTwistTrainingCoachReadinessEligibilitySurface& ReadinessEligibilitySurface,
	const FHyperTwistTrainingCoachVerificationRecognitionReviewContextSurface&
		VerificationRecognitionReviewContextSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeLaunchExecutionContextSurface Surface;
	Surface.Headline = TEXT("Generated Mode");
	Surface.bHasLatestLaunchRequest = PanelState.bHasLatestGeneratedModeLaunchRequest;
	Surface.bHasExecutionTarget = PanelState.bHasActiveGeneratedModeExecutionTarget;
	Surface.bCanExecute = PanelState.bCanExecuteActiveGeneratedModeLaunchRequest;
	Surface.bWillRefreshLaunchRequestOnExecute =
		PanelState.bActiveGeneratedModeExecutionWillRefreshLaunchRequest;
	Surface.LatestLaunchRequestId = PanelState.LatestGeneratedModeLaunchRequestId;
	Surface.LatestLaunchRequestedAtUtc = PanelState.LatestGeneratedModeLaunchRequestedAtUtc;
	Surface.LatestRuntimeModeId = PanelState.LatestGeneratedModeRuntimeModeId;
	Surface.SelectorSummaryLine = PanelState.LatestGeneratedModeSelectorSummaryLine;
	Surface.BlockedReasonLine = PanelState.ActiveGeneratedModeExecutionBlockedReason;
	if (Surface.bHasExecutionTarget
		&& !Surface.bCanExecute
		&& Surface.BlockedReasonLine.IsEmpty())
	{
		Surface.BlockedReasonLine =
			TEXT("Finish the active selector choices before executing the owned generated run.");
	}
	Surface.bHasBlockedExecution = !Surface.BlockedReasonLine.IsEmpty();

	const FString RequestIdSummary = Surface.LatestLaunchRequestId.IsEmpty()
		? TEXT("n/a")
		: Surface.LatestLaunchRequestId;
	const FString RequestTimeSummary = Surface.LatestLaunchRequestedAtUtc.IsEmpty()
		? TEXT("n/a")
		: Surface.LatestLaunchRequestedAtUtc;
	const FString RuntimeModeSummary = Surface.LatestRuntimeModeId.IsEmpty()
		? TEXT("n/a")
		: Surface.LatestRuntimeModeId;
	const FString SelectorSummary = Surface.SelectorSummaryLine.IsEmpty()
		? TEXT("none")
		: Surface.SelectorSummaryLine;

	Surface.RequestLine = Surface.bHasLatestLaunchRequest
		? FString::Printf(
			TEXT("Request: %s @ %s | mode: %s"),
			*RequestIdSummary,
			*RequestTimeSummary,
			*RuntimeModeSummary
		)
		: TEXT("Request: none persisted for the active deck");
	Surface.SelectorLine = FString::Printf(
		TEXT("Selectors: %s"),
		*SelectorSummary
	);
	Surface.ExecutionLine = Surface.bHasExecutionTarget
		? FString::Printf(
			TEXT("Execution: ready %s | request refresh on execute: %s"),
			Surface.bCanExecute ? TEXT("yes") : TEXT("no"),
			Surface.bWillRefreshLaunchRequestOnExecute ? TEXT("yes") : TEXT("no")
		)
		: TEXT("Execution: no generated-mode execution target is currently staged");

	if (Surface.bHasExecutionTarget && Surface.bCanExecute)
	{
		Surface.StatusLine = Surface.bWillRefreshLaunchRequestOnExecute
			? TEXT("Generated mode: execution is ready and will refresh the stored request on execute.")
			: TEXT("Generated mode: execution is ready from the current stored request.");
	}
	else if (Surface.bHasExecutionTarget)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated mode: execution is blocked. %s"),
			*Surface.BlockedReasonLine
		);
	}
	else if (Surface.bHasLatestLaunchRequest)
	{
		Surface.StatusLine =
			TEXT("Generated mode: the latest request is persisted, but no active generated-mode execution target is staged.");
	}
	else
	{
		Surface.StatusLine =
			TEXT("Generated mode: no persisted request or execution target is currently available.");
	}

	Surface.DetailLine = FString::Printf(
		TEXT("Readiness: %s | Coach context: %s"),
		ReadinessEligibilitySurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *ReadinessEligibilitySurface.StatusLine,
		VerificationRecognitionReviewContextSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *VerificationRecognitionReviewContextSurface.StatusLine
	);
	if (Surface.bHasBlockedExecution)
	{
		Surface.DetailLine += FString::Printf(
			TEXT(" | Blocked: %s"),
			*Surface.BlockedReasonLine
		);
	}

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorApplicationContextSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorApplicationContextSurface(
	const FHyperTwistTrainingDeck& ActiveDeck,
	const FHyperTwistTrainingImportedRuntimeSelectionState& ImportedRuntimeSelectionState,
	const FHyperTwistTrainingImportedGeneratedModeLaunchConfig& LaunchConfig,
	const FHyperTwistTrainingCoachGeneratedModeLaunchExecutionContextSurface& LaunchExecutionContextSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorApplicationContextSurface Surface;
	Surface.Headline = TEXT("Generated Mode Selectors");

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = ActiveDeck.ImportedRuntimeSurface;
	Surface.bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	Surface.bHasSelectionState = ImportedRuntimeSelectionState.IsStructurallyValid();
	Surface.bHasLaunchConfig = LaunchConfig.IsStructurallyValid();
	Surface.bWillRefreshLaunchRequestOnExecute =
		LaunchExecutionContextSurface.bWillRefreshLaunchRequestOnExecute;
	Surface.bSelectionStateMatchesSurface = !Surface.bHasGeneratedModeSurface
		|| !Surface.bHasSelectionState
		|| ImportedRuntimeSelectionState.SurfaceId == RuntimeSurface.SurfaceId;

	Surface.SurfaceId = Surface.bHasLaunchConfig
		? LaunchConfig.SurfaceId
		: (Surface.bHasGeneratedModeSurface
			? RuntimeSurface.SurfaceId
			: ImportedRuntimeSelectionState.SurfaceId);
	Surface.SurfaceLabel = Surface.bHasLaunchConfig
		? LaunchConfig.SurfaceLabel
		: (Surface.bHasGeneratedModeSurface ? RuntimeSurface.SurfaceLabel : FString());
	Surface.SurfaceKind = Surface.bHasGeneratedModeSurface
		? RuntimeSurface.SurfaceKind
		: ImportedRuntimeSelectionState.SurfaceKind;
	Surface.RuntimeModeId = Surface.bHasLaunchConfig
		? LaunchConfig.RuntimeModeId
		: (Surface.bHasGeneratedModeSurface ? RuntimeSurface.RuntimeModeId : FString());
	Surface.GeneratorType = Surface.bHasLaunchConfig
		? LaunchConfig.GeneratorType
		: (Surface.bHasGeneratedModeSurface ? RuntimeSurface.GeneratorType : FString());

	TSet<FString> RequiredSelectorIds;
	if (Surface.bHasGeneratedModeSurface)
	{
		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (Selector.IsStructurallyValid())
			{
				RequiredSelectorIds.Add(Selector.SelectorId);
			}
		}
	}
	Surface.RequiredSelectorCount = RequiredSelectorIds.Num();

	TSet<FString> SelectedSelectorIds;
	if (Surface.bHasSelectionState)
	{
		for (const FHyperTwistTrainingImportedRuntimeSelectorChoice& Choice :
			ImportedRuntimeSelectionState.SelectorChoices)
		{
			if (!Choice.IsStructurallyValid())
			{
				continue;
			}
			if (RequiredSelectorIds.Num() > 0 && !RequiredSelectorIds.Contains(Choice.SelectorId))
			{
				continue;
			}
			SelectedSelectorIds.Add(Choice.SelectorId);
		}
	}
	Surface.SelectedSelectorCount = SelectedSelectorIds.Num();
	Surface.MissingSelectorCount = FMath::Max(
		Surface.RequiredSelectorCount - Surface.SelectedSelectorCount,
		0
	);
	Surface.bHasFullSelectorCoverage = Surface.bHasLaunchConfig
		|| (Surface.bHasSelectionState
			&& Surface.bSelectionStateMatchesSurface
			&& Surface.RequiredSelectorCount > 0
			&& Surface.MissingSelectorCount == 0);

	const FString SurfaceLabelSummary = Surface.SurfaceLabel.IsEmpty()
		? (Surface.SurfaceId.IsEmpty() ? TEXT("n/a") : Surface.SurfaceId)
		: Surface.SurfaceLabel;
	const FString SurfaceIdSummary = Surface.SurfaceId.IsEmpty() ? TEXT("n/a") : Surface.SurfaceId;
	const FString SurfaceKindSummary = Surface.SurfaceKind.IsEmpty() ? TEXT("n/a") : Surface.SurfaceKind;
	const FString RuntimeModeSummary = Surface.RuntimeModeId.IsEmpty() ? TEXT("n/a") : Surface.RuntimeModeId;
	const FString GeneratorSummary = Surface.GeneratorType.IsEmpty() ? TEXT("n/a") : Surface.GeneratorType;
	const FString CoverageSuffix = Surface.MissingSelectorCount > 0
		? FString::Printf(TEXT(" | missing: %d"), Surface.MissingSelectorCount)
		: FString();

	if (Surface.RequiredSelectorCount > 0)
	{
		Surface.CoverageLine = FString::Printf(
			TEXT("Coverage: %d/%d selectors selected%s"),
			Surface.SelectedSelectorCount,
			Surface.RequiredSelectorCount,
			*CoverageSuffix
		);
	}
	else if (Surface.bHasSelectionState)
	{
		Surface.CoverageLine = FString::Printf(
			TEXT("Coverage: %d selector choice%s cached"),
			Surface.SelectedSelectorCount,
			Surface.SelectedSelectorCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else
	{
		Surface.CoverageLine = TEXT("Coverage: no generated-mode selector choices are cached");
	}
	if (!Surface.bSelectionStateMatchesSurface && Surface.bHasGeneratedModeSurface && Surface.bHasSelectionState)
	{
		Surface.CoverageLine += TEXT(" | selection state is bound to a different surface");
	}

	Surface.IdentityLine = FString::Printf(
		TEXT("Identity: %s | kind: %s | mode: %s | generator: %s"),
		*SurfaceLabelSummary,
		*SurfaceKindSummary,
		*RuntimeModeSummary,
		*GeneratorSummary
	);

	if (LaunchExecutionContextSurface.bHasExecutionTarget)
	{
		Surface.RefreshLine = Surface.bWillRefreshLaunchRequestOnExecute
			? TEXT("Refresh posture: execute will rebuild the stored request from the current selector set.")
			: TEXT("Refresh posture: execute can use the current stored request without rebuilding it.");
	}
	else if (Surface.bHasLaunchConfig || Surface.bHasGeneratedModeSurface)
	{
		Surface.RefreshLine =
			TEXT("Refresh posture: no generated-mode execution target is currently staged.");
	}
	else
	{
		Surface.RefreshLine =
			TEXT("Refresh posture: selector application must stage a generated-mode target first.");
	}

	if (Surface.bHasLaunchConfig)
	{
		Surface.StatusLine = Surface.bWillRefreshLaunchRequestOnExecute
			? TEXT("Generated-mode selector application is complete; execute will refresh the stored request from the current selector set.")
			: TEXT("Generated-mode selector application is complete for the active generated-mode surface.");
	}
	else if (Surface.bHasGeneratedModeSurface && Surface.bHasSelectionState && !Surface.bSelectionStateMatchesSurface)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector application is cached against a different surface than the active generated-mode deck.");
	}
	else if (Surface.bHasGeneratedModeSurface && Surface.RequiredSelectorCount > 0 && Surface.MissingSelectorCount == 0)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector application has full selector coverage, but launch execution is not yet staged.");
	}
	else if (Surface.bHasGeneratedModeSurface && Surface.RequiredSelectorCount > 0 && Surface.SelectedSelectorCount > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector application is in progress; %d selector%s still need selection."),
			Surface.MissingSelectorCount,
			Surface.MissingSelectorCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (Surface.bHasGeneratedModeSurface)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector application has not started for the active generated-mode surface.");
	}
	else if (Surface.bHasSelectionState)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector application is cached, but no active generated-mode surface is currently staged.");
	}
	else
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector application is not currently cached.");
	}

	Surface.DetailLine = FString::Printf(
		TEXT("Surface: %s (%s) | Runtime: %s | Generator: %s | Launch posture: %s"),
		*SurfaceLabelSummary,
		*SurfaceIdSummary,
		*RuntimeModeSummary,
		*GeneratorSummary,
		LaunchExecutionContextSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *LaunchExecutionContextSurface.StatusLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorRosterSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorRosterSurface(
	const FHyperTwistTrainingDeck& ActiveDeck,
	const FHyperTwistTrainingImportedRuntimeSelectionState& ImportedRuntimeSelectionState,
	const FHyperTwistTrainingCoachGeneratedModeSelectorApplicationContextSurface&
		SelectorApplicationContextSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorRosterSurface Surface;
	Surface.Headline = TEXT("Generated Mode Selector Roster");
	Surface.CoverageLine = SelectorApplicationContextSurface.CoverageLine;

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
	{
		if (!Selector.IsStructurallyValid())
		{
			continue;
		}

		FHyperTwistTrainingCoachGeneratedModeSelectorRosterEntrySurface Entry;
		Entry.SelectorId = Selector.SelectorId;
		Entry.Label = Selector.Label;
		Entry.BindingLabel = Selector.SelectorBinding;

		const FHyperTwistTrainingImportedRuntimeSelectorChoice* MatchingChoice =
			ImportedRuntimeSelectionState.SelectorChoices.FindByPredicate(
				[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
				{
					return Candidate.SelectorId == Selector.SelectorId && Candidate.IsStructurallyValid();
				}
			);
		Entry.bHasSelection = MatchingChoice != nullptr;
		Entry.bIsResolved = MatchingChoice != nullptr;
		if (MatchingChoice != nullptr)
		{
			Entry.SelectedValue = MatchingChoice->SelectedValue;
			Entry.SelectedDisplayValue = MatchingChoice->DisplayValue.IsEmpty()
				? MatchingChoice->SelectedValue
				: MatchingChoice->DisplayValue;
		}

		for (const FHyperTwistTrainingImportedRuntimeSelectorOption& Option : Selector.Options)
		{
			if (Option.IsStructurallyValid())
			{
				++Entry.AvailableOptionCount;
			}
		}
		Entry.bHasAvailableOptions = Entry.AvailableOptionCount > 0;
		Entry.SelectionLine = Entry.bHasSelection
			? FString::Printf(
				TEXT("Selection: %s"),
				Entry.SelectedDisplayValue.IsEmpty() ? TEXT("n/a") : *Entry.SelectedDisplayValue
			)
			: TEXT("Selection: unresolved");
		Entry.OptionAvailabilityLine = Entry.bHasAvailableOptions
			? FString::Printf(
				TEXT("Options: %d available"),
				Entry.AvailableOptionCount
			)
			: TEXT("Options: no imported options");

		Surface.SelectorEntries.Add(MoveTemp(Entry));
	}

	Surface.TotalSelectorCount = Surface.SelectorEntries.Num();
	for (const FHyperTwistTrainingCoachGeneratedModeSelectorRosterEntrySurface& Entry :
		Surface.SelectorEntries)
	{
		if (Entry.bIsResolved)
		{
			++Surface.ResolvedSelectorCount;
		}
		if (!Entry.bIsResolved && Entry.bHasAvailableOptions)
		{
			++Surface.UnresolvedWithAvailableOptionsCount;
		}
	}
	Surface.UnresolvedSelectorCount = Surface.TotalSelectorCount - Surface.ResolvedSelectorCount;
	Surface.bHasSelectorRoster = Surface.TotalSelectorCount > 0;
	Surface.bHasUnresolvedSelectors = Surface.UnresolvedSelectorCount > 0;
	Surface.bHasResolvableUnresolvedSelectors = Surface.UnresolvedWithAvailableOptionsCount > 0;
	Surface.bAllUnresolvedSelectorsHaveOptions = Surface.UnresolvedSelectorCount > 0
		&& Surface.UnresolvedSelectorCount == Surface.UnresolvedWithAvailableOptionsCount;

	TArray<FString> UnresolvedLabels;
	for (const FHyperTwistTrainingCoachGeneratedModeSelectorRosterEntrySurface& Entry :
		Surface.SelectorEntries)
	{
		if (!Entry.bIsResolved)
		{
			UnresolvedLabels.Add(Entry.Label.IsEmpty() ? Entry.SelectorId : Entry.Label);
		}
	}

	if (Surface.bHasSelectorRoster && Surface.UnresolvedSelectorCount == 0)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector roster is fully resolved for the active generated-mode surface.");
	}
	else if (Surface.bHasSelectorRoster)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector roster has %d unresolved selector%s; %d still expose imported options."),
			Surface.UnresolvedSelectorCount,
			Surface.UnresolvedSelectorCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnresolvedWithAvailableOptionsCount
		);
	}
	else if (bHasGeneratedModeSurface)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector roster is empty for the active generated-mode surface.");
	}
	else if (SelectorApplicationContextSurface.bHasSelectionState)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector roster is not active, but cached selector choices remain.");
	}
	else
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector roster is not currently available.");
	}

	if (UnresolvedLabels.Num() == 0)
	{
		Surface.UnresolvedSelectorsLine = TEXT("Unresolved: none");
	}
	else
	{
		const int32 PreviewCount = FMath::Min(UnresolvedLabels.Num(), 3);
		TArray<FString> PreviewLabels;
		PreviewLabels.Append(UnresolvedLabels.GetData(), PreviewCount);
		Surface.UnresolvedSelectorsLine = FString::Printf(
			TEXT("Unresolved: %s%s"),
			*FString::Join(PreviewLabels, TEXT(", ")),
			UnresolvedLabels.Num() > PreviewCount
				? *FString::Printf(TEXT(" (+%d more)"), UnresolvedLabels.Num() - PreviewCount)
				: TEXT("")
		);
	}

	Surface.DetailLine = FString::Printf(
		TEXT("Selector application: %s | Identity: %s | Refresh: %s"),
		SelectorApplicationContextSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *SelectorApplicationContextSurface.StatusLine,
		SelectorApplicationContextSurface.IdentityLine.IsEmpty()
			? TEXT("n/a")
			: *SelectorApplicationContextSurface.IdentityLine,
		SelectorApplicationContextSurface.RefreshLine.IsEmpty()
			? TEXT("n/a")
			: *SelectorApplicationContextSurface.RefreshLine
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionMenuSurface(
	const FHyperTwistTrainingDeck& ActiveDeck,
	const FHyperTwistTrainingImportedRuntimeSelectionState& ImportedRuntimeSelectionState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorRosterSurface& SelectorRosterSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.Headline = TEXT("Generated Mode Selector Options");

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option detail requires a selector id from the active selector roster.");
		Surface.SelectionLine = TEXT("Selection: n/a");
		Surface.AvailabilityLine = TEXT("Options: n/a");
		Surface.DetailLine = SelectorRosterSurface.StatusLine.IsEmpty()
			? TEXT("Roster: n/a")
			: FString::Printf(TEXT("Roster: %s"), *SelectorRosterSurface.StatusLine);
		return Surface;
	}

	const FHyperTwistTrainingCoachGeneratedModeSelectorRosterEntrySurface* MatchingRosterEntry =
		SelectorRosterSurface.SelectorEntries.FindByPredicate(
			[&SelectorId](const FHyperTwistTrainingCoachGeneratedModeSelectorRosterEntrySurface& Entry)
			{
				return Entry.SelectorId == SelectorId;
			}
		);
	const FHyperTwistTrainingImportedRuntimeSelectorChoice* MatchingChoice =
		ImportedRuntimeSelectionState.SelectorChoices.FindByPredicate(
			[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
			{
				return Candidate.SelectorId == SelectorId && Candidate.IsStructurallyValid();
			}
		);
	const FHyperTwistTrainingImportedRuntimeSelector* MatchingSelector =
		RuntimeSurface.Selectors.FindByPredicate(
			[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelector& Candidate)
			{
				return Candidate.SelectorId == SelectorId && Candidate.IsStructurallyValid();
			}
		);

	Surface.bHasSelection = MatchingChoice != nullptr;
	if (MatchingChoice != nullptr)
	{
		Surface.SelectedValue = MatchingChoice->SelectedValue;
		Surface.SelectedDisplayValue = MatchingChoice->DisplayValue.IsEmpty()
			? MatchingChoice->SelectedValue
			: MatchingChoice->DisplayValue;
	}
	else if (MatchingRosterEntry != nullptr && MatchingRosterEntry->bHasSelection)
	{
		Surface.bHasSelection = true;
		Surface.SelectedValue = MatchingRosterEntry->SelectedValue;
		Surface.SelectedDisplayValue = MatchingRosterEntry->SelectedDisplayValue;
	}

	if (MatchingSelector != nullptr)
	{
		Surface.bHasSelector = true;
		Surface.SelectorId = MatchingSelector->SelectorId;
		Surface.SelectorLabel = MatchingSelector->Label;
		Surface.BindingLabel = MatchingSelector->SelectorBinding;
		Surface.Headline = MatchingSelector->Label.IsEmpty()
			? FString::Printf(TEXT("Generated Mode Selector Options: %s"), *MatchingSelector->SelectorId)
			: FString::Printf(TEXT("Generated Mode Selector Options: %s"), *MatchingSelector->Label);

		for (const FHyperTwistTrainingImportedRuntimeSelectorOption& Option : MatchingSelector->Options)
		{
			if (!Option.IsStructurallyValid())
			{
				continue;
			}

			FHyperTwistTrainingCoachGeneratedModeSelectorOptionEntrySurface Entry;
			Entry.OptionId = Option.OptionId;
			Entry.Label = Option.Label;
			Entry.OptionValue = Option.OptionValue;
			Entry.DetailLine = Entry.OptionValue.IsEmpty() || Entry.OptionValue == Entry.OptionId
				? FString::Printf(TEXT("Option id: %s"), *Entry.OptionId)
				: FString::Printf(
					TEXT("Option id: %s | Value: %s"),
					*Entry.OptionId,
					*Entry.OptionValue
				);
			Entry.bMatchesCurrentSelection = Surface.bHasSelection
				&& (Surface.SelectedValue == Option.OptionId || Surface.SelectedValue == Option.OptionValue);
			if (Entry.bMatchesCurrentSelection && !Surface.bSelectionMatchesAvailableOption)
			{
				Surface.bSelectionMatchesAvailableOption = true;
				Surface.MatchedOptionId = Entry.OptionId;
				Surface.MatchedOptionLabel = Entry.Label;
				Surface.MatchedOptionValue = Entry.OptionValue;
			}

			Surface.OptionEntries.Add(MoveTemp(Entry));
		}
	}

	Surface.AvailableOptionCount = Surface.OptionEntries.Num();
	Surface.bHasOptions = Surface.AvailableOptionCount > 0;
	Surface.bHasUnresolvedSelectionDetail =
		Surface.bHasSelection && !Surface.bSelectionMatchesAvailableOption;

	if (Surface.bHasSelection)
	{
		const FString SelectionSummary = Surface.SelectedDisplayValue.IsEmpty()
			? Surface.SelectedValue
			: Surface.SelectedDisplayValue;
		Surface.SelectionLine = Surface.bSelectionMatchesAvailableOption
			? FString::Printf(
				TEXT("Selection: %s [%s]"),
				SelectionSummary.IsEmpty() ? TEXT("n/a") : *SelectionSummary,
				Surface.MatchedOptionId.IsEmpty() ? TEXT("n/a") : *Surface.MatchedOptionId
			)
			: FString::Printf(
				TEXT("Selection: %s (cached)"),
				SelectionSummary.IsEmpty() ? TEXT("n/a") : *SelectionSummary
			);
	}
	else if (Surface.bHasSelector)
	{
		Surface.SelectionLine = TEXT("Selection: unresolved");
	}
	else
	{
		Surface.SelectionLine = TEXT("Selection: n/a");
	}

	if (Surface.bHasUnresolvedSelectionDetail)
	{
		const FString SelectionDisplaySummary = Surface.SelectedDisplayValue.IsEmpty()
			? Surface.SelectedValue
			: Surface.SelectedDisplayValue;
		Surface.UnresolvedSelectionLine =
			Surface.SelectedDisplayValue.IsEmpty() || Surface.SelectedDisplayValue == Surface.SelectedValue
			? FString::Printf(
				TEXT("Cached selection '%s' is not present in the imported options."),
				SelectionDisplaySummary.IsEmpty() ? TEXT("n/a") : *SelectionDisplaySummary
			)
			: FString::Printf(
				TEXT("Cached selection '%s' stored as '%s' is not present in the imported options."),
				SelectionDisplaySummary.IsEmpty() ? TEXT("n/a") : *SelectionDisplaySummary,
				Surface.SelectedValue.IsEmpty() ? TEXT("n/a") : *Surface.SelectedValue
			);
	}

	if (Surface.bHasOptions)
	{
		Surface.AvailabilityLine = FString::Printf(
			TEXT("Options: %d imported"),
			Surface.AvailableOptionCount
		);
	}
	else if (Surface.bHasSelector)
	{
		Surface.AvailabilityLine = TEXT("Options: no imported options");
	}
	else if (bHasGeneratedModeSurface)
	{
		Surface.AvailabilityLine = TEXT("Options: selector not found in active generated-mode surface");
	}
	else
	{
		Surface.AvailabilityLine = TEXT("Options: n/a");
	}

	if (Surface.bHasSelector && Surface.bHasOptions && Surface.bSelectionMatchesAvailableOption)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option detail exposes %d imported option%s and the cached selection resolves cleanly."),
			Surface.AvailableOptionCount,
			Surface.AvailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (Surface.bHasSelector && Surface.bHasOptions && Surface.bHasSelection)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option detail exposes %d imported option%s, but the cached selection no longer matches an imported option."),
			Surface.AvailableOptionCount,
			Surface.AvailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (Surface.bHasSelector && Surface.bHasOptions)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option detail exposes %d imported option%s and the selector is currently unresolved."),
			Surface.AvailableOptionCount,
			Surface.AvailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (Surface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option detail is active, but this selector does not expose imported options.");
	}
	else if (bHasGeneratedModeSurface)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option detail could not find the requested selector in the active generated-mode surface.");
	}
	else if (SelectorRosterSurface.bHasSelectorRoster || ImportedRuntimeSelectionState.IsStructurallyValid())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option detail is not active, but cached selector state remains.");
	}
	else
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option detail is not currently available.");
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Roster: %s | Selector: %s | Binding: %s"),
		SelectorRosterSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *SelectorRosterSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionActionabilitySurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionActionabilitySurface(
	const FHyperTwistTrainingDeck& ActiveDeck,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionActionabilitySurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Coverage");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(TEXT("Generated Mode Selector Option Coverage: %s"), *SelectorId)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Coverage: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option coverage requires a selector id from the active selector roster.");
		Surface.CoverageLine = TEXT("Case coverage: n/a");
		Surface.SelectionCoverageLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Option detail: n/a")
			: FString::Printf(TEXT("Option detail: %s"), *OptionMenuSurface.StatusLine);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionEntrySurface& OptionEntry :
		OptionMenuSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionActionabilityEntrySurface Entry;
		Entry.OptionId = OptionEntry.OptionId;
		Entry.Label = OptionEntry.Label;
		Entry.OptionValue = OptionEntry.OptionValue;
		Entry.bMatchesCurrentSelection = OptionEntry.bMatchesCurrentSelection;

		FHyperTwistTrainingCase MatchingCase;
		Entry.bHasCoveredCase = UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
			ActiveDeck,
			SelectorId,
			OptionEntry.OptionId,
			MatchingCase
		);
		if (Entry.bHasCoveredCase)
		{
			Entry.MatchedCaseId = MatchingCase.CaseId;
			Entry.MatchedCaseLabel = MatchingCase.PromptLabel.IsEmpty()
				? MatchingCase.CaseId
				: MatchingCase.PromptLabel;
			Entry.ActionabilityLine = Entry.MatchedCaseLabel.IsEmpty()
				? TEXT("Case coverage: owned case available")
				: FString::Printf(TEXT("Case coverage: %s"), *Entry.MatchedCaseLabel);
			++Surface.CoveredOptionCount;
		}
		else
		{
			Entry.ActionabilityLine = TEXT("Case coverage: selection-only choice");
			++Surface.SelectionOnlyOptionCount;
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasCaseCoverage = Entry.bHasCoveredCase;
			Surface.bCurrentSelectionIsSelectionOnly = !Entry.bHasCoveredCase;
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasCaseCoverage = Surface.CoveredOptionCount > 0;
	Surface.CoverageLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Case coverage: %d covered | %d selection-only"),
			Surface.CoveredOptionCount,
			Surface.SelectionOnlyOptionCount
		)
		: TEXT("Case coverage: no imported options");

	if (OptionMenuSurface.bSelectionMatchesAvailableOption && Surface.bCurrentSelectionHasCaseCoverage)
	{
		Surface.SelectionCoverageLine = FString::Printf(
			TEXT("Current selection maps to owned case: %s"),
			OptionMenuSurface.MatchedOptionLabel.IsEmpty()
				? (OptionMenuSurface.MatchedOptionId.IsEmpty()
					? TEXT("n/a")
					: *OptionMenuSurface.MatchedOptionId)
				: *OptionMenuSurface.MatchedOptionLabel
		);
	}
	else if (OptionMenuSurface.bSelectionMatchesAvailableOption && Surface.bCurrentSelectionIsSelectionOnly)
	{
		Surface.SelectionCoverageLine =
			TEXT("Current selection remains available, but it is currently selection-only.");
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.SelectionCoverageLine = OptionMenuSurface.UnresolvedSelectionLine.IsEmpty()
			? TEXT("Current selection does not currently map to an imported option.")
			: OptionMenuSurface.UnresolvedSelectionLine;
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.SelectionCoverageLine = TEXT("Current selection has no additional case-coverage detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.SelectionCoverageLine = TEXT("Current selection: unresolved");
	}
	else
	{
		Surface.SelectionCoverageLine = TEXT("Current selection: n/a");
	}

	if (OptionMenuSurface.bHasSelector && Surface.CoveredOptionCount > 0
		&& Surface.SelectionOnlyOptionCount == 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option coverage exposes %d covered option%s and no selection-only choices."),
			Surface.CoveredOptionCount,
			Surface.CoveredOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && Surface.CoveredOptionCount > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option coverage exposes %d covered option%s and %d selection-only choice%s."),
			Surface.CoveredOptionCount,
			Surface.CoveredOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.SelectionOnlyOptionCount,
			Surface.SelectionOnlyOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && OptionMenuSurface.bHasOptions)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option coverage is active, but none of the imported options currently map to owned cases.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option coverage is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option coverage is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Option detail: %s | Selector: %s | Binding: %s"),
		OptionMenuSurface.StatusLine.IsEmpty() ? TEXT("n/a") : *OptionMenuSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionDispatchSurface(
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionActionabilitySurface&
		OptionActionabilitySurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Dispatch");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(TEXT("Generated Mode Selector Option Dispatch: %s"), *SelectorId)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Dispatch: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option dispatch requires a selector id from the active selector roster.");
		Surface.DispatchSummaryLine = TEXT("Dispatch: n/a");
		Surface.CurrentSelectionDispatchLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionActionabilitySurface.StatusLine.IsEmpty()
			? TEXT("Coverage: n/a")
			: FString::Printf(TEXT("Coverage: %s"), *OptionActionabilitySurface.StatusLine);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionEntrySurface& OptionEntry :
		OptionMenuSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchEntrySurface Entry;
		Entry.OptionId = OptionEntry.OptionId;
		Entry.Label = OptionEntry.Label;
		Entry.OptionValue = OptionEntry.OptionValue;
		Entry.bMatchesCurrentSelection = OptionEntry.bMatchesCurrentSelection;
		Entry.GeneratedChoiceSelectedValue = OptionEntry.OptionValue.IsEmpty()
			? OptionEntry.OptionId
			: OptionEntry.OptionValue;
		Entry.GeneratedChoiceDisplayValue = OptionEntry.Label.IsEmpty()
			? Entry.GeneratedChoiceSelectedValue
			: OptionEntry.Label;

		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionActionabilityEntrySurface*
			MatchingActionabilityEntry =
				OptionActionabilitySurface.OptionEntries.FindByPredicate(
					[&OptionEntry](
						const FHyperTwistTrainingCoachGeneratedModeSelectorOptionActionabilityEntrySurface&
							Candidate
					)
					{
						return Candidate.OptionId == OptionEntry.OptionId;
					}
				);
		const bool bHasCoveredCase =
			MatchingActionabilityEntry != nullptr && MatchingActionabilityEntry->bHasCoveredCase;

		if (bHasCoveredCase)
		{
			Entry.DispatchKind =
				EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::DirectCaseLaunch;
			Entry.DirectLaunchOptionId = OptionEntry.OptionId;
			Entry.DispatchLine = TEXT("Dispatch: launch direct owned case");
			Entry.DetailLine = MatchingActionabilityEntry->MatchedCaseLabel.IsEmpty()
				? TEXT("Launch path: ApplyActiveImportedRuntimeSelectorOption")
				: FString::Printf(
					TEXT("Launch path: ApplyActiveImportedRuntimeSelectorOption | Case: %s"),
					*MatchingActionabilityEntry->MatchedCaseLabel
				);
			Entry.bCanDispatch = true;
			++Surface.DirectLaunchOptionCount;
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Entry.DispatchKind =
				EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::ApplyGeneratedChoice;
			Entry.DispatchLine = TEXT("Dispatch: apply generated-mode selector choice");
			Entry.DetailLine = FString::Printf(
				TEXT("Choice path: ApplyActiveImportedGeneratedModeSelectorChoice | Value: %s"),
				Entry.GeneratedChoiceSelectedValue.IsEmpty()
					? TEXT("n/a")
					: *Entry.GeneratedChoiceSelectedValue
			);
			Entry.bCanDispatch = !Entry.GeneratedChoiceSelectedValue.IsEmpty();
			++Surface.GeneratedChoiceOptionCount;
		}
		else
		{
			Entry.DispatchKind = EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::Unavailable;
			Entry.DispatchLine = TEXT("Dispatch: unavailable");
			Entry.DetailLine = TEXT("Option dispatch is unavailable because the selector is not active.");
			Entry.bCanDispatch = false;
			++Surface.UnavailableOptionCount;
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionDispatchesDirectLaunch =
				Entry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::DirectCaseLaunch;
			Surface.bCurrentSelectionDispatchesGeneratedChoice =
				Entry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::ApplyGeneratedChoice;
		}

		if (!Entry.bCanDispatch
			&& Entry.DispatchKind
				!= EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::Unavailable)
		{
			++Surface.UnavailableOptionCount;
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasDispatchOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectLaunchOptions = Surface.DirectLaunchOptionCount > 0;
	Surface.bHasGeneratedChoiceOptions = Surface.GeneratedChoiceOptionCount > 0;

	if (Surface.bHasDispatchOptions)
	{
		Surface.DispatchSummaryLine = FString::Printf(
			TEXT("Dispatch: %d direct-launch | %d generated-choice | %d unavailable"),
			Surface.DirectLaunchOptionCount,
			Surface.GeneratedChoiceOptionCount,
			Surface.UnavailableOptionCount
		);
	}
	else
	{
		Surface.DispatchSummaryLine = TEXT("Dispatch: no imported options");
	}

	if (Surface.bCurrentSelectionDispatchesDirectLaunch)
	{
		Surface.CurrentSelectionDispatchLine =
			TEXT("Current selection dispatches as direct owned-case launch.");
	}
	else if (Surface.bCurrentSelectionDispatchesGeneratedChoice)
	{
		Surface.CurrentSelectionDispatchLine =
			TEXT("Current selection dispatches as generated-mode selector choice apply.");
	}
	else if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
	{
		Surface.CurrentSelectionDispatchLine = OptionMenuSurface.UnresolvedSelectionLine.IsEmpty()
			? TEXT("Current selection does not currently map to an imported option.")
			: OptionMenuSurface.UnresolvedSelectionLine;
	}
	else if (OptionMenuSurface.bHasSelection)
	{
		Surface.CurrentSelectionDispatchLine =
			TEXT("Current selection has no additional dispatch detail.");
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.CurrentSelectionDispatchLine = TEXT("Current selection: unresolved");
	}
	else
	{
		Surface.CurrentSelectionDispatchLine = TEXT("Current selection: n/a");
	}

	if (OptionMenuSurface.bHasSelector && Surface.DirectLaunchOptionCount > 0
		&& Surface.GeneratedChoiceOptionCount == 0 && Surface.UnavailableOptionCount == 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option dispatch exposes %d direct-launch option%s and no fallback choice applies."),
			Surface.DirectLaunchOptionCount,
			Surface.DirectLaunchOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && Surface.GeneratedChoiceOptionCount > 0
		&& Surface.DirectLaunchOptionCount == 0 && Surface.UnavailableOptionCount == 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option dispatch exposes %d generated-choice option%s and no direct-launch cases."),
			Surface.GeneratedChoiceOptionCount,
			Surface.GeneratedChoiceOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector && Surface.bHasDispatchOptions)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option dispatch exposes %d direct-launch option%s, %d generated-choice option%s, and %d unavailable option%s."),
			Surface.DirectLaunchOptionCount,
			Surface.DirectLaunchOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedChoiceOptionCount,
			Surface.GeneratedChoiceOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option dispatch is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option dispatch is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Coverage: %s | Selector: %s | Binding: %s"),
		OptionActionabilitySurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionActionabilitySurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionExecutionImpactSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionExecutionImpactSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeLaunchExecutionContextSurface& LaunchExecutionContextSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchSurface& OptionDispatchSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionExecutionImpactSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Execution Impact");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Execution Impact: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Execution Impact: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option execution impact requires a selector id from the active selector roster.");
		Surface.ExecutionImpactSummaryLine = TEXT("Execution impact: n/a");
		Surface.CurrentSelectionExecutionImpactLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionDispatchSurface.StatusLine.IsEmpty()
			? TEXT("Dispatch: n/a")
			: FString::Printf(TEXT("Dispatch: %s"), *OptionDispatchSurface.StatusLine);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingImportedRuntimeSelector* MatchingSelector =
		RuntimeSurface.Selectors.FindByPredicate(
			[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelector& Candidate)
			{
				return Candidate.SelectorId == SelectorId && Candidate.IsStructurallyValid();
			}
		);
	const FString SelectorBinding = MatchingSelector != nullptr
		? MatchingSelector->SelectorBinding
		: OptionMenuSurface.BindingLabel;

	const auto DescribeSelector = [](
		const FHyperTwistTrainingImportedRuntimeSelector& Selector
	) -> FString
	{
		if (!Selector.Label.IsEmpty())
		{
			return Selector.Label;
		}
		if (!Selector.SelectorBinding.IsEmpty())
		{
			return Selector.SelectorBinding;
		}
		return Selector.SelectorId;
	};

	const auto BuildUnresolvedSelectorBlockedReason = [&DescribeSelector, &RuntimeSurface](
		const FHyperTwistTrainingImportedRuntimeSelectionState& SelectionState,
		int32& OutUnresolvedSelectorCount
	) -> FString
	{
		OutUnresolvedSelectorCount = 0;
		FString FirstUnresolvedSelectorLabel;

		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* MatchingChoice =
				SelectionState.SelectorChoices.FindByPredicate(
					[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == Selector.SelectorId
							&& Candidate.IsStructurallyValid();
					}
				);
			if (MatchingChoice != nullptr)
			{
				continue;
			}

			++OutUnresolvedSelectorCount;
			if (FirstUnresolvedSelectorLabel.IsEmpty())
			{
				FirstUnresolvedSelectorLabel = DescribeSelector(Selector);
			}
		}

		return OutUnresolvedSelectorCount > 0
			? FString::Printf(
				TEXT("Generated-mode execution is blocked because selector %s is unresolved."),
				FirstUnresolvedSelectorLabel.IsEmpty() ? TEXT("n/a") : *FirstUnresolvedSelectorLabel
			)
			: FString();
	};

	const auto DoSelectorChoiceSetsMatch = [&RuntimeSurface](
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& LeftChoices,
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& RightChoices
	) -> bool
	{
		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* LeftChoice =
				LeftChoices.FindByPredicate(
					[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == Selector.SelectorId
							&& Candidate.IsStructurallyValid();
					}
				);
			const FHyperTwistTrainingImportedRuntimeSelectorChoice* RightChoice =
				RightChoices.FindByPredicate(
					[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == Selector.SelectorId
							&& Candidate.IsStructurallyValid();
					}
				);
			if (LeftChoice == nullptr || RightChoice == nullptr)
			{
				return false;
			}
			if (LeftChoice->SelectedValue != RightChoice->SelectedValue)
			{
				return false;
			}
		}

		return true;
	};

	const auto DoesLaunchRequestMatchLaunchConfig = [&DoSelectorChoiceSetsMatch](
		const FHyperTwistTrainingImportedGeneratedModeLaunchRequest& LaunchRequest,
		const FHyperTwistTrainingImportedGeneratedModeLaunchConfig& ExpectedLaunchConfig
	) -> bool
	{
		return LaunchRequest.IsStructurallyValid()
			&& LaunchRequest.LaunchConfig.DeckId == ExpectedLaunchConfig.DeckId
			&& LaunchRequest.LaunchConfig.SurfaceId == ExpectedLaunchConfig.SurfaceId
			&& LaunchRequest.LaunchConfig.RuntimeModeId.Equals(
				ExpectedLaunchConfig.RuntimeModeId,
				ESearchCase::IgnoreCase
			)
			&& DoSelectorChoiceSetsMatch(
				LaunchRequest.LaunchConfig.SelectorChoices,
				ExpectedLaunchConfig.SelectorChoices
			);
	};

	const auto DescribeUnchangedExecutionImpact = [&LaunchExecutionContextSurface]() -> FString
	{
		if (LaunchExecutionContextSurface.bHasExecutionTarget
			&& LaunchExecutionContextSurface.bCanExecute)
		{
			return LaunchExecutionContextSurface.bWillRefreshLaunchRequestOnExecute
				? TEXT("Execution impact: execute posture is unchanged and still refreshes the stored request.")
				: TEXT("Execution impact: execute posture is unchanged and still uses the stored request.");
		}
		if (LaunchExecutionContextSurface.bHasExecutionTarget)
		{
			return TEXT("Execution impact: execute posture is unchanged and remains blocked.");
		}
		if (LaunchExecutionContextSurface.bHasLatestLaunchRequest)
		{
			return TEXT("Execution impact: execute posture is unchanged and no execution target is currently staged.");
		}
		return TEXT("Execution impact: execute posture is unchanged and no stored request or execution target is currently staged.");
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option execution impact is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.ExecutionImpactSummaryLine = TEXT("Execution impact: n/a");
		Surface.CurrentSelectionExecutionImpactLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active generated-mode execute context is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Dispatch: %s | Execute: %s"),
			OptionDispatchSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionDispatchSurface.StatusLine,
			LaunchExecutionContextSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *LaunchExecutionContextSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchEntrySurface& DispatchEntry :
		OptionDispatchSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionExecutionImpactEntrySurface Entry;
		Entry.OptionId = DispatchEntry.OptionId;
		Entry.Label = DispatchEntry.Label;
		Entry.OptionValue = DispatchEntry.OptionValue;
		Entry.bMatchesCurrentSelection = DispatchEntry.bMatchesCurrentSelection;

		if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::DirectCaseLaunch
			&& DispatchEntry.bCanDispatch)
		{
			Entry.ExecutionImpactKind =
				EHyperTwistTrainingCoachGeneratedModeOptionExecutionImpactKind::ImmediateOwnedCaseStart;
			Entry.ImpactLine = TEXT("Execution impact: starts a direct owned case immediately.");
			Entry.DetailLine = DispatchEntry.DetailLine.IsEmpty()
				? TEXT("Direct option launch bypasses generated-mode execute for this interaction.")
				: DispatchEntry.DetailLine;
			Entry.bStartsOwnedCaseImmediately = true;
			Entry.bCanApplyImpact = true;
			++Surface.ImmediateOwnedCaseStartOptionCount;
		}
		else if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::ApplyGeneratedChoice
			&& DispatchEntry.bCanDispatch && MatchingSelector != nullptr)
		{
			FHyperTwistTrainingImportedRuntimeSelectionState HypotheticalSelectionState =
				RunState.ImportedRuntimeSelectionState;
			if (!HypotheticalSelectionState.IsStructurallyValid())
			{
				HypotheticalSelectionState.SurfaceId = RuntimeSurface.SurfaceId;
				HypotheticalSelectionState.SurfaceKind = RuntimeSurface.SurfaceKind;
			}

			const FString SelectedValue = DispatchEntry.GeneratedChoiceSelectedValue.IsEmpty()
				? (DispatchEntry.OptionValue.IsEmpty()
					? DispatchEntry.OptionId
					: DispatchEntry.OptionValue)
				: DispatchEntry.GeneratedChoiceSelectedValue;
			const FString DisplayValue = DispatchEntry.GeneratedChoiceDisplayValue.IsEmpty()
				? (DispatchEntry.Label.IsEmpty() ? SelectedValue : DispatchEntry.Label)
				: DispatchEntry.GeneratedChoiceDisplayValue;

			FHyperTwistTrainingImportedRuntimeSelectorChoice* ExistingChoice =
				HypotheticalSelectionState.SelectorChoices.FindByPredicate(
					[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == SelectorId;
					}
				);
			if (ExistingChoice != nullptr)
			{
				ExistingChoice->SelectorBinding = SelectorBinding;
				ExistingChoice->SelectedValue = SelectedValue;
				ExistingChoice->DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
			}
			else
			{
				FHyperTwistTrainingImportedRuntimeSelectorChoice Choice;
				Choice.SelectorId = SelectorId;
				Choice.SelectorBinding = SelectorBinding;
				Choice.SelectedValue = SelectedValue;
				Choice.DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
				HypotheticalSelectionState.SelectorChoices.Add(MoveTemp(Choice));
			}

			int32 UnresolvedSelectorCount = 0;
			Entry.BlockedReasonLine = BuildUnresolvedSelectorBlockedReason(
				HypotheticalSelectionState,
				UnresolvedSelectorCount
			);

			if (!Entry.BlockedReasonLine.IsEmpty())
			{
				Entry.ExecutionImpactKind =
					EHyperTwistTrainingCoachGeneratedModeOptionExecutionImpactKind::ExecuteBlocked;
				Entry.ImpactLine =
					TEXT("Execution impact: applies the selector choice, but execute remains blocked.");
				Entry.DetailLine = FString::Printf(
					TEXT("Choice apply: %s | %d selector%s still need resolution before generated-mode execute."),
					DispatchEntry.DetailLine.IsEmpty() ? TEXT("n/a") : *DispatchEntry.DetailLine,
					UnresolvedSelectorCount,
					UnresolvedSelectorCount == 1 ? TEXT("") : TEXT("s")
				);
				Entry.bLeavesExecuteBlocked = true;
				Entry.bCanApplyImpact = true;
				++Surface.BlockedExecuteOptionCount;
			}
			else
			{
				FHyperTwistTrainingImportedGeneratedModeLaunchConfig HypotheticalLaunchConfig;
				if (!UHyperTwistTrainingCatalogLibrary::TryBuildImportedGeneratedModeLaunchConfig(
						RunState.ActiveDeck,
						HypotheticalSelectionState,
						RunState.Session,
						HypotheticalLaunchConfig))
				{
					Entry.ExecutionImpactKind =
						EHyperTwistTrainingCoachGeneratedModeOptionExecutionImpactKind::ExecuteBlocked;
					Entry.ImpactLine =
						TEXT("Execution impact: applies the selector choice, but execute remains blocked.");
					Entry.BlockedReasonLine =
						TEXT("Generated-mode execution could not derive a structurally valid launch request from the resulting selector state.");
					Entry.DetailLine = FString::Printf(
						TEXT("Choice apply: %s | The resulting selector state is not executable yet."),
						DispatchEntry.DetailLine.IsEmpty() ? TEXT("n/a") : *DispatchEntry.DetailLine
					);
					Entry.bLeavesExecuteBlocked = true;
					Entry.bCanApplyImpact = true;
					++Surface.BlockedExecuteOptionCount;
				}
				else
				{
					const bool bWouldUseStoredRequest = DoesLaunchRequestMatchLaunchConfig(
						RunState.ImportedGeneratedModeLaunchRequest,
						HypotheticalLaunchConfig
					);

					if (DispatchEntry.bMatchesCurrentSelection)
					{
						Entry.ExecutionImpactKind =
							EHyperTwistTrainingCoachGeneratedModeOptionExecutionImpactKind::ExecutePostureUnchanged;
						Entry.ImpactLine = DescribeUnchangedExecutionImpact();
						Entry.BlockedReasonLine = LaunchExecutionContextSurface.bHasBlockedExecution
							? LaunchExecutionContextSurface.BlockedReasonLine
							: FString();
						Entry.DetailLine = LaunchExecutionContextSurface.StatusLine.IsEmpty()
							? TEXT("Current generated-mode execute posture remains unchanged.")
							: FString::Printf(
								TEXT("Current generated-mode execute posture: %s"),
								*LaunchExecutionContextSurface.StatusLine
							);
						Entry.bLeavesExecutePostureUnchanged = true;
						Entry.bExecutesFromStoredRequest =
							LaunchExecutionContextSurface.bHasExecutionTarget
							&& LaunchExecutionContextSurface.bCanExecute
							&& !LaunchExecutionContextSurface.bWillRefreshLaunchRequestOnExecute;
						Entry.bRequiresLaunchRequestRefreshBeforeExecute =
							LaunchExecutionContextSurface.bWillRefreshLaunchRequestOnExecute;
						Entry.bLeavesExecuteBlocked =
							LaunchExecutionContextSurface.bHasExecutionTarget
							&& !LaunchExecutionContextSurface.bCanExecute;
						Entry.bCanApplyImpact = true;
						++Surface.UnchangedExecutePostureOptionCount;
					}
					else if (bWouldUseStoredRequest)
					{
						Entry.ExecutionImpactKind =
							EHyperTwistTrainingCoachGeneratedModeOptionExecutionImpactKind::ExecuteFromStoredRequest;
						Entry.ImpactLine = TEXT("Execution impact: generated-mode execute can use the stored request after this choice.");
						Entry.DetailLine = FString::Printf(
							TEXT("Choice apply: %s | The resulting selector state realigns with the current stored request."),
							DispatchEntry.DetailLine.IsEmpty() ? TEXT("n/a") : *DispatchEntry.DetailLine
						);
						Entry.bExecutesFromStoredRequest = true;
						Entry.bCanApplyImpact = true;
						++Surface.ExecuteFromStoredRequestOptionCount;
					}
					else
					{
						Entry.ExecutionImpactKind =
							EHyperTwistTrainingCoachGeneratedModeOptionExecutionImpactKind::LaunchRequestRefreshRequired;
						Entry.ImpactLine = TEXT("Execution impact: generated-mode execute will require launch-request refresh after this choice.");
						Entry.DetailLine = FString::Printf(
							TEXT("Choice apply: %s | The resulting selector state no longer matches the current stored request."),
							DispatchEntry.DetailLine.IsEmpty() ? TEXT("n/a") : *DispatchEntry.DetailLine
						);
						Entry.bRequiresLaunchRequestRefreshBeforeExecute = true;
						Entry.bCanApplyImpact = true;
						++Surface.RefreshRequiredOptionCount;
					}
				}
			}
		}
		else
		{
			Entry.ExecutionImpactKind =
				EHyperTwistTrainingCoachGeneratedModeOptionExecutionImpactKind::Unavailable;
			Entry.ImpactLine = TEXT("Execution impact: unavailable.");
			Entry.DetailLine = TEXT("Execution-impact preview is unavailable because this selector option cannot dispatch from the active generated-mode surface.");
			Entry.bCanApplyImpact = false;
			++Surface.UnavailableOptionCount;
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionStartsOwnedCaseImmediately = Entry.bStartsOwnedCaseImmediately;
			Surface.bCurrentSelectionLeavesExecutePostureUnchanged =
				Entry.bLeavesExecutePostureUnchanged;
			Surface.bCurrentSelectionRequiresLaunchRequestRefreshBeforeExecute =
				Entry.bRequiresLaunchRequestRefreshBeforeExecute;
			Surface.bCurrentSelectionLeavesExecuteBlocked = Entry.bLeavesExecuteBlocked;
			Surface.CurrentSelectionExecutionImpactLine = Entry.bLeavesExecuteBlocked
				&& !Entry.BlockedReasonLine.IsEmpty()
				? FString::Printf(TEXT("%s %s"), *Entry.ImpactLine, *Entry.BlockedReasonLine)
				: Entry.ImpactLine;
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasExecutionImpactOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasImmediateOwnedCaseStartOptions =
		Surface.ImmediateOwnedCaseStartOptionCount > 0;
	Surface.bHasStoredRequestExecutionOptions =
		Surface.ExecuteFromStoredRequestOptionCount > 0;
	Surface.bHasRefreshRequiredOptions = Surface.RefreshRequiredOptionCount > 0;
	Surface.bHasBlockedExecuteOptions = Surface.BlockedExecuteOptionCount > 0;

	Surface.ExecutionImpactSummaryLine = Surface.bHasExecutionImpactOptions
		? FString::Printf(
			TEXT("Execution impact: %d direct-start | %d stored-request | %d unchanged | %d refresh-required | %d blocked | %d unavailable"),
			Surface.ImmediateOwnedCaseStartOptionCount,
			Surface.ExecuteFromStoredRequestOptionCount,
			Surface.UnchangedExecutePostureOptionCount,
			Surface.RefreshRequiredOptionCount,
			Surface.BlockedExecuteOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Execution impact: no imported options");

	if (Surface.CurrentSelectionExecutionImpactLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionExecutionImpactLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionExecutionImpactLine =
				TEXT("Current selection has no additional execution-impact detail.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionExecutionImpactLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionExecutionImpactLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.bHasExecutionImpactOptions)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option execution impact exposes %d direct-start option%s, %d stored-request option%s, %d unchanged execute option%s, %d refresh-required option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.ImmediateOwnedCaseStartOptionCount,
			Surface.ImmediateOwnedCaseStartOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.ExecuteFromStoredRequestOptionCount,
			Surface.ExecuteFromStoredRequestOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnchangedExecutePostureOptionCount,
			Surface.UnchangedExecutePostureOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.RefreshRequiredOptionCount,
			Surface.RefreshRequiredOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedExecuteOptionCount,
			Surface.BlockedExecuteOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option execution impact is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option execution impact is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Dispatch: %s | Execute: %s | Selector: %s | Binding: %s"),
		OptionDispatchSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionDispatchSurface.StatusLine,
		LaunchExecutionContextSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *LaunchExecutionContextSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionRequestAlignmentSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchSurface& OptionDispatchSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionExecutionImpactSurface&
		OptionExecutionImpactSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Request Alignment");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Request Alignment: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Request Alignment: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option request alignment requires a selector id from the active selector roster.");
		Surface.RequestAlignmentSummaryLine = TEXT("Stored request alignment: n/a");
		Surface.UnresolvedPreviewSummaryLine = TEXT("Unresolved preview: n/a");
		Surface.CurrentSelectionPreviewLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionExecutionImpactSurface.StatusLine.IsEmpty()
			? TEXT("Execute impact: n/a")
			: FString::Printf(TEXT("Execute impact: %s"), *OptionExecutionImpactSurface.StatusLine);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingImportedRuntimeSelector* MatchingSelector =
		RuntimeSurface.Selectors.FindByPredicate(
			[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelector& Candidate)
			{
				return Candidate.SelectorId == SelectorId && Candidate.IsStructurallyValid();
			}
		);
	const FString SelectorBinding = MatchingSelector != nullptr
		? MatchingSelector->SelectorBinding
		: OptionMenuSurface.BindingLabel;

	const auto DescribeSelector = [](
		const FHyperTwistTrainingImportedRuntimeSelector& Selector
	) -> FString
	{
		if (!Selector.Label.IsEmpty())
		{
			return Selector.Label;
		}
		if (!Selector.SelectorBinding.IsEmpty())
		{
			return Selector.SelectorBinding;
		}
		return Selector.SelectorId;
	};

	const auto FormatExecutePreviewLine =
		[](const FHyperTwistTrainingCoachGeneratedModeSelectorOptionExecutionImpactEntrySurface* ImpactEntry)
		-> FString
	{
		if (ImpactEntry == nullptr)
		{
			return TEXT("Execute preview: unavailable.");
		}

		FString PreviewLine = ImpactEntry->ImpactLine.IsEmpty()
			? TEXT("Execute preview: unavailable.")
			: ImpactEntry->ImpactLine.Replace(
				TEXT("Execution impact:"),
				TEXT("Execute preview:"),
				ESearchCase::IgnoreCase
			);
		if (ImpactEntry->bLeavesExecuteBlocked && !ImpactEntry->BlockedReasonLine.IsEmpty())
		{
			PreviewLine += FString::Printf(TEXT(" %s"), *ImpactEntry->BlockedReasonLine);
		}
		return PreviewLine;
	};

	const auto FormatHypotheticalSelectorSummary = [&DescribeSelector, &RuntimeSurface](
		const FHyperTwistTrainingImportedRuntimeSelectionState& SelectionState
	) -> FString
	{
		TArray<FString> SelectorParts;
		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* MatchingChoice =
				SelectionState.SelectorChoices.FindByPredicate(
					[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == Selector.SelectorId
							&& Candidate.IsStructurallyValid();
					}
				);
			if (MatchingChoice == nullptr)
			{
				SelectorParts.Add(FString::Printf(
					TEXT("%s=unresolved"),
					*DescribeSelector(Selector)
				));
				continue;
			}

			const FString ValueSummary = MatchingChoice->DisplayValue.IsEmpty()
				? MatchingChoice->SelectedValue
				: MatchingChoice->DisplayValue;
			SelectorParts.Add(FString::Printf(
				TEXT("%s=%s"),
				*DescribeSelector(Selector),
				ValueSummary.IsEmpty() ? TEXT("n/a") : *ValueSummary
			));
		}

		return SelectorParts.Num() > 0
			? FString::Printf(
				TEXT("Hypothetical selectors: %s"),
				*FString::Join(SelectorParts, TEXT(" | "))
			)
			: TEXT("Hypothetical selectors: none");
	};

	const auto FormatUnresolvedSelectorPreview = [&DescribeSelector, &RuntimeSurface](
		const FHyperTwistTrainingImportedRuntimeSelectionState& SelectionState,
		int32& OutUnresolvedSelectorCount
	) -> FString
	{
		OutUnresolvedSelectorCount = 0;
		TArray<FString> UnresolvedLabels;

		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* MatchingChoice =
				SelectionState.SelectorChoices.FindByPredicate(
					[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == Selector.SelectorId
							&& Candidate.IsStructurallyValid();
					}
				);
			if (MatchingChoice != nullptr)
			{
				continue;
			}

			++OutUnresolvedSelectorCount;
			UnresolvedLabels.Add(DescribeSelector(Selector));
		}

		if (OutUnresolvedSelectorCount == 0)
		{
			return TEXT("Unresolved after choice: none");
		}

		const int32 PreviewCount = FMath::Min(3, UnresolvedLabels.Num());
		TArray<FString> PreviewLabels;
		PreviewLabels.Append(UnresolvedLabels.GetData(), PreviewCount);
		return FString::Printf(
			TEXT("Unresolved after choice: %s%s"),
			*FString::Join(PreviewLabels, TEXT(", ")),
			UnresolvedLabels.Num() > PreviewCount
				? *FString::Printf(TEXT(" (+%d more)"), UnresolvedLabels.Num() - PreviewCount)
				: TEXT("")
		);
	};

	const auto DoSelectorChoiceSetsMatch = [&RuntimeSurface](
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& LeftChoices,
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& RightChoices
	) -> bool
	{
		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* LeftChoice =
				LeftChoices.FindByPredicate(
					[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == Selector.SelectorId
							&& Candidate.IsStructurallyValid();
					}
				);
			const FHyperTwistTrainingImportedRuntimeSelectorChoice* RightChoice =
				RightChoices.FindByPredicate(
					[&Selector](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == Selector.SelectorId
							&& Candidate.IsStructurallyValid();
					}
				);
			if (LeftChoice == nullptr || RightChoice == nullptr)
			{
				return false;
			}
			if (LeftChoice->SelectedValue != RightChoice->SelectedValue)
			{
				return false;
			}
		}

		return true;
	};

	const auto DoesSelectionStateMatchStoredRequest =
		[&DoSelectorChoiceSetsMatch, &RunState, &RuntimeSurface](
			const FHyperTwistTrainingImportedRuntimeSelectionState& SelectionState
		) -> bool
	{
		const FHyperTwistTrainingImportedGeneratedModeLaunchRequest& LaunchRequest =
			RunState.ImportedGeneratedModeLaunchRequest;
		return LaunchRequest.IsStructurallyValid()
			&& LaunchRequest.LaunchConfig.DeckId == RunState.ActiveDeck.DeckId
			&& LaunchRequest.LaunchConfig.SurfaceId == RuntimeSurface.SurfaceId
			&& LaunchRequest.LaunchConfig.RuntimeModeId.Equals(
				RuntimeSurface.RuntimeModeId,
				ESearchCase::IgnoreCase
			)
			&& DoSelectorChoiceSetsMatch(
				LaunchRequest.LaunchConfig.SelectorChoices,
				SelectionState.SelectorChoices
			);
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option request alignment is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.RequestAlignmentSummaryLine = TEXT("Stored request alignment: n/a");
		Surface.UnresolvedPreviewSummaryLine = TEXT("Unresolved preview: n/a");
		Surface.CurrentSelectionPreviewLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active generated-mode request-alignment preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Dispatch: %s | Execute impact: %s"),
			OptionDispatchSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionDispatchSurface.StatusLine,
			OptionExecutionImpactSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionExecutionImpactSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchEntrySurface& DispatchEntry :
		OptionDispatchSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentEntrySurface Entry;
		Entry.OptionId = DispatchEntry.OptionId;
		Entry.Label = DispatchEntry.Label;
		Entry.OptionValue = DispatchEntry.OptionValue;
		Entry.bMatchesCurrentSelection = DispatchEntry.bMatchesCurrentSelection;

		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionExecutionImpactEntrySurface*
			MatchingImpactEntry =
				OptionExecutionImpactSurface.OptionEntries.FindByPredicate(
					[&DispatchEntry](
						const FHyperTwistTrainingCoachGeneratedModeSelectorOptionExecutionImpactEntrySurface&
							Candidate
					)
					{
						return Candidate.OptionId == DispatchEntry.OptionId;
					}
				);

		if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::DirectCaseLaunch
			&& DispatchEntry.bCanDispatch)
		{
			Entry.RequestAlignmentKind =
				EHyperTwistTrainingCoachGeneratedModeOptionRequestAlignmentKind::DirectOwnedCaseStart;
			Entry.HypotheticalSelectorSummaryLine =
				TEXT("Hypothetical selectors: direct owned-case launch bypasses generated-mode selector-choice apply.");
			Entry.StoredRequestAlignmentLine =
				TEXT("Stored request alignment: direct owned-case launch bypasses generated-mode request alignment.");
			Entry.UnresolvedSelectorsLine = TEXT("Unresolved after choice: n/a");
			Entry.ExecutePreviewLine = FormatExecutePreviewLine(MatchingImpactEntry);
			Entry.DetailLine = DispatchEntry.DetailLine.IsEmpty()
				? TEXT("Direct option launch bypasses generated-mode request-preview derivation.")
				: DispatchEntry.DetailLine;
			Entry.bStartsOwnedCaseImmediately = true;
			Entry.bCanPreview = true;
			++Surface.DirectOwnedCaseStartOptionCount;
		}
		else if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::ApplyGeneratedChoice
			&& DispatchEntry.bCanDispatch && MatchingSelector != nullptr)
		{
			FHyperTwistTrainingImportedRuntimeSelectionState HypotheticalSelectionState =
				RunState.ImportedRuntimeSelectionState;
			if (!HypotheticalSelectionState.IsStructurallyValid())
			{
				HypotheticalSelectionState.SurfaceId = RuntimeSurface.SurfaceId;
				HypotheticalSelectionState.SurfaceKind = RuntimeSurface.SurfaceKind;
			}

			const FString SelectedValue = DispatchEntry.GeneratedChoiceSelectedValue.IsEmpty()
				? (DispatchEntry.OptionValue.IsEmpty()
					? DispatchEntry.OptionId
					: DispatchEntry.OptionValue)
				: DispatchEntry.GeneratedChoiceSelectedValue;
			const FString DisplayValue = DispatchEntry.GeneratedChoiceDisplayValue.IsEmpty()
				? (DispatchEntry.Label.IsEmpty() ? SelectedValue : DispatchEntry.Label)
				: DispatchEntry.GeneratedChoiceDisplayValue;

			FHyperTwistTrainingImportedRuntimeSelectorChoice* ExistingChoice =
				HypotheticalSelectionState.SelectorChoices.FindByPredicate(
					[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == SelectorId;
					}
				);
			if (ExistingChoice != nullptr)
			{
				ExistingChoice->SelectorBinding = SelectorBinding;
				ExistingChoice->SelectedValue = SelectedValue;
				ExistingChoice->DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
			}
			else
			{
				FHyperTwistTrainingImportedRuntimeSelectorChoice Choice;
				Choice.SelectorId = SelectorId;
				Choice.SelectorBinding = SelectorBinding;
				Choice.SelectedValue = SelectedValue;
				Choice.DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
				HypotheticalSelectionState.SelectorChoices.Add(MoveTemp(Choice));
			}

			Entry.HypotheticalSelectorSummaryLine =
				FormatHypotheticalSelectorSummary(HypotheticalSelectionState);
			Entry.UnresolvedSelectorsLine = FormatUnresolvedSelectorPreview(
				HypotheticalSelectionState,
				Entry.UnresolvedSelectorCount
			);
			Entry.ExecutePreviewLine = FormatExecutePreviewLine(MatchingImpactEntry);

			if (Entry.UnresolvedSelectorCount > 0)
			{
				Entry.RequestAlignmentKind =
					EHyperTwistTrainingCoachGeneratedModeOptionRequestAlignmentKind::UnresolvedAfterChoice;
				Entry.StoredRequestAlignmentLine =
					TEXT("Stored request alignment: selector coverage remains incomplete after this choice.");
				Entry.bWouldLeaveSelectorsUnresolved = true;
				Entry.bCanPreview = true;
				++Surface.UnresolvedAfterChoiceOptionCount;
			}
			else if (DoesSelectionStateMatchStoredRequest(HypotheticalSelectionState))
			{
				Entry.RequestAlignmentKind =
					EHyperTwistTrainingCoachGeneratedModeOptionRequestAlignmentKind::StoredRequestAligned;
				Entry.StoredRequestAlignmentLine =
					TEXT("Stored request alignment: the hypothetical selector state matches the current stored request.");
				Entry.bWouldUseStoredRequestOnExecute = true;
				Entry.bCanPreview = true;
				++Surface.StoredRequestAlignedOptionCount;
			}
			else
			{
				Entry.RequestAlignmentKind =
					EHyperTwistTrainingCoachGeneratedModeOptionRequestAlignmentKind::LaunchRequestRefreshRequired;
				Entry.StoredRequestAlignmentLine =
					RunState.ImportedGeneratedModeLaunchRequest.IsStructurallyValid()
					? TEXT("Stored request alignment: the hypothetical selector state diverges from the current stored request.")
					: TEXT("Stored request alignment: no stored request is currently persisted for this selector state.");
				Entry.bWouldRequireLaunchRequestRefreshBeforeExecute = true;
				Entry.bCanPreview = true;
				++Surface.LaunchRequestRefreshRequiredOptionCount;
			}

			Entry.DetailLine = FString::Printf(
				TEXT("Dispatch: %s | Execute impact: %s"),
				DispatchEntry.DetailLine.IsEmpty() ? TEXT("n/a") : *DispatchEntry.DetailLine,
				MatchingImpactEntry == nullptr || MatchingImpactEntry->DetailLine.IsEmpty()
					? TEXT("n/a")
					: *MatchingImpactEntry->DetailLine
			);
		}
		else
		{
			Entry.RequestAlignmentKind =
				EHyperTwistTrainingCoachGeneratedModeOptionRequestAlignmentKind::Unavailable;
			Entry.HypotheticalSelectorSummaryLine = TEXT("Hypothetical selectors: unavailable");
			Entry.StoredRequestAlignmentLine = TEXT("Stored request alignment: unavailable");
			Entry.UnresolvedSelectorsLine = TEXT("Unresolved after choice: unavailable");
			Entry.ExecutePreviewLine = TEXT("Execute preview: unavailable.");
			Entry.DetailLine =
				TEXT("Request-alignment preview is unavailable because this selector option cannot dispatch from the active generated-mode surface.");
			Entry.bCanPreview = false;
			++Surface.UnavailableOptionCount;
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionWouldUseStoredRequestOnExecute =
				Entry.bWouldUseStoredRequestOnExecute;
			Surface.bCurrentSelectionWouldRequireLaunchRequestRefreshBeforeExecute =
				Entry.bWouldRequireLaunchRequestRefreshBeforeExecute;
			Surface.bCurrentSelectionWouldLeaveSelectorsUnresolved =
				Entry.bWouldLeaveSelectorsUnresolved;
			Surface.CurrentSelectionPreviewLine = Entry.bWouldLeaveSelectorsUnresolved
				? FString::Printf(
					TEXT("%s | %s | %s"),
					*Entry.HypotheticalSelectorSummaryLine,
					*Entry.StoredRequestAlignmentLine,
					*Entry.UnresolvedSelectorsLine
				)
				: FString::Printf(
					TEXT("%s | %s | %s"),
					*Entry.HypotheticalSelectorSummaryLine,
					*Entry.StoredRequestAlignmentLine,
					*Entry.ExecutePreviewLine
				);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasRequestAlignmentOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectOwnedCaseStartOptions = Surface.DirectOwnedCaseStartOptionCount > 0;
	Surface.bHasStoredRequestAlignedOptions = Surface.StoredRequestAlignedOptionCount > 0;
	Surface.bHasLaunchRequestRefreshRequiredOptions =
		Surface.LaunchRequestRefreshRequiredOptionCount > 0;
	Surface.bHasUnresolvedAfterChoiceOptions = Surface.UnresolvedAfterChoiceOptionCount > 0;

	Surface.RequestAlignmentSummaryLine = Surface.bHasRequestAlignmentOptions
		? FString::Printf(
			TEXT("Stored request alignment: %d aligned | %d refresh-required | %d unresolved | %d direct-launch | %d unavailable"),
			Surface.StoredRequestAlignedOptionCount,
			Surface.LaunchRequestRefreshRequiredOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount,
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Stored request alignment: no imported options");
	Surface.UnresolvedPreviewSummaryLine = Surface.UnresolvedAfterChoiceOptionCount > 0
		? FString::Printf(
			TEXT("Unresolved preview: %d option%s still leave at least one selector unresolved."),
			Surface.UnresolvedAfterChoiceOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount == 1 ? TEXT("") : TEXT("s")
		)
		: TEXT("Unresolved preview: every previewed option fully resolves selector coverage or bypasses generated-mode execute.");

	if (Surface.CurrentSelectionPreviewLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionPreviewLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionPreviewLine =
				TEXT("Current selection has no additional request-alignment preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionPreviewLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionPreviewLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.bHasRequestAlignmentOptions)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option request alignment exposes %d stored-request-aligned option%s, %d refresh-required option%s, %d unresolved option%s, %d direct-launch option%s, and %d unavailable option%s."),
			Surface.StoredRequestAlignedOptionCount,
			Surface.StoredRequestAlignedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.LaunchRequestRefreshRequiredOptionCount,
			Surface.LaunchRequestRefreshRequiredOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnresolvedAfterChoiceOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.DirectOwnedCaseStartOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option request alignment is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option request alignment is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Dispatch: %s | Execute impact: %s | Selector: %s | Binding: %s"),
		OptionDispatchSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionDispatchSurface.StatusLine,
		OptionExecutionImpactSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionExecutionImpactSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionStoredRequestDeltaSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionStoredRequestDeltaSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchSurface& OptionDispatchSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentSurface&
		OptionRequestAlignmentSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionStoredRequestDeltaSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Stored-Request Delta");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Stored-Request Delta: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Stored-Request Delta: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option stored-request delta requires a selector id from the active selector roster.");
		Surface.SelectorDiffSummaryLine = TEXT("Selector diff: n/a");
		Surface.CurrentToHypotheticalSummaryLine = TEXT("Current -> hypothetical: n/a");
		Surface.StoredRequestToHypotheticalSummaryLine = TEXT("Stored request -> hypothetical: n/a");
		Surface.CurrentToStoredRequestSummaryLine = TEXT("Current -> stored request: n/a");
		Surface.CurrentSelectionDeltaLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionRequestAlignmentSurface.StatusLine.IsEmpty()
			? TEXT("Request alignment: n/a")
			: FString::Printf(
				TEXT("Request alignment: %s"),
				*OptionRequestAlignmentSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingImportedRuntimeSelector* MatchingSelector =
		RuntimeSurface.Selectors.FindByPredicate(
			[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelector& Candidate)
			{
				return Candidate.SelectorId == SelectorId && Candidate.IsStructurallyValid();
			}
		);
	const FString SelectorBinding = MatchingSelector != nullptr
		? MatchingSelector->SelectorBinding
		: OptionMenuSurface.BindingLabel;
	const FHyperTwistTrainingImportedGeneratedModeLaunchRequest& LaunchRequest =
		RunState.ImportedGeneratedModeLaunchRequest;
	const bool bHasComparableStoredRequest = LaunchRequest.IsStructurallyValid()
		&& LaunchRequest.LaunchConfig.DeckId == RunState.ActiveDeck.DeckId
		&& LaunchRequest.LaunchConfig.SurfaceId == RuntimeSurface.SurfaceId
		&& LaunchRequest.LaunchConfig.RuntimeModeId.Equals(
			RuntimeSurface.RuntimeModeId,
			ESearchCase::IgnoreCase
		);

	const auto DescribeSelector = [](
		const FHyperTwistTrainingImportedRuntimeSelector& Selector
	) -> FString
	{
		if (!Selector.Label.IsEmpty())
		{
			return Selector.Label;
		}
		if (!Selector.SelectorBinding.IsEmpty())
		{
			return Selector.SelectorBinding;
		}
		return Selector.SelectorId;
	};

	const auto FindSelectorChoice = [](
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& Choices,
		const FString& InSelectorId
	) -> const FHyperTwistTrainingImportedRuntimeSelectorChoice*
	{
		return Choices.FindByPredicate(
			[&InSelectorId](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
			{
				return Candidate.SelectorId == InSelectorId && Candidate.IsStructurallyValid();
			}
		);
	};

	const auto DoChoicesMatch = [](
		const FHyperTwistTrainingImportedRuntimeSelectorChoice* LeftChoice,
		const FHyperTwistTrainingImportedRuntimeSelectorChoice* RightChoice
	) -> bool
	{
		if (LeftChoice == nullptr || RightChoice == nullptr)
		{
			return LeftChoice == nullptr && RightChoice == nullptr;
		}

		return LeftChoice->SelectedValue == RightChoice->SelectedValue;
	};

	const auto DescribeChoiceValue = [](
		const FHyperTwistTrainingImportedRuntimeSelectorChoice* Choice,
		const TCHAR* MissingText
	) -> FString
	{
		if (Choice == nullptr)
		{
			return MissingText;
		}

		if (Choice->DisplayValue.IsEmpty() || Choice->DisplayValue == Choice->SelectedValue)
		{
			return Choice->SelectedValue.IsEmpty() ? FString(MissingText) : Choice->SelectedValue;
		}

		return FString::Printf(
			TEXT("%s [%s]"),
			*Choice->DisplayValue,
			Choice->SelectedValue.IsEmpty() ? TEXT("n/a") : *Choice->SelectedValue
		);
	};

	const auto BuildPairDeltaLine = [](
		const TCHAR* Label,
		const FString& LeftValue,
		const FString& RightValue,
		const bool bMatches
	) -> FString
	{
		return bMatches
			? FString::Printf(TEXT("%s: no change (%s)"), Label, *RightValue)
			: FString::Printf(TEXT("%s: %s -> %s"), Label, *LeftValue, *RightValue);
	};

	const auto BuildAggregateDeltaLine = [](
		const TCHAR* Label,
		const TArray<FString>& ChangedSelectorLabels
	) -> FString
	{
		if (ChangedSelectorLabels.Num() == 0)
		{
			return FString::Printf(TEXT("%s: no selector change"), Label);
		}

		const int32 PreviewCount = FMath::Min(3, ChangedSelectorLabels.Num());
		TArray<FString> PreviewLabels;
		for (int32 Index = 0; Index < PreviewCount; ++Index)
		{
			PreviewLabels.Add(ChangedSelectorLabels[Index]);
		}

		return FString::Printf(
			TEXT("%s: %d selector change%s (%s%s)"),
			Label,
			ChangedSelectorLabels.Num(),
			ChangedSelectorLabels.Num() == 1 ? TEXT("") : TEXT("s"),
			*FString::Join(PreviewLabels, TEXT(", ")),
			ChangedSelectorLabels.Num() > PreviewCount
				? *FString::Printf(TEXT(" (+%d more)"), ChangedSelectorLabels.Num() - PreviewCount)
				: TEXT("")
		);
	};

	const auto BuildFallbackUnresolvedSelectorLine = [&DescribeSelector, &FindSelectorChoice, &RuntimeSurface](
		const FHyperTwistTrainingImportedRuntimeSelectionState& SelectionState,
		int32& OutUnresolvedSelectorCount
	) -> FString
	{
		OutUnresolvedSelectorCount = 0;
		TArray<FString> UnresolvedSelectorLabels;

		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			if (FindSelectorChoice(SelectionState.SelectorChoices, Selector.SelectorId) != nullptr)
			{
				continue;
			}

			++OutUnresolvedSelectorCount;
			UnresolvedSelectorLabels.Add(DescribeSelector(Selector));
		}

		if (OutUnresolvedSelectorCount == 0)
		{
			return TEXT("Unresolved after choice: none");
		}

		const int32 PreviewCount = FMath::Min(3, UnresolvedSelectorLabels.Num());
		TArray<FString> PreviewLabels;
		for (int32 Index = 0; Index < PreviewCount; ++Index)
		{
			PreviewLabels.Add(UnresolvedSelectorLabels[Index]);
		}

		return FString::Printf(
			TEXT("Unresolved after choice: %s%s"),
			*FString::Join(PreviewLabels, TEXT(", ")),
			UnresolvedSelectorLabels.Num() > PreviewCount
				? *FString::Printf(TEXT(" (+%d more)"), UnresolvedSelectorLabels.Num() - PreviewCount)
				: TEXT("")
		);
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option stored-request delta is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.SelectorDiffSummaryLine = TEXT("Selector diff: n/a");
		Surface.CurrentToHypotheticalSummaryLine = TEXT("Current -> hypothetical: n/a");
		Surface.StoredRequestToHypotheticalSummaryLine = TEXT("Stored request -> hypothetical: n/a");
		Surface.CurrentToStoredRequestSummaryLine = TEXT("Current -> stored request: n/a");
		Surface.CurrentSelectionDeltaLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active stored-request delta preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Dispatch: %s | Request alignment: %s"),
			OptionDispatchSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionDispatchSurface.StatusLine,
			OptionRequestAlignmentSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionRequestAlignmentSurface.StatusLine
		);
		return Surface;
	}

	int32 PreviewableGeneratedOptionCount = 0;
	int32 CurrentToHypotheticalDeltaOptionCount = 0;
	int32 StoredRequestToHypotheticalDeltaOptionCount = 0;
	int32 CurrentToStoredRequestDeltaOptionCount = 0;

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchEntrySurface& DispatchEntry :
		OptionDispatchSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionStoredRequestDeltaEntrySurface Entry;
		Entry.OptionId = DispatchEntry.OptionId;
		Entry.Label = DispatchEntry.Label;
		Entry.OptionValue = DispatchEntry.OptionValue;
		Entry.bMatchesCurrentSelection = DispatchEntry.bMatchesCurrentSelection;

		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentEntrySurface*
			MatchingRequestAlignmentEntry =
				OptionRequestAlignmentSurface.OptionEntries.FindByPredicate(
					[&DispatchEntry](
						const FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentEntrySurface&
							Candidate
					)
					{
						return Candidate.OptionId == DispatchEntry.OptionId;
					}
				);

		if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::DirectCaseLaunch
			&& DispatchEntry.bCanDispatch)
		{
			Entry.StoredRequestDeltaKind =
				EHyperTwistTrainingCoachGeneratedModeOptionStoredRequestDeltaKind::DirectOwnedCaseStart;
			Entry.HypotheticalSelectorSummaryLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->HypotheticalSelectorSummaryLine.IsEmpty()
				? TEXT("Hypothetical selectors: direct owned-case launch bypasses generated-mode selector-choice apply.")
				: MatchingRequestAlignmentEntry->HypotheticalSelectorSummaryLine;
			Entry.CurrentToHypotheticalDeltaLine =
				TEXT("Current -> hypothetical: direct owned-case launch bypasses selector diff preview.");
			Entry.StoredRequestToHypotheticalDeltaLine =
				TEXT("Stored request -> hypothetical: direct owned-case launch bypasses selector diff preview.");
			Entry.CurrentToStoredRequestDeltaLine =
				TEXT("Current -> stored request: direct owned-case launch bypasses selector diff preview.");
			Entry.UnresolvedSelectorsLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->UnresolvedSelectorsLine.IsEmpty()
				? TEXT("Unresolved after choice: n/a")
				: MatchingRequestAlignmentEntry->UnresolvedSelectorsLine;
			Entry.ExecutePreviewLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->ExecutePreviewLine.IsEmpty()
				? TEXT("Execute preview: direct owned-case launch starts immediately.")
				: MatchingRequestAlignmentEntry->ExecutePreviewLine;
			Entry.DetailLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->DetailLine.IsEmpty()
				? TEXT("Direct option launch bypasses generated-mode selector diff preview for this interaction.")
				: MatchingRequestAlignmentEntry->DetailLine;
			Entry.bStartsOwnedCaseImmediately = true;
			Entry.bCanPreview = true;
			++Surface.DirectOwnedCaseStartOptionCount;
		}
		else if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::ApplyGeneratedChoice
			&& DispatchEntry.bCanDispatch && MatchingSelector != nullptr)
		{
			++PreviewableGeneratedOptionCount;

			FHyperTwistTrainingImportedRuntimeSelectionState HypotheticalSelectionState =
				RunState.ImportedRuntimeSelectionState;
			if (!HypotheticalSelectionState.IsStructurallyValid())
			{
				HypotheticalSelectionState.SurfaceId = RuntimeSurface.SurfaceId;
				HypotheticalSelectionState.SurfaceKind = RuntimeSurface.SurfaceKind;
			}

			const FString SelectedValue = DispatchEntry.GeneratedChoiceSelectedValue.IsEmpty()
				? (DispatchEntry.OptionValue.IsEmpty()
					? DispatchEntry.OptionId
					: DispatchEntry.OptionValue)
				: DispatchEntry.GeneratedChoiceSelectedValue;
			const FString DisplayValue = DispatchEntry.GeneratedChoiceDisplayValue.IsEmpty()
				? (DispatchEntry.Label.IsEmpty() ? SelectedValue : DispatchEntry.Label)
				: DispatchEntry.GeneratedChoiceDisplayValue;

			FHyperTwistTrainingImportedRuntimeSelectorChoice* ExistingChoice =
				HypotheticalSelectionState.SelectorChoices.FindByPredicate(
					[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == SelectorId;
					}
				);
			if (ExistingChoice != nullptr)
			{
				ExistingChoice->SelectorBinding = SelectorBinding;
				ExistingChoice->SelectedValue = SelectedValue;
				ExistingChoice->DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
			}
			else
			{
				FHyperTwistTrainingImportedRuntimeSelectorChoice Choice;
				Choice.SelectorId = SelectorId;
				Choice.SelectorBinding = SelectorBinding;
				Choice.SelectedValue = SelectedValue;
				Choice.DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
				HypotheticalSelectionState.SelectorChoices.Add(MoveTemp(Choice));
			}

			Entry.HypotheticalSelectorSummaryLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->HypotheticalSelectorSummaryLine.IsEmpty()
				? OptionRequestAlignmentSurface.CurrentSelectionPreviewLine
				: MatchingRequestAlignmentEntry->HypotheticalSelectorSummaryLine;
			Entry.ExecutePreviewLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->ExecutePreviewLine.IsEmpty()
				? TEXT("Execute preview: unavailable.")
				: MatchingRequestAlignmentEntry->ExecutePreviewLine;

			if (MatchingRequestAlignmentEntry != nullptr)
			{
				Entry.UnresolvedSelectorsLine = MatchingRequestAlignmentEntry->UnresolvedSelectorsLine;
				Entry.UnresolvedSelectorCount = MatchingRequestAlignmentEntry->UnresolvedSelectorCount;
				Entry.bWouldLeaveSelectorsUnresolved =
					MatchingRequestAlignmentEntry->bWouldLeaveSelectorsUnresolved;
			}
			else
			{
				Entry.UnresolvedSelectorsLine = BuildFallbackUnresolvedSelectorLine(
					HypotheticalSelectionState,
					Entry.UnresolvedSelectorCount
				);
				Entry.bWouldLeaveSelectorsUnresolved = Entry.UnresolvedSelectorCount > 0;
			}

			TArray<FString> CurrentToHypotheticalChangedSelectorLabels;
			TArray<FString> StoredRequestToHypotheticalChangedSelectorLabels;
			TArray<FString> CurrentToStoredRequestChangedSelectorLabels;

			for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
			{
				if (!Selector.IsStructurallyValid())
				{
					continue;
				}

				const FString SelectorLabel = DescribeSelector(Selector);
				const FHyperTwistTrainingImportedRuntimeSelectorChoice* CurrentChoice =
					FindSelectorChoice(
						RunState.ImportedRuntimeSelectionState.SelectorChoices,
						Selector.SelectorId
					);
				const FHyperTwistTrainingImportedRuntimeSelectorChoice* HypotheticalChoice =
					FindSelectorChoice(
						HypotheticalSelectionState.SelectorChoices,
						Selector.SelectorId
					);
				const FHyperTwistTrainingImportedRuntimeSelectorChoice* StoredRequestChoice =
					bHasComparableStoredRequest
					? FindSelectorChoice(
						LaunchRequest.LaunchConfig.SelectorChoices,
						Selector.SelectorId
					)
					: nullptr;

				FHyperTwistTrainingCoachGeneratedModeSelectorOptionSelectorDiffEntrySurface
					SelectorDiffEntry;
				SelectorDiffEntry.SelectorId = Selector.SelectorId;
				SelectorDiffEntry.SelectorLabel = SelectorLabel;
				SelectorDiffEntry.BindingLabel = Selector.SelectorBinding;
				SelectorDiffEntry.CurrentSelectionValue =
					DescribeChoiceValue(CurrentChoice, TEXT("unresolved"));
				SelectorDiffEntry.HypotheticalSelectionValue =
					DescribeChoiceValue(HypotheticalChoice, TEXT("unresolved"));
				SelectorDiffEntry.StoredRequestSelectionValue =
					DescribeChoiceValue(StoredRequestChoice, TEXT("not stored"));
				SelectorDiffEntry.bIsTargetSelector = Selector.SelectorId == SelectorId;
				SelectorDiffEntry.bHasCurrentSelection = CurrentChoice != nullptr;
				SelectorDiffEntry.bHasHypotheticalSelection = HypotheticalChoice != nullptr;
				SelectorDiffEntry.bHasStoredRequestSelection = StoredRequestChoice != nullptr;
				SelectorDiffEntry.bCurrentMatchesHypothetical =
					DoChoicesMatch(CurrentChoice, HypotheticalChoice);
				SelectorDiffEntry.bStoredRequestMatchesHypothetical =
					DoChoicesMatch(StoredRequestChoice, HypotheticalChoice);
				SelectorDiffEntry.bCurrentMatchesStoredRequest =
					DoChoicesMatch(CurrentChoice, StoredRequestChoice);
				SelectorDiffEntry.CurrentToHypotheticalDeltaLine = BuildPairDeltaLine(
					TEXT("Current -> hypothetical"),
					SelectorDiffEntry.CurrentSelectionValue,
					SelectorDiffEntry.HypotheticalSelectionValue,
					SelectorDiffEntry.bCurrentMatchesHypothetical
				);
				SelectorDiffEntry.StoredRequestToHypotheticalDeltaLine = BuildPairDeltaLine(
					TEXT("Stored request -> hypothetical"),
					SelectorDiffEntry.StoredRequestSelectionValue,
					SelectorDiffEntry.HypotheticalSelectionValue,
					SelectorDiffEntry.bStoredRequestMatchesHypothetical
				);
				SelectorDiffEntry.CurrentToStoredRequestDeltaLine = BuildPairDeltaLine(
					TEXT("Current -> stored request"),
					SelectorDiffEntry.CurrentSelectionValue,
					SelectorDiffEntry.StoredRequestSelectionValue,
					SelectorDiffEntry.bCurrentMatchesStoredRequest
				);

				if (!SelectorDiffEntry.bCurrentMatchesHypothetical)
				{
					++Entry.CurrentToHypotheticalChangedSelectorCount;
					CurrentToHypotheticalChangedSelectorLabels.Add(SelectorLabel);
				}
				if (!SelectorDiffEntry.bStoredRequestMatchesHypothetical)
				{
					++Entry.StoredRequestToHypotheticalChangedSelectorCount;
					StoredRequestToHypotheticalChangedSelectorLabels.Add(SelectorLabel);
				}
				if (!SelectorDiffEntry.bCurrentMatchesStoredRequest)
				{
					++Entry.CurrentToStoredRequestChangedSelectorCount;
					CurrentToStoredRequestChangedSelectorLabels.Add(SelectorLabel);
				}

				Entry.SelectorDiffEntries.Add(MoveTemp(SelectorDiffEntry));
			}

			Entry.bHasCurrentToHypotheticalDelta =
				Entry.CurrentToHypotheticalChangedSelectorCount > 0;
			Entry.bHasStoredRequestToHypotheticalDelta =
				Entry.StoredRequestToHypotheticalChangedSelectorCount > 0;
			Entry.bHasCurrentToStoredRequestDelta =
				Entry.CurrentToStoredRequestChangedSelectorCount > 0;
			Entry.CurrentToHypotheticalDeltaLine = BuildAggregateDeltaLine(
				TEXT("Current -> hypothetical"),
				CurrentToHypotheticalChangedSelectorLabels
			);
			Entry.StoredRequestToHypotheticalDeltaLine = BuildAggregateDeltaLine(
				TEXT("Stored request -> hypothetical"),
				StoredRequestToHypotheticalChangedSelectorLabels
			);
			Entry.CurrentToStoredRequestDeltaLine = BuildAggregateDeltaLine(
				TEXT("Current -> stored request"),
				CurrentToStoredRequestChangedSelectorLabels
			);

			if (Entry.bWouldLeaveSelectorsUnresolved)
			{
				Entry.StoredRequestDeltaKind =
					EHyperTwistTrainingCoachGeneratedModeOptionStoredRequestDeltaKind::
						UnresolvedAfterChoice;
				++Surface.UnresolvedAfterChoiceOptionCount;
			}
			else if (!Entry.bHasCurrentToHypotheticalDelta
				&& !Entry.bHasStoredRequestToHypotheticalDelta)
			{
				Entry.StoredRequestDeltaKind =
					EHyperTwistTrainingCoachGeneratedModeOptionStoredRequestDeltaKind::NoSelectorDelta;
				++Surface.NoSelectorDeltaOptionCount;
			}
			else if (Entry.bHasCurrentToHypotheticalDelta
				&& !Entry.bHasStoredRequestToHypotheticalDelta)
			{
				Entry.StoredRequestDeltaKind =
					EHyperTwistTrainingCoachGeneratedModeOptionStoredRequestDeltaKind::
						CurrentDeltaOnly;
				++Surface.CurrentDeltaOnlyOptionCount;
			}
			else if (!Entry.bHasCurrentToHypotheticalDelta
				&& Entry.bHasStoredRequestToHypotheticalDelta)
			{
				Entry.StoredRequestDeltaKind =
					EHyperTwistTrainingCoachGeneratedModeOptionStoredRequestDeltaKind::
						StoredRequestDeltaOnly;
				++Surface.StoredRequestDeltaOnlyOptionCount;
			}
			else
			{
				Entry.StoredRequestDeltaKind =
					EHyperTwistTrainingCoachGeneratedModeOptionStoredRequestDeltaKind::
						CurrentAndStoredDelta;
				++Surface.CurrentAndStoredDeltaOptionCount;
			}

			const FString RequestAlignmentDetail =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->DetailLine.IsEmpty()
				? TEXT("Request alignment detail: n/a")
				: MatchingRequestAlignmentEntry->DetailLine;
			const FString StoredRequestAlignmentLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->StoredRequestAlignmentLine.IsEmpty()
				? TEXT("Stored request alignment: n/a")
				: MatchingRequestAlignmentEntry->StoredRequestAlignmentLine;
			Entry.DetailLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.CurrentToStoredRequestDeltaLine,
				*StoredRequestAlignmentLine,
				*RequestAlignmentDetail
			);
			Entry.bCanPreview = true;

			if (Entry.bHasCurrentToHypotheticalDelta)
			{
				++CurrentToHypotheticalDeltaOptionCount;
			}
			if (Entry.bHasStoredRequestToHypotheticalDelta)
			{
				++StoredRequestToHypotheticalDeltaOptionCount;
			}
			if (Entry.bHasCurrentToStoredRequestDelta)
			{
				++CurrentToStoredRequestDeltaOptionCount;
			}
		}
		else
		{
			Entry.StoredRequestDeltaKind =
				EHyperTwistTrainingCoachGeneratedModeOptionStoredRequestDeltaKind::Unavailable;
			Entry.HypotheticalSelectorSummaryLine = TEXT("Hypothetical selectors: unavailable");
			Entry.CurrentToHypotheticalDeltaLine = TEXT("Current -> hypothetical: unavailable");
			Entry.StoredRequestToHypotheticalDeltaLine =
				TEXT("Stored request -> hypothetical: unavailable");
			Entry.CurrentToStoredRequestDeltaLine = TEXT("Current -> stored request: unavailable");
			Entry.UnresolvedSelectorsLine = TEXT("Unresolved after choice: unavailable");
			Entry.ExecutePreviewLine = TEXT("Execute preview: unavailable.");
			Entry.DetailLine =
				TEXT("Stored-request delta preview is unavailable because this selector option cannot dispatch from the active generated-mode surface.");
			Entry.bCanPreview = false;
			++Surface.UnavailableOptionCount;
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasCurrentToHypotheticalDelta =
				Entry.bHasCurrentToHypotheticalDelta;
			Surface.bCurrentSelectionHasStoredRequestToHypotheticalDelta =
				Entry.bHasStoredRequestToHypotheticalDelta;
			Surface.bCurrentSelectionHasCurrentToStoredRequestDelta =
				Entry.bHasCurrentToStoredRequestDelta;
			Surface.bCurrentSelectionWouldLeaveSelectorsUnresolved =
				Entry.bWouldLeaveSelectorsUnresolved;
			Surface.CurrentSelectionDeltaLine = Entry.bStartsOwnedCaseImmediately
				? FString::Printf(
					TEXT("%s | %s"),
					*Entry.CurrentToHypotheticalDeltaLine,
					*Entry.ExecutePreviewLine
				)
				: FString::Printf(
					TEXT("%s | %s | %s | %s"),
					*Entry.CurrentToHypotheticalDeltaLine,
					*Entry.StoredRequestToHypotheticalDeltaLine,
					*Entry.CurrentToStoredRequestDeltaLine,
					Entry.bWouldLeaveSelectorsUnresolved
						? *Entry.UnresolvedSelectorsLine
						: *Entry.ExecutePreviewLine
				);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasStoredRequestDeltaOptions = PreviewableGeneratedOptionCount > 0;
	Surface.bHasCurrentToHypotheticalDeltaOptions = CurrentToHypotheticalDeltaOptionCount > 0;
	Surface.bHasStoredRequestToHypotheticalDeltaOptions =
		StoredRequestToHypotheticalDeltaOptionCount > 0;
	Surface.bHasCurrentToStoredRequestDeltaOptions =
		CurrentToStoredRequestDeltaOptionCount > 0;
	Surface.bHasUnresolvedAfterChoiceOptions = Surface.UnresolvedAfterChoiceOptionCount > 0;

	Surface.SelectorDiffSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Selector diff: %d no-delta | %d current-only | %d stored-only | %d current+stored | %d unresolved | %d direct-launch | %d unavailable"),
			Surface.NoSelectorDeltaOptionCount,
			Surface.CurrentDeltaOnlyOptionCount,
			Surface.StoredRequestDeltaOnlyOptionCount,
			Surface.CurrentAndStoredDeltaOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount,
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Selector diff: no imported options");
	Surface.CurrentToHypotheticalSummaryLine = PreviewableGeneratedOptionCount > 0
		? FString::Printf(
			TEXT("Current -> hypothetical: %d option%s change at least one selector; %d keep selector state unchanged."),
			CurrentToHypotheticalDeltaOptionCount,
			CurrentToHypotheticalDeltaOptionCount == 1 ? TEXT("") : TEXT("s"),
			PreviewableGeneratedOptionCount - CurrentToHypotheticalDeltaOptionCount
		)
		: TEXT("Current -> hypothetical: no previewable generated-choice options");
	Surface.StoredRequestToHypotheticalSummaryLine = PreviewableGeneratedOptionCount > 0
		? FString::Printf(
			TEXT("Stored request -> hypothetical: %d option%s diverge from the stored request baseline; %d stay aligned."),
			StoredRequestToHypotheticalDeltaOptionCount,
			StoredRequestToHypotheticalDeltaOptionCount == 1 ? TEXT("") : TEXT("s"),
			PreviewableGeneratedOptionCount - StoredRequestToHypotheticalDeltaOptionCount
		)
		: TEXT("Stored request -> hypothetical: no previewable generated-choice options");
	Surface.CurrentToStoredRequestSummaryLine = PreviewableGeneratedOptionCount > 0
		? FString::Printf(
			TEXT("Current -> stored request: %d option%s retain at least one selector delta from the stored request baseline."),
			CurrentToStoredRequestDeltaOptionCount,
			CurrentToStoredRequestDeltaOptionCount == 1 ? TEXT("") : TEXT("s")
		)
		: TEXT("Current -> stored request: no previewable generated-choice options");

	if (Surface.CurrentSelectionDeltaLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionDeltaLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionDeltaLine =
				TEXT("Current selection has no additional stored-request delta preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionDeltaLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionDeltaLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option stored-request delta exposes %d no-delta option%s, %d current-delta-only option%s, %d stored-request-delta-only option%s, %d current-and-stored-delta option%s, %d unresolved option%s, %d direct-launch option%s, and %d unavailable option%s."),
			Surface.NoSelectorDeltaOptionCount,
			Surface.NoSelectorDeltaOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.CurrentDeltaOnlyOptionCount,
			Surface.CurrentDeltaOnlyOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.StoredRequestDeltaOnlyOptionCount,
			Surface.StoredRequestDeltaOnlyOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.CurrentAndStoredDeltaOptionCount,
			Surface.CurrentAndStoredDeltaOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnresolvedAfterChoiceOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.DirectOwnedCaseStartOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option stored-request delta is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option stored-request delta is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Dispatch: %s | Request alignment: %s | Selector: %s | Binding: %s"),
		OptionDispatchSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionDispatchSurface.StatusLine,
		OptionRequestAlignmentSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionRequestAlignmentSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchSurface& OptionDispatchSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentSurface&
		OptionRequestAlignmentSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Launch-Request Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Launch-Request Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Launch-Request Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option launch-request preview requires a selector id from the active selector roster.");
		Surface.PayloadSummaryLine = TEXT("Payload preview: n/a");
		Surface.StoredRequestReuseSummaryLine = TEXT("Stored request reuse: n/a");
		Surface.RefreshPreviewSummaryLine = TEXT("Refresh preview: n/a");
		Surface.CurrentSelectionPayloadLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionRequestAlignmentSurface.StatusLine.IsEmpty()
			? TEXT("Request alignment: n/a")
			: FString::Printf(
				TEXT("Request alignment: %s"),
				*OptionRequestAlignmentSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingImportedRuntimeSelector* MatchingSelector =
		RuntimeSurface.Selectors.FindByPredicate(
			[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelector& Candidate)
			{
				return Candidate.SelectorId == SelectorId && Candidate.IsStructurallyValid();
			}
		);
	const FString SelectorBinding = MatchingSelector != nullptr
		? MatchingSelector->SelectorBinding
		: OptionMenuSurface.BindingLabel;
	const FHyperTwistTrainingImportedGeneratedModeLaunchRequest& LaunchRequest =
		RunState.ImportedGeneratedModeLaunchRequest;
	const bool bHasComparableStoredRequest = LaunchRequest.IsStructurallyValid()
		&& LaunchRequest.LaunchConfig.DeckId == RunState.ActiveDeck.DeckId
		&& LaunchRequest.LaunchConfig.SurfaceId == RuntimeSurface.SurfaceId
		&& LaunchRequest.LaunchConfig.RuntimeModeId.Equals(
			RuntimeSurface.RuntimeModeId,
			ESearchCase::IgnoreCase
		);
	const FHyperTwistTrainingCase* SeedCase = RunState.ActiveDeck.Cases.FindByPredicate(
		[](const FHyperTwistTrainingCase& Candidate)
		{
			return Candidate.IsStructurallyValid();
		}
	);
	const FString FallbackPuzzleId = SeedCase != nullptr ? SeedCase->PuzzleId : FString();

	const auto DescribeDeliveryMode = [](
		const EHyperTwistTrainingDeliveryMode DeliveryMode
	) -> FString
	{
		switch (DeliveryMode)
		{
			case EHyperTwistTrainingDeliveryMode::Timer:
				return TEXT("Timer");
			case EHyperTwistTrainingDeliveryMode::VirtualCube:
				return TEXT("Virtual Cube");
			case EHyperTwistTrainingDeliveryMode::SmartDevice:
				return TEXT("Smart Device");
			case EHyperTwistTrainingDeliveryMode::RecognitionAssisted:
				return TEXT("Recognition Assisted");
			case EHyperTwistTrainingDeliveryMode::CoachReviewed:
				return TEXT("Coach Reviewed");
			default:
				return TEXT("Unknown");
		}
	};

	const auto DescribeSelector = [](
		const FHyperTwistTrainingImportedRuntimeSelector& Selector
	) -> FString
	{
		if (!Selector.Label.IsEmpty())
		{
			return Selector.Label;
		}
		if (!Selector.SelectorBinding.IsEmpty())
		{
			return Selector.SelectorBinding;
		}
		return Selector.SelectorId;
	};

	const auto FindSelectorChoice = [](
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& Choices,
		const FString& InSelectorId
	) -> const FHyperTwistTrainingImportedRuntimeSelectorChoice*
	{
		return Choices.FindByPredicate(
			[&InSelectorId](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
			{
				return Candidate.SelectorId == InSelectorId && Candidate.IsStructurallyValid();
			}
		);
	};

	const auto DoChoicesMatch = [](
		const FHyperTwistTrainingImportedRuntimeSelectorChoice* LeftChoice,
		const FHyperTwistTrainingImportedRuntimeSelectorChoice* RightChoice
	) -> bool
	{
		if (LeftChoice == nullptr || RightChoice == nullptr)
		{
			return LeftChoice == nullptr && RightChoice == nullptr;
		}

		return LeftChoice->SelectedValue == RightChoice->SelectedValue;
	};

	const auto DoSelectorChoiceSetsMatch = [&RuntimeSurface, &FindSelectorChoice](
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& LeftChoices,
		const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& RightChoices
	) -> bool
	{
		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* LeftChoice =
				FindSelectorChoice(LeftChoices, Selector.SelectorId);
			const FHyperTwistTrainingImportedRuntimeSelectorChoice* RightChoice =
				FindSelectorChoice(RightChoices, Selector.SelectorId);
			if (LeftChoice == nullptr || RightChoice == nullptr)
			{
				return false;
			}
			if (LeftChoice->SelectedValue != RightChoice->SelectedValue)
			{
				return false;
			}
		}

		return true;
	};

	const auto DoesLaunchRequestMatchLaunchConfig = [&DoSelectorChoiceSetsMatch](
		const FHyperTwistTrainingImportedGeneratedModeLaunchRequest& InLaunchRequest,
		const FHyperTwistTrainingImportedGeneratedModeLaunchConfig& ExpectedLaunchConfig
	) -> bool
	{
		return InLaunchRequest.IsStructurallyValid()
			&& InLaunchRequest.LaunchConfig.DeckId == ExpectedLaunchConfig.DeckId
			&& InLaunchRequest.LaunchConfig.SurfaceId == ExpectedLaunchConfig.SurfaceId
			&& InLaunchRequest.LaunchConfig.RuntimeModeId.Equals(
				ExpectedLaunchConfig.RuntimeModeId,
				ESearchCase::IgnoreCase
			)
			&& DoSelectorChoiceSetsMatch(
				InLaunchRequest.LaunchConfig.SelectorChoices,
				ExpectedLaunchConfig.SelectorChoices
			);
	};

	const auto DescribeChoiceValue = [](
		const FHyperTwistTrainingImportedRuntimeSelectorChoice* Choice,
		const TCHAR* MissingText
	) -> FString
	{
		if (Choice == nullptr)
		{
			return MissingText;
		}

		if (Choice->DisplayValue.IsEmpty() || Choice->DisplayValue == Choice->SelectedValue)
		{
			return Choice->SelectedValue.IsEmpty() ? FString(MissingText) : Choice->SelectedValue;
		}

		return FString::Printf(
			TEXT("%s [%s]"),
			*Choice->DisplayValue,
			Choice->SelectedValue.IsEmpty() ? TEXT("n/a") : *Choice->SelectedValue
		);
	};

	const auto BuildPayloadIdentityLine = [&DescribeDeliveryMode](
		const FString& DeckId,
		const FString& TrainingSessionId,
		const EHyperTwistTrainingDeliveryMode DeliveryMode,
		const FString& SurfaceId,
		const FString& SurfaceLabel,
		const FString& RuntimeModeId,
		const FString& GeneratorType,
		const FString& PuzzleId
	) -> FString
	{
		const FString DeckSummary = DeckId.IsEmpty() ? TEXT("n/a") : DeckId;
		const FString SessionSummary = TrainingSessionId.IsEmpty() ? TEXT("n/a") : TrainingSessionId;
		const FString SurfaceSummary = SurfaceLabel.IsEmpty()
			? (SurfaceId.IsEmpty() ? FString(TEXT("n/a")) : SurfaceId)
			: FString::Printf(
				TEXT("%s [%s]"),
				*SurfaceLabel,
				SurfaceId.IsEmpty() ? TEXT("n/a") : *SurfaceId
			);
		const FString RuntimeModeSummary = RuntimeModeId.IsEmpty() ? TEXT("n/a") : RuntimeModeId;
		const FString GeneratorSummary = GeneratorType.IsEmpty() ? TEXT("n/a") : GeneratorType;
		const FString PuzzleSummary = PuzzleId.IsEmpty() ? TEXT("n/a") : PuzzleId;
		return FString::Printf(
			TEXT("Payload: deck=%s | session=%s | delivery=%s | surface=%s | mode=%s | generator=%s | puzzle=%s"),
			*DeckSummary,
			*SessionSummary,
			*DescribeDeliveryMode(DeliveryMode),
			*SurfaceSummary,
			*RuntimeModeSummary,
			*GeneratorSummary,
			*PuzzleSummary
		);
	};

	const auto BuildSelectorChoiceEntriesAndSummary =
		[&RuntimeSurface,
		 &SelectorId,
		 &RunState,
		 &LaunchRequest,
		 &bHasComparableStoredRequest,
		 &DescribeSelector,
		 &FindSelectorChoice,
		 &DoChoicesMatch,
		 &DescribeChoiceValue](
			const TArray<FHyperTwistTrainingImportedRuntimeSelectorChoice>& PreviewChoices,
			TArray<FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestSelectorChoiceEntrySurface>&
				OutEntries,
			int32& OutResolvedChoiceCount
		) -> FString
	{
		OutEntries.Reset();
		OutResolvedChoiceCount = 0;

		TSet<FString> AddedSelectorIds;
		TArray<FString> SelectorParts;

		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* PreviewChoice =
				FindSelectorChoice(PreviewChoices, Selector.SelectorId);
			const FHyperTwistTrainingImportedRuntimeSelectorChoice* CurrentChoice =
				FindSelectorChoice(
					RunState.ImportedRuntimeSelectionState.SelectorChoices,
					Selector.SelectorId
				);
			const FHyperTwistTrainingImportedRuntimeSelectorChoice* StoredRequestChoice =
				bHasComparableStoredRequest
				? FindSelectorChoice(LaunchRequest.LaunchConfig.SelectorChoices, Selector.SelectorId)
				: nullptr;
			const FString ChoiceValueSummary = DescribeChoiceValue(PreviewChoice, TEXT("unresolved"));

			FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestSelectorChoiceEntrySurface
				ChoiceEntry;
			ChoiceEntry.SelectorId = Selector.SelectorId;
			ChoiceEntry.SelectorLabel = DescribeSelector(Selector);
			ChoiceEntry.BindingLabel = Selector.SelectorBinding;
			ChoiceEntry.SelectedValue = PreviewChoice == nullptr ? FString() : PreviewChoice->SelectedValue;
			ChoiceEntry.DisplayValue = ChoiceValueSummary;
			ChoiceEntry.PayloadLine = FString::Printf(
				TEXT("Payload choice: %s=%s"),
				*ChoiceEntry.SelectorLabel,
				*ChoiceValueSummary
			);
			ChoiceEntry.bIsTargetSelector = Selector.SelectorId == SelectorId;
			ChoiceEntry.bHasChoice = PreviewChoice != nullptr;
			ChoiceEntry.bMatchesCurrentSelectionChoice = DoChoicesMatch(CurrentChoice, PreviewChoice);
			ChoiceEntry.bMatchesStoredRequestChoice =
				bHasComparableStoredRequest && DoChoicesMatch(StoredRequestChoice, PreviewChoice);

			if (PreviewChoice != nullptr)
			{
				++OutResolvedChoiceCount;
			}

			SelectorParts.Add(FString::Printf(
				TEXT("%s=%s"),
				*ChoiceEntry.SelectorLabel,
				*ChoiceValueSummary
			));
			AddedSelectorIds.Add(Selector.SelectorId);
			OutEntries.Add(MoveTemp(ChoiceEntry));
		}

		for (const FHyperTwistTrainingImportedRuntimeSelectorChoice& PreviewChoice : PreviewChoices)
		{
			if (!PreviewChoice.IsStructurallyValid()
				|| AddedSelectorIds.Contains(PreviewChoice.SelectorId))
			{
				continue;
			}

			const FHyperTwistTrainingImportedRuntimeSelectorChoice* CurrentChoice =
				FindSelectorChoice(
					RunState.ImportedRuntimeSelectionState.SelectorChoices,
					PreviewChoice.SelectorId
				);
			const FHyperTwistTrainingImportedRuntimeSelectorChoice* StoredRequestChoice =
				bHasComparableStoredRequest
				? FindSelectorChoice(
					LaunchRequest.LaunchConfig.SelectorChoices,
					PreviewChoice.SelectorId
				)
				: nullptr;
			const FString ChoiceValueSummary = DescribeChoiceValue(&PreviewChoice, TEXT("unresolved"));

			FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestSelectorChoiceEntrySurface
				ChoiceEntry;
			ChoiceEntry.SelectorId = PreviewChoice.SelectorId;
			ChoiceEntry.SelectorLabel = PreviewChoice.SelectorBinding.IsEmpty()
				? PreviewChoice.SelectorId
				: PreviewChoice.SelectorBinding;
			ChoiceEntry.BindingLabel = PreviewChoice.SelectorBinding;
			ChoiceEntry.SelectedValue = PreviewChoice.SelectedValue;
			ChoiceEntry.DisplayValue = ChoiceValueSummary;
			ChoiceEntry.PayloadLine = FString::Printf(
				TEXT("Payload choice: %s=%s"),
				*ChoiceEntry.SelectorLabel,
				*ChoiceValueSummary
			);
			ChoiceEntry.bIsTargetSelector = PreviewChoice.SelectorId == SelectorId;
			ChoiceEntry.bHasChoice = true;
			ChoiceEntry.bMatchesCurrentSelectionChoice = DoChoicesMatch(CurrentChoice, &PreviewChoice);
			ChoiceEntry.bMatchesStoredRequestChoice =
				bHasComparableStoredRequest && DoChoicesMatch(StoredRequestChoice, &PreviewChoice);

			++OutResolvedChoiceCount;
			SelectorParts.Add(FString::Printf(
				TEXT("%s=%s"),
				*ChoiceEntry.SelectorLabel,
				*ChoiceValueSummary
			));
			OutEntries.Add(MoveTemp(ChoiceEntry));
		}

		return SelectorParts.Num() > 0
			? FString::Printf(
				TEXT("Selector payload: %s"),
				*FString::Join(SelectorParts, TEXT(" | "))
			)
			: TEXT("Selector payload: none");
	};

	const auto BuildFallbackUnresolvedSelectorLine = [&RuntimeSurface, &DescribeSelector, &FindSelectorChoice](
		const FHyperTwistTrainingImportedRuntimeSelectionState& SelectionState,
		int32& OutUnresolvedSelectorCount
	) -> FString
	{
		OutUnresolvedSelectorCount = 0;
		TArray<FString> UnresolvedLabels;

		for (const FHyperTwistTrainingImportedRuntimeSelector& Selector : RuntimeSurface.Selectors)
		{
			if (!Selector.IsStructurallyValid())
			{
				continue;
			}

			if (FindSelectorChoice(SelectionState.SelectorChoices, Selector.SelectorId) != nullptr)
			{
				continue;
			}

			++OutUnresolvedSelectorCount;
			UnresolvedLabels.Add(DescribeSelector(Selector));
		}

		if (OutUnresolvedSelectorCount == 0)
		{
			return TEXT("Unresolved after choice: none");
		}

		const int32 PreviewCount = FMath::Min(3, UnresolvedLabels.Num());
		TArray<FString> PreviewLabels;
		for (int32 Index = 0; Index < PreviewCount; ++Index)
		{
			PreviewLabels.Add(UnresolvedLabels[Index]);
		}

		return FString::Printf(
			TEXT("Unresolved after choice: %s%s"),
			*FString::Join(PreviewLabels, TEXT(", ")),
			UnresolvedLabels.Num() > PreviewCount
				? *FString::Printf(TEXT(" (+%d more)"), UnresolvedLabels.Num() - PreviewCount)
				: TEXT("")
		);
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option launch-request preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.PayloadSummaryLine = TEXT("Payload preview: n/a");
		Surface.StoredRequestReuseSummaryLine = TEXT("Stored request reuse: n/a");
		Surface.RefreshPreviewSummaryLine = TEXT("Refresh preview: n/a");
		Surface.CurrentSelectionPayloadLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active launch-request preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Dispatch: %s | Request alignment: %s"),
			OptionDispatchSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionDispatchSurface.StatusLine,
			OptionRequestAlignmentSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionRequestAlignmentSurface.StatusLine
		);
		return Surface;
	}

	const FString FallbackPayloadIdentityLine = BuildPayloadIdentityLine(
		RunState.ActiveDeck.DeckId,
		RunState.Session.TrainingSessionId,
		RunState.Session.Mode,
		RuntimeSurface.SurfaceId,
		RuntimeSurface.SurfaceLabel,
		RuntimeSurface.RuntimeModeId,
		RuntimeSurface.GeneratorType,
		FallbackPuzzleId
	);

	int32 PreviewableGeneratedOptionCount = 0;
	int32 PreviewablePayloadOptionCount = 0;

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionDispatchEntrySurface& DispatchEntry :
		OptionDispatchSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface Entry;
		Entry.OptionId = DispatchEntry.OptionId;
		Entry.Label = DispatchEntry.Label;
		Entry.OptionValue = DispatchEntry.OptionValue;
		Entry.bMatchesCurrentSelection = DispatchEntry.bMatchesCurrentSelection;
		Entry.HypotheticalDeckId = RunState.ActiveDeck.DeckId;
		Entry.HypotheticalTrainingSessionId = RunState.Session.TrainingSessionId;
		Entry.HypotheticalSurfaceId = RuntimeSurface.SurfaceId;
		Entry.HypotheticalSurfaceLabel = RuntimeSurface.SurfaceLabel;
		Entry.HypotheticalRuntimeModeId = RuntimeSurface.RuntimeModeId;
		Entry.HypotheticalGeneratorType = RuntimeSurface.GeneratorType;
		Entry.HypotheticalPuzzleId = FallbackPuzzleId;
		Entry.HypotheticalDeliveryMode = RunState.Session.Mode;

		const FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentEntrySurface*
			MatchingRequestAlignmentEntry =
				OptionRequestAlignmentSurface.OptionEntries.FindByPredicate(
					[&DispatchEntry](
						const FHyperTwistTrainingCoachGeneratedModeSelectorOptionRequestAlignmentEntrySurface&
							Candidate
					)
					{
						return Candidate.OptionId == DispatchEntry.OptionId;
					}
				);
		const FString RequestAlignmentDetail =
			MatchingRequestAlignmentEntry == nullptr || MatchingRequestAlignmentEntry->DetailLine.IsEmpty()
			? TEXT("Request alignment detail: n/a")
			: MatchingRequestAlignmentEntry->DetailLine;

		if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::DirectCaseLaunch
			&& DispatchEntry.bCanDispatch)
		{
			Entry.LaunchRequestPreviewKind =
				EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
					DirectOwnedCaseStart;
			Entry.PayloadIdentityLine =
				TEXT("Payload: direct owned-case launch bypasses generated-mode launch-request staging.");
			Entry.SelectorPayloadLine =
				TEXT("Selector payload: direct owned-case launch bypasses generated-mode selector payload staging.");
			Entry.StoredRequestReuseLine =
				TEXT("Stored request reuse: direct owned-case launch bypasses stored launch-request reuse.");
			Entry.RefreshPreviewLine =
				TEXT("Refresh preview: direct owned-case launch bypasses generated-mode request refresh.");
			Entry.ExecutePreviewLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->ExecutePreviewLine.IsEmpty()
				? TEXT("Execute preview: direct owned-case launch starts immediately.")
				: MatchingRequestAlignmentEntry->ExecutePreviewLine;
			Entry.DetailLine = MatchingRequestAlignmentEntry == nullptr
				? DispatchEntry.DetailLine
				: FString::Printf(TEXT("%s | %s"), *Entry.PayloadIdentityLine, *RequestAlignmentDetail);
			Entry.bStartsOwnedCaseImmediately = true;
			Entry.bCanPreview = true;
			++Surface.DirectOwnedCaseStartOptionCount;
		}
		else if (DispatchEntry.DispatchKind
				== EHyperTwistTrainingCoachGeneratedModeOptionDispatchKind::ApplyGeneratedChoice
			&& DispatchEntry.bCanDispatch && MatchingSelector != nullptr)
		{
			++PreviewableGeneratedOptionCount;

			FHyperTwistTrainingImportedRuntimeSelectionState HypotheticalSelectionState =
				RunState.ImportedRuntimeSelectionState;
			if (!HypotheticalSelectionState.IsStructurallyValid())
			{
				HypotheticalSelectionState.SurfaceId = RuntimeSurface.SurfaceId;
				HypotheticalSelectionState.SurfaceKind = RuntimeSurface.SurfaceKind;
			}

			const FString SelectedValue = DispatchEntry.GeneratedChoiceSelectedValue.IsEmpty()
				? (DispatchEntry.OptionValue.IsEmpty()
					? DispatchEntry.OptionId
					: DispatchEntry.OptionValue)
				: DispatchEntry.GeneratedChoiceSelectedValue;
			const FString DisplayValue = DispatchEntry.GeneratedChoiceDisplayValue.IsEmpty()
				? (DispatchEntry.Label.IsEmpty() ? SelectedValue : DispatchEntry.Label)
				: DispatchEntry.GeneratedChoiceDisplayValue;

			FHyperTwistTrainingImportedRuntimeSelectorChoice* ExistingChoice =
				HypotheticalSelectionState.SelectorChoices.FindByPredicate(
					[&SelectorId](const FHyperTwistTrainingImportedRuntimeSelectorChoice& Candidate)
					{
						return Candidate.SelectorId == SelectorId;
					}
				);
			if (ExistingChoice != nullptr)
			{
				ExistingChoice->SelectorBinding = SelectorBinding;
				ExistingChoice->SelectedValue = SelectedValue;
				ExistingChoice->DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
			}
			else
			{
				FHyperTwistTrainingImportedRuntimeSelectorChoice Choice;
				Choice.SelectorId = SelectorId;
				Choice.SelectorBinding = SelectorBinding;
				Choice.SelectedValue = SelectedValue;
				Choice.DisplayValue = DisplayValue.IsEmpty() ? SelectedValue : DisplayValue;
				HypotheticalSelectionState.SelectorChoices.Add(MoveTemp(Choice));
			}

			Entry.ExecutePreviewLine =
				MatchingRequestAlignmentEntry == nullptr
				|| MatchingRequestAlignmentEntry->ExecutePreviewLine.IsEmpty()
				? TEXT("Execute preview: unavailable.")
				: MatchingRequestAlignmentEntry->ExecutePreviewLine;
			if (MatchingRequestAlignmentEntry != nullptr)
			{
				Entry.bWouldLeaveSelectorsUnresolved =
					MatchingRequestAlignmentEntry->bWouldLeaveSelectorsUnresolved;
			}

			int32 UnresolvedSelectorCount = 0;
			FString UnresolvedSelectorsLine = MatchingRequestAlignmentEntry == nullptr
				? BuildFallbackUnresolvedSelectorLine(
					HypotheticalSelectionState,
					UnresolvedSelectorCount
				)
				: MatchingRequestAlignmentEntry->UnresolvedSelectorsLine;
			if (MatchingRequestAlignmentEntry != nullptr)
			{
				UnresolvedSelectorCount = MatchingRequestAlignmentEntry->UnresolvedSelectorCount;
			}

			Entry.PayloadIdentityLine = FallbackPayloadIdentityLine;
			Entry.SelectorPayloadLine = BuildSelectorChoiceEntriesAndSummary(
				HypotheticalSelectionState.SelectorChoices,
				Entry.SelectorChoiceEntries,
				Entry.SelectorChoiceCount
			);

			if (Entry.bWouldLeaveSelectorsUnresolved)
			{
				Entry.LaunchRequestPreviewKind =
					EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
						UnresolvedAfterChoice;
				Entry.StoredRequestReuseLine =
					TEXT("Stored request reuse: no structurally valid launch payload is available while selector coverage remains incomplete.");
				Entry.RefreshPreviewLine =
					TEXT("Refresh preview: execute cannot stage a launch request until every required selector is resolved.");
				Entry.DetailLine = FString::Printf(
					TEXT("%s | %s | %s"),
					*Entry.SelectorPayloadLine,
					*UnresolvedSelectorsLine,
					*RequestAlignmentDetail
				);
				Entry.bCanPreview = true;
				++Surface.UnresolvedAfterChoiceOptionCount;
			}
			else
			{
				FHyperTwistTrainingImportedGeneratedModeLaunchConfig HypotheticalLaunchConfig;
				if (!UHyperTwistTrainingCatalogLibrary::TryBuildImportedGeneratedModeLaunchConfig(
						RunState.ActiveDeck,
						HypotheticalSelectionState,
						RunState.Session,
						HypotheticalLaunchConfig))
				{
					Entry.LaunchRequestPreviewKind =
						EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							PayloadUnavailable;
					Entry.StoredRequestReuseLine =
						TEXT("Stored request reuse: no structurally valid launch payload could be derived from the resulting selector state.");
					Entry.RefreshPreviewLine =
						TEXT("Refresh preview: execute cannot preview request refresh because the resulting selector state is not structurally valid.");
					Entry.DetailLine = FString::Printf(
						TEXT("%s | %s"),
						*Entry.SelectorPayloadLine,
						*RequestAlignmentDetail
					);
					Entry.bCanPreview = true;
					++Surface.PayloadUnavailableOptionCount;
				}
				else
				{
					const bool bWouldReuseStoredRequest =
						MatchingRequestAlignmentEntry != nullptr
						? MatchingRequestAlignmentEntry->bWouldUseStoredRequestOnExecute
						: DoesLaunchRequestMatchLaunchConfig(
							LaunchRequest,
							HypotheticalLaunchConfig
						);
					const bool bWouldRequireLaunchRequestRefresh =
						MatchingRequestAlignmentEntry != nullptr
						? MatchingRequestAlignmentEntry->bWouldRequireLaunchRequestRefreshBeforeExecute
						: !bWouldReuseStoredRequest;

					Entry.HypotheticalDeckId = HypotheticalLaunchConfig.DeckId;
					Entry.HypotheticalTrainingSessionId =
						HypotheticalLaunchConfig.TrainingSessionId;
					Entry.HypotheticalSurfaceId = HypotheticalLaunchConfig.SurfaceId;
					Entry.HypotheticalSurfaceLabel = HypotheticalLaunchConfig.SurfaceLabel;
					Entry.HypotheticalRuntimeModeId = HypotheticalLaunchConfig.RuntimeModeId;
					Entry.HypotheticalGeneratorType = HypotheticalLaunchConfig.GeneratorType;
					Entry.HypotheticalPuzzleId = HypotheticalLaunchConfig.PuzzleId;
					Entry.HypotheticalDeliveryMode = HypotheticalLaunchConfig.DeliveryMode;
					Entry.PayloadIdentityLine = BuildPayloadIdentityLine(
						HypotheticalLaunchConfig.DeckId,
						HypotheticalLaunchConfig.TrainingSessionId,
						HypotheticalLaunchConfig.DeliveryMode,
						HypotheticalLaunchConfig.SurfaceId,
						HypotheticalLaunchConfig.SurfaceLabel,
						HypotheticalLaunchConfig.RuntimeModeId,
						HypotheticalLaunchConfig.GeneratorType,
						HypotheticalLaunchConfig.PuzzleId
					);
					Entry.SelectorPayloadLine = BuildSelectorChoiceEntriesAndSummary(
						HypotheticalLaunchConfig.SelectorChoices,
						Entry.SelectorChoiceEntries,
						Entry.SelectorChoiceCount
					);
					Entry.bWouldReuseStoredRequest = bWouldReuseStoredRequest;
					Entry.bWouldRequireLaunchRequestRefresh =
						bWouldRequireLaunchRequestRefresh;
					Entry.bHasStructurallyValidLaunchPayload = true;
					Entry.bCanPreview = true;

					if (bWouldReuseStoredRequest)
					{
						Entry.LaunchRequestPreviewKind =
							EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
								StoredRequestReusable;
						Entry.StoredRequestReuseLine =
							TEXT("Stored request reuse: the current stored request already matches this hypothetical launch payload.");
						Entry.RefreshPreviewLine =
							TEXT("Refresh preview: execute can use the stored request without rebuilding it.");
						++Surface.StoredRequestReusableOptionCount;
					}
					else
					{
						Entry.LaunchRequestPreviewKind =
							EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
								RefreshRequired;
						Entry.StoredRequestReuseLine =
							!LaunchRequest.IsStructurallyValid()
							? TEXT("Stored request reuse: no stored request is currently persisted for this hypothetical launch payload.")
							: (bHasComparableStoredRequest
								? TEXT("Stored request reuse: this hypothetical launch payload diverges from the current stored request.")
								: TEXT("Stored request reuse: a stored request exists, but it does not match this generated-mode surface or runtime mode."));
						Entry.RefreshPreviewLine =
							!LaunchRequest.IsStructurallyValid()
							? TEXT("Refresh preview: execute would persist a first stored request from this hypothetical launch payload.")
							: (bHasComparableStoredRequest
								? TEXT("Refresh preview: execute would refresh the stored request from this hypothetical launch payload.")
								: TEXT("Refresh preview: execute would replace the currently persisted stored request with this hypothetical launch payload."));
						++Surface.RefreshRequiredOptionCount;
					}

					++PreviewablePayloadOptionCount;
					Entry.DetailLine = FString::Printf(
						TEXT("%s | %s"),
						*Entry.PayloadIdentityLine,
						*RequestAlignmentDetail
					);
				}
			}
		}
		else
		{
			Entry.LaunchRequestPreviewKind =
				EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable;
			Entry.PayloadIdentityLine = TEXT("Payload: unavailable");
			Entry.SelectorPayloadLine = TEXT("Selector payload: unavailable");
			Entry.StoredRequestReuseLine = TEXT("Stored request reuse: unavailable");
			Entry.RefreshPreviewLine = TEXT("Refresh preview: unavailable");
			Entry.ExecutePreviewLine = TEXT("Execute preview: unavailable.");
			Entry.DetailLine =
				TEXT("Launch-request preview is unavailable because this selector option cannot dispatch from the active generated-mode surface.");
			Entry.bCanPreview = false;
			++Surface.UnavailableOptionCount;
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionWouldReuseStoredRequest = Entry.bWouldReuseStoredRequest;
			Surface.bCurrentSelectionWouldRequireLaunchRequestRefresh =
				Entry.bWouldRequireLaunchRequestRefresh;
			Surface.bCurrentSelectionWouldLeaveSelectorsUnresolved =
				Entry.bWouldLeaveSelectorsUnresolved;
			Surface.bCurrentSelectionHasStructurallyValidLaunchPayload =
				Entry.bHasStructurallyValidLaunchPayload;
			Surface.CurrentSelectionPayloadLine = Entry.bStartsOwnedCaseImmediately
				? FString::Printf(
					TEXT("%s | %s"),
					*Entry.PayloadIdentityLine,
					*Entry.ExecutePreviewLine
				)
				: FString::Printf(
					TEXT("%s | %s | %s"),
					*Entry.PayloadIdentityLine,
					*Entry.StoredRequestReuseLine,
					*Entry.RefreshPreviewLine
				);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasLaunchRequestPreviewOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasStoredRequestReusableOptions = Surface.StoredRequestReusableOptionCount > 0;
	Surface.bHasRefreshRequiredOptions = Surface.RefreshRequiredOptionCount > 0;
	Surface.bHasUnresolvedAfterChoiceOptions = Surface.UnresolvedAfterChoiceOptionCount > 0;
	Surface.bHasPayloadUnavailableOptions = Surface.PayloadUnavailableOptionCount > 0;

	Surface.PayloadSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Payload preview: %d reusable | %d refresh-required | %d unresolved | %d payload-unavailable | %d direct-launch | %d unavailable"),
			Surface.StoredRequestReusableOptionCount,
			Surface.RefreshRequiredOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount,
			Surface.PayloadUnavailableOptionCount,
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Payload preview: no imported options");
	Surface.StoredRequestReuseSummaryLine = PreviewableGeneratedOptionCount > 0
		? FString::Printf(
			TEXT("Stored request reuse: %d option%s can reuse the current stored request; %d would need refresh; %d still have no valid launch payload."),
			Surface.StoredRequestReusableOptionCount,
			Surface.StoredRequestReusableOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.RefreshRequiredOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount + Surface.PayloadUnavailableOptionCount
		)
		: TEXT("Stored request reuse: no previewable generated-choice options");
	Surface.RefreshPreviewSummaryLine = PreviewableGeneratedOptionCount > 0
		? FString::Printf(
			TEXT("Refresh preview: %d option%s would refresh the stored request; %d stay reusable without refresh; %d still cannot stage a complete payload."),
			Surface.RefreshRequiredOptionCount,
			Surface.RefreshRequiredOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.StoredRequestReusableOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount + Surface.PayloadUnavailableOptionCount
		)
		: TEXT("Refresh preview: no previewable generated-choice options");

	if (Surface.CurrentSelectionPayloadLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionPayloadLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionPayloadLine =
				TEXT("Current selection has no additional launch-request payload preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionPayloadLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionPayloadLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option launch-request preview exposes %d stored-request-reusable option%s, %d refresh-required option%s, %d unresolved option%s, %d payload-unavailable option%s, %d direct-launch option%s, and %d unavailable option%s."),
			Surface.StoredRequestReusableOptionCount,
			Surface.StoredRequestReusableOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.RefreshRequiredOptionCount,
			Surface.RefreshRequiredOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnresolvedAfterChoiceOptionCount,
			Surface.UnresolvedAfterChoiceOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.PayloadUnavailableOptionCount,
			Surface.PayloadUnavailableOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.DirectOwnedCaseStartOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option launch-request preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option launch-request preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Dispatch: %s | Request alignment: %s | Payload-ready: %d | Selector: %s | Binding: %s"),
		OptionDispatchSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionDispatchSurface.StatusLine,
		OptionRequestAlignmentSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionRequestAlignmentSurface.StatusLine,
		PreviewablePayloadOptionCount,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestMetadataPreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionLaunchRequestMetadataPreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
		OptionLaunchRequestPreviewSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestMetadataPreviewSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Launch-Request Metadata Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Launch-Request Metadata Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Launch-Request Metadata Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option launch-request metadata preview requires a selector id from the active selector roster.");
		Surface.MetadataSummaryLine = TEXT("Metadata preview: n/a");
		Surface.MetadataScopeLine = TEXT("Metadata scope: n/a");
		Surface.OriginSummaryLine = TEXT("Origin paths: n/a");
		Surface.NotesSummaryLine = TEXT("Notes: n/a");
		Surface.CurrentSelectionMetadataLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	const auto BuildOriginSummaryLine = [](
		const TArray<FString>& OriginPaths
	) -> FString
	{
		if (OriginPaths.Num() == 0)
		{
			return TEXT("Origin paths: none");
		}

		const int32 PreviewCount = FMath::Min(2, OriginPaths.Num());
		TArray<FString> PreviewPaths;
		for (int32 Index = 0; Index < PreviewCount; ++Index)
		{
			PreviewPaths.Add(OriginPaths[Index]);
		}

		return FString::Printf(
			TEXT("Origin paths: %d (%s%s)"),
			OriginPaths.Num(),
			*FString::Join(PreviewPaths, TEXT(" | ")),
			OriginPaths.Num() > PreviewCount
				? *FString::Printf(TEXT(" | +%d more"), OriginPaths.Num() - PreviewCount)
				: TEXT("")
		);
	};

	const auto BuildNotesSummaryLine = [](
		const FString& Notes
	) -> FString
	{
		return Notes.IsEmpty()
			? TEXT("Notes: none")
			: FString::Printf(TEXT("Notes: %s"), *Notes);
	};

	const auto BuildMetadataScopeLine = [](
		const FString& SurfaceId,
		const FString& SurfaceLabel,
		const FString& RuntimeModeId,
		const FString& GeneratorType
	) -> FString
	{
		const FString SurfaceSummary = SurfaceLabel.IsEmpty()
			? (SurfaceId.IsEmpty() ? FString(TEXT("n/a")) : SurfaceId)
			: FString::Printf(
				TEXT("%s [%s]"),
				*SurfaceLabel,
				SurfaceId.IsEmpty() ? TEXT("n/a") : *SurfaceId
			);
		const FString RuntimeModeSummary = RuntimeModeId.IsEmpty() ? TEXT("n/a") : RuntimeModeId;
		const FString GeneratorSummary = GeneratorType.IsEmpty() ? TEXT("n/a") : GeneratorType;
		return FString::Printf(
			TEXT("Metadata scope: surface=%s | mode=%s | generator=%s"),
			*SurfaceSummary,
			*RuntimeModeSummary,
			*GeneratorSummary
		);
	};

	Surface.OriginPaths = RuntimeSurface.OriginPaths;
	Surface.Notes = RuntimeSurface.Notes;
	Surface.OriginPathCount = RuntimeSurface.OriginPaths.Num();
	Surface.OriginSummaryLine = BuildOriginSummaryLine(RuntimeSurface.OriginPaths);
	Surface.NotesSummaryLine = BuildNotesSummaryLine(RuntimeSurface.Notes);
	Surface.MetadataScopeLine = BuildMetadataScopeLine(
		RuntimeSurface.SurfaceId,
		RuntimeSurface.SurfaceLabel,
		RuntimeSurface.RuntimeModeId,
		RuntimeSurface.GeneratorType
	);

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option launch-request metadata preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.MetadataSummaryLine = TEXT("Metadata preview: n/a");
		Surface.MetadataScopeLine = TEXT("Metadata scope: n/a");
		Surface.OriginSummaryLine = TEXT("Origin paths: n/a");
		Surface.NotesSummaryLine = TEXT("Notes: n/a");
		Surface.CurrentSelectionMetadataLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active launch-request metadata preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestMetadataPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.PayloadIdentityLine = PreviewEntry.PayloadIdentityLine;
		Entry.HypotheticalSurfaceId = PreviewEntry.HypotheticalSurfaceId.IsEmpty()
			? RuntimeSurface.SurfaceId
			: PreviewEntry.HypotheticalSurfaceId;
		Entry.HypotheticalSurfaceLabel = PreviewEntry.HypotheticalSurfaceLabel.IsEmpty()
			? RuntimeSurface.SurfaceLabel
			: PreviewEntry.HypotheticalSurfaceLabel;
		Entry.HypotheticalRuntimeModeId = PreviewEntry.HypotheticalRuntimeModeId.IsEmpty()
			? RuntimeSurface.RuntimeModeId
			: PreviewEntry.HypotheticalRuntimeModeId;
		Entry.HypotheticalGeneratorType = PreviewEntry.HypotheticalGeneratorType.IsEmpty()
			? RuntimeSurface.GeneratorType
			: PreviewEntry.HypotheticalGeneratorType;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		if (PreviewEntry.LaunchRequestPreviewKind
				== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
					DirectOwnedCaseStart)
		{
			Entry.MetadataScopeLine =
				TEXT("Metadata scope: direct owned-case launch bypasses generated-mode launch-request metadata preview.");
			Entry.OriginSummaryLine =
				TEXT("Origin paths: direct owned-case launch bypasses generated-mode launch-request metadata preview.");
			Entry.NotesSummaryLine =
				TEXT("Notes: direct owned-case launch bypasses generated-mode launch-request metadata preview.");
			Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
				? TEXT("Launch-request metadata preview is not applicable because this option starts a direct owned case instead of staging a generated-mode payload.")
				: PreviewEntry.DetailLine;
			Entry.bCanPreview = true;
			++Surface.DirectOwnedCaseStartOptionCount;
		}
		else if (PreviewEntry.LaunchRequestPreviewKind
					== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable
			|| PreviewEntry.LaunchRequestPreviewKind
				== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None)
		{
			Entry.MetadataScopeLine = TEXT("Metadata scope: unavailable");
			Entry.OriginSummaryLine = TEXT("Origin paths: unavailable");
			Entry.NotesSummaryLine = TEXT("Notes: unavailable");
			Entry.DetailLine =
				TEXT("Launch-request metadata preview is unavailable because this selector option has no generated-mode payload preview from the active surface.");
			Entry.bCanPreview = false;
			++Surface.UnavailableOptionCount;
		}
		else
		{
			Entry.OriginPaths = RuntimeSurface.OriginPaths;
			Entry.Notes = RuntimeSurface.Notes;
			Entry.OriginPathCount = RuntimeSurface.OriginPaths.Num();
			Entry.bHasOriginPaths = RuntimeSurface.OriginPaths.Num() > 0;
			Entry.bHasNotes = !RuntimeSurface.Notes.IsEmpty();
			Entry.bHasMetadataPreview = true;
			Entry.bCanPreview = true;
			Entry.MetadataScopeLine = BuildMetadataScopeLine(
				Entry.HypotheticalSurfaceId,
				Entry.HypotheticalSurfaceLabel,
				Entry.HypotheticalRuntimeModeId,
				Entry.HypotheticalGeneratorType
			);
			Entry.OriginSummaryLine = BuildOriginSummaryLine(RuntimeSurface.OriginPaths);
			Entry.NotesSummaryLine = BuildNotesSummaryLine(RuntimeSurface.Notes);
			Entry.DetailLine = FString::Printf(
				TEXT("%s | %s"),
				*Entry.MetadataScopeLine,
				PreviewEntry.RefreshPreviewLine.IsEmpty()
					? (PreviewEntry.StoredRequestReuseLine.IsEmpty()
						? TEXT("Launch-request metadata preview stays attached to the imported generated-mode surface.")
						: *PreviewEntry.StoredRequestReuseLine)
					: *PreviewEntry.RefreshPreviewLine
			);
			++Surface.MetadataPreviewOptionCount;
			if (Entry.bHasOriginPaths)
			{
				++Surface.OriginPathOptionCount;
			}
			if (Entry.bHasNotes)
			{
				++Surface.NotesOptionCount;
			}
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasOriginPaths = Entry.bHasOriginPaths;
			Surface.bCurrentSelectionHasNotes = Entry.bHasNotes;
			Surface.CurrentSelectionMetadataLine = Entry.bStartsOwnedCaseImmediately
				? Entry.OriginSummaryLine
				: FString::Printf(
					TEXT("%s | %s"),
					*Entry.OriginSummaryLine,
					*Entry.NotesSummaryLine
				);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasMetadataPreviewOptions = Surface.MetadataPreviewOptionCount > 0;
	Surface.bHasOriginPathOptions = Surface.OriginPathOptionCount > 0;
	Surface.bHasNotesOptions = Surface.NotesOptionCount > 0;

	Surface.MetadataSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Metadata preview: %d payload-backed option%s, %d with origin paths, %d with notes, %d direct-launch, %d unavailable."),
			Surface.MetadataPreviewOptionCount,
			Surface.MetadataPreviewOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.OriginPathOptionCount,
			Surface.NotesOptionCount,
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Metadata preview: no imported options");

	if (Surface.CurrentSelectionMetadataLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionMetadataLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionMetadataLine =
				TEXT("Current selection has no additional launch-request metadata preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionMetadataLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionMetadataLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option launch-request metadata preview exposes %d payload-backed option%s, %d direct-launch option%s, and %d unavailable option%s."),
			Surface.MetadataPreviewOptionCount,
			Surface.MetadataPreviewOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.DirectOwnedCaseStartOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option launch-request metadata preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option launch-request metadata preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestEnvelopePreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionLaunchRequestEnvelopePreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
		OptionLaunchRequestPreviewSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestEnvelopePreviewSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Launch-Request Envelope Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Launch-Request Envelope Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Launch-Request Envelope Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option launch-request envelope preview requires a selector id from the active selector roster.");
		Surface.EnvelopeSummaryLine = TEXT("Stored request envelope: n/a");
		Surface.RequestSourceSummaryLine = TEXT("Request source preview: n/a");
		Surface.PersistenceSummaryLine = TEXT("Persistence preview: n/a");
		Surface.CurrentSelectionEnvelopeLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface = RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingImportedGeneratedModeLaunchRequest& LaunchRequest =
		RunState.ImportedGeneratedModeLaunchRequest;
	const bool bHasStoredRequestEnvelope = LaunchRequest.IsStructurallyValid();
	const bool bHasStoredRequestForActiveSurface = bHasStoredRequestEnvelope
		&& LaunchRequest.LaunchConfig.DeckId == RunState.ActiveDeck.DeckId
		&& LaunchRequest.LaunchConfig.SurfaceId == RuntimeSurface.SurfaceId
		&& LaunchRequest.LaunchConfig.RuntimeModeId.Equals(
			RuntimeSurface.RuntimeModeId,
			ESearchCase::IgnoreCase
		);
	const FString ExecuteRequestSource = TEXT("runtime-imported-generated-mode-executor");

	const auto BuildStoredEnvelopeLine = [](
		const FString& RequestId,
		const FString& RequestedAtUtc,
		const FString& RequestSource
	) -> FString
	{
		if (RequestId.IsEmpty() && RequestedAtUtc.IsEmpty() && RequestSource.IsEmpty())
		{
			return TEXT("Stored request envelope: none");
		}

		return FString::Printf(
			TEXT("Stored request envelope: %s @ %s | source: %s"),
			RequestId.IsEmpty() ? TEXT("n/a") : *RequestId,
			RequestedAtUtc.IsEmpty() ? TEXT("n/a") : *RequestedAtUtc,
			RequestSource.IsEmpty() ? TEXT("n/a") : *RequestSource
		);
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option launch-request envelope preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.EnvelopeSummaryLine = TEXT("Stored request envelope: n/a");
		Surface.RequestSourceSummaryLine = TEXT("Request source preview: n/a");
		Surface.PersistenceSummaryLine = TEXT("Persistence preview: n/a");
		Surface.CurrentSelectionEnvelopeLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active launch-request envelope preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestEnvelopePreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.HypotheticalDeckId = PreviewEntry.HypotheticalDeckId.IsEmpty()
			? RunState.ActiveDeck.DeckId
			: PreviewEntry.HypotheticalDeckId;
		Entry.HypotheticalSurfaceId = PreviewEntry.HypotheticalSurfaceId.IsEmpty()
			? RuntimeSurface.SurfaceId
			: PreviewEntry.HypotheticalSurfaceId;
		Entry.HypotheticalRuntimeModeId = PreviewEntry.HypotheticalRuntimeModeId.IsEmpty()
			? RuntimeSurface.RuntimeModeId
			: PreviewEntry.HypotheticalRuntimeModeId;
		Entry.CurrentStoredRequestId = LaunchRequest.RequestId;
		Entry.CurrentStoredRequestedAtUtc = LaunchRequest.RequestedAtUtc;
		Entry.CurrentStoredRequestSource = LaunchRequest.RequestSource;
		Entry.ExecuteRequestSource = ExecuteRequestSource;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;
		Entry.bHasStoredRequestEnvelope = bHasStoredRequestEnvelope;
		Entry.StoredRequestEnvelopeLine = BuildStoredEnvelopeLine(
			LaunchRequest.RequestId,
			LaunchRequest.RequestedAtUtc,
			LaunchRequest.RequestSource
		);

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
				Entry.RequestIdLine =
					TEXT("Request id: direct owned-case launch bypasses generated-mode launch-request staging.");
				Entry.RequestedAtLine =
					TEXT("Requested at: direct owned-case launch bypasses generated-mode launch-request staging.");
				Entry.RequestSourceLine =
					TEXT("Request source: direct owned-case launch bypasses generated-mode launch-request staging.");
				Entry.PersistencePreviewLine =
					TEXT("Persistence: execute would not create or reuse a generated-mode stored request envelope for this option.");
				Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
					? TEXT("Launch-request envelope preview is not applicable because this option starts a direct owned case instead of staging a generated-mode payload.")
					: PreviewEntry.DetailLine;
				Entry.bCanPreview = true;
				++Surface.DirectOwnedCaseStartOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
				Entry.RequestIdLine = FString::Printf(
					TEXT("Request id: reuse %s"),
					LaunchRequest.RequestId.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestId
				);
				Entry.RequestedAtLine = FString::Printf(
					TEXT("Requested at: reuse %s"),
					LaunchRequest.RequestedAtUtc.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestedAtUtc
				);
				Entry.RequestSourceLine = FString::Printf(
					TEXT("Request source: reuse %s"),
					LaunchRequest.RequestSource.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestSource
				);
				Entry.PersistencePreviewLine =
					TEXT("Persistence: execute reuses the current stored request envelope without generating a new request id or timestamp.");
				Entry.bWouldReuseStoredRequestEnvelope = true;
				Entry.bCanPreview = true;
				++Surface.StoredRequestReusableOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				Entry.RequestIdLine =
					TEXT("Request id on execute: generated at execute time");
				Entry.RequestedAtLine =
					TEXT("Requested at on execute: generated at execute time");
				Entry.RequestSourceLine = FString::Printf(
					TEXT("Request source on execute: %s"),
					*ExecuteRequestSource
				);
				Entry.bCanPreview = true;
				if (!bHasStoredRequestEnvelope)
				{
					Entry.PersistencePreviewLine =
						TEXT("Persistence: execute would persist the first stored request envelope for this generated-mode payload.");
					Entry.bWouldPersistFirstStoredRequestEnvelope = true;
					++Surface.FirstPersistOptionCount;
				}
				else if (bHasStoredRequestForActiveSurface)
				{
					Entry.PersistencePreviewLine =
						TEXT("Persistence: execute would refresh the current stored request envelope for this active generated-mode surface.");
					Entry.bWouldRefreshStoredRequestEnvelope = true;
					++Surface.RefreshExistingOptionCount;
				}
				else
				{
					Entry.PersistencePreviewLine =
						TEXT("Persistence: execute would replace the currently persisted stored request envelope with one for this generated-mode payload.");
					Entry.bWouldReplaceStoredRequestEnvelope = true;
					++Surface.ReplaceStoredRequestOptionCount;
				}
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.RequestIdLine = bHasStoredRequestEnvelope
					? FString::Printf(
						TEXT("Current request id: %s"),
						LaunchRequest.RequestId.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestId
					)
					: TEXT("Current request id: none");
				Entry.RequestedAtLine = bHasStoredRequestEnvelope
					? FString::Printf(
						TEXT("Current requested-at: %s"),
						LaunchRequest.RequestedAtUtc.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestedAtUtc
					)
					: TEXT("Current requested-at: none");
				Entry.RequestSourceLine = bHasStoredRequestEnvelope
					? FString::Printf(
						TEXT("Current request source: %s"),
						LaunchRequest.RequestSource.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestSource
					)
					: FString::Printf(
						TEXT("Request source on execute: %s (after selectors are resolved)"),
						*ExecuteRequestSource
					);
				Entry.PersistencePreviewLine =
					TEXT("Persistence: execute cannot create or refresh a stored request envelope until every required selector is resolved.");
				Entry.bPersistencePreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.PersistenceBlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.RequestIdLine = bHasStoredRequestEnvelope
					? FString::Printf(
						TEXT("Current request id: %s"),
						LaunchRequest.RequestId.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestId
					)
					: TEXT("Current request id: none");
				Entry.RequestedAtLine = bHasStoredRequestEnvelope
					? FString::Printf(
						TEXT("Current requested-at: %s"),
						LaunchRequest.RequestedAtUtc.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestedAtUtc
					)
					: TEXT("Current requested-at: none");
				Entry.RequestSourceLine = bHasStoredRequestEnvelope
					? FString::Printf(
						TEXT("Current request source: %s"),
						LaunchRequest.RequestSource.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestSource
					)
					: FString::Printf(
						TEXT("Request source on execute: %s (once payload becomes valid)"),
						*ExecuteRequestSource
					);
				Entry.PersistencePreviewLine =
					TEXT("Persistence: execute cannot create or refresh a stored request envelope until a structurally valid launch payload can be derived.");
				Entry.bPersistencePreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.PersistenceBlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.StoredRequestEnvelopeLine = TEXT("Stored request envelope: unavailable");
				Entry.RequestIdLine = TEXT("Request id: unavailable");
				Entry.RequestedAtLine = TEXT("Requested at: unavailable");
				Entry.RequestSourceLine = TEXT("Request source: unavailable");
				Entry.PersistencePreviewLine = TEXT("Persistence: unavailable");
				Entry.DetailLine =
					TEXT("Launch-request envelope preview is unavailable because this selector option has no generated-mode payload preview from the active surface.");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		if (Entry.DetailLine.IsEmpty())
		{
			Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
				? Entry.PersistencePreviewLine
				: FString::Printf(
					TEXT("%s | %s"),
					*Entry.PersistencePreviewLine,
					*PreviewEntry.DetailLine
				);
		}

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasStoredRequestEnvelope = Entry.bHasStoredRequestEnvelope;
			Surface.bCurrentSelectionWouldReuseStoredRequestEnvelope =
				Entry.bWouldReuseStoredRequestEnvelope;
			Surface.bCurrentSelectionWouldPersistFirstStoredRequestEnvelope =
				Entry.bWouldPersistFirstStoredRequestEnvelope;
			Surface.bCurrentSelectionWouldRefreshStoredRequestEnvelope =
				Entry.bWouldRefreshStoredRequestEnvelope;
			Surface.bCurrentSelectionWouldReplaceStoredRequestEnvelope =
				Entry.bWouldReplaceStoredRequestEnvelope;
			Surface.CurrentSelectionEnvelopeLine = FString::Printf(
				TEXT("%s | %s"),
				*Entry.StoredRequestEnvelopeLine,
				*Entry.PersistencePreviewLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasEnvelopePreviewOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasStoredRequestReusableOptions = Surface.StoredRequestReusableOptionCount > 0;
	Surface.bHasFirstPersistOptions = Surface.FirstPersistOptionCount > 0;
	Surface.bHasRefreshExistingOptions = Surface.RefreshExistingOptionCount > 0;
	Surface.bHasReplaceStoredRequestOptions = Surface.ReplaceStoredRequestOptionCount > 0;
	Surface.bHasPersistenceBlockedOptions = Surface.PersistenceBlockedOptionCount > 0;

	Surface.EnvelopeSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Stored request envelope: %d reusable | %d first-persist | %d refresh | %d replace | %d blocked | %d direct-launch | %d unavailable"),
			Surface.StoredRequestReusableOptionCount,
			Surface.FirstPersistOptionCount,
			Surface.RefreshExistingOptionCount,
			Surface.ReplaceStoredRequestOptionCount,
			Surface.PersistenceBlockedOptionCount,
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Stored request envelope: no imported options");
	Surface.RequestSourceSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Request source preview: stored=%s | execute-refresh source=%s"),
			bHasStoredRequestEnvelope
				? (LaunchRequest.RequestSource.IsEmpty() ? TEXT("n/a") : *LaunchRequest.RequestSource)
				: TEXT("none"),
			*ExecuteRequestSource
		)
		: TEXT("Request source preview: n/a");
	Surface.PersistenceSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Persistence preview: %d option%s reuse the current envelope; %d create first envelope; %d refresh existing; %d replace stored; %d remain blocked."),
			Surface.StoredRequestReusableOptionCount,
			Surface.StoredRequestReusableOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.FirstPersistOptionCount,
			Surface.RefreshExistingOptionCount,
			Surface.ReplaceStoredRequestOptionCount,
			Surface.PersistenceBlockedOptionCount
		)
		: TEXT("Persistence preview: no imported options");

	if (Surface.CurrentSelectionEnvelopeLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionEnvelopeLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionEnvelopeLine =
				TEXT("Current selection has no additional launch-request envelope preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionEnvelopeLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionEnvelopeLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option launch-request envelope preview exposes %d reusable option%s, %d first-persist option%s, %d refresh option%s, %d replace option%s, %d blocked option%s, %d direct-launch option%s, and %d unavailable option%s."),
			Surface.StoredRequestReusableOptionCount,
			Surface.StoredRequestReusableOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.FirstPersistOptionCount,
			Surface.FirstPersistOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.RefreshExistingOptionCount,
			Surface.RefreshExistingOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.ReplaceStoredRequestOptionCount,
			Surface.ReplaceStoredRequestOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.PersistenceBlockedOptionCount,
			Surface.PersistenceBlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.DirectOwnedCaseStartOptionCount,
			Surface.DirectOwnedCaseStartOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option launch-request envelope preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option launch-request envelope preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionCasePreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionOwnedExecutionCasePreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestEnvelopePreviewSurface&
		OptionLaunchRequestEnvelopePreviewSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionCasePreviewSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Owned-Execution Case Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Case Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Case Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution case preview requires a selector id from the active selector roster.");
		Surface.OwnedCaseSummaryLine = TEXT("Owned case target: n/a");
		Surface.CanonicalStateSummaryLine = TEXT("Canonical state ref: n/a");
		Surface.CurrentSelectionPreviewLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestEnvelopePreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request envelope preview: n/a")
			: FString::Printf(
				TEXT("Launch-request envelope preview: %s"),
				*OptionLaunchRequestEnvelopePreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);

	const auto SanitizeGeneratedModeToken = [](const FString& Value) -> FString
	{
		FString Sanitized;
		Sanitized.Reserve(Value.Len());

		for (const TCHAR Character : Value)
		{
			if (FChar::IsAlnum(Character))
			{
				Sanitized.AppendChar(FChar::ToLower(Character));
			}
			else if (Sanitized.IsEmpty() || Sanitized[Sanitized.Len() - 1] != TEXT('-'))
			{
				Sanitized.AppendChar(TEXT('-'));
			}
		}

		while (Sanitized.StartsWith(TEXT("-")))
		{
			Sanitized.RightChopInline(1, EAllowShrinking::No);
		}
		while (Sanitized.EndsWith(TEXT("-")))
		{
			Sanitized.LeftChopInline(1, EAllowShrinking::No);
		}

		return Sanitized.IsEmpty() ? TEXT("value") : Sanitized;
	};

	const auto BuildGeneratedModeCaseId = [&SanitizeGeneratedModeToken](
		const FString& DeckId,
		const FString& RequestId
	) -> FString
	{
		return DeckId.IsEmpty() || RequestId.IsEmpty()
			? FString()
			: FString::Printf(
				TEXT("%s/generated/%s"),
				*DeckId,
				*SanitizeGeneratedModeToken(RequestId)
			);
	};

	const auto BuildGeneratedModeCanonicalStateRef = [&SanitizeGeneratedModeToken](
		const FString& SurfaceId,
		const FString& RuntimeModeId,
		const FString& RequestId
	) -> FString
	{
		return SurfaceId.IsEmpty() || RuntimeModeId.IsEmpty() || RequestId.IsEmpty()
			? FString()
			: FString::Printf(
				TEXT("generated-mode/%s/%s/%s"),
				*SanitizeGeneratedModeToken(SurfaceId),
				*SanitizeGeneratedModeToken(RuntimeModeId),
				*SanitizeGeneratedModeToken(RequestId)
			);
	};

	const auto BuildGeneratedModeCaseIdTemplate = [](const FString& DeckId) -> FString
	{
		const FString DeckSummary = DeckId.IsEmpty() ? TEXT("<active-deck>") : DeckId;
		return FString::Printf(TEXT("%s/generated/<next-request-id>"), *DeckSummary);
	};

	const auto BuildGeneratedModeCanonicalStateRefTemplate = [&SanitizeGeneratedModeToken](
		const FString& SurfaceId,
		const FString& RuntimeModeId
	) -> FString
	{
		const FString SurfaceToken = SurfaceId.IsEmpty()
			? TEXT("<surface>")
			: SanitizeGeneratedModeToken(SurfaceId);
		const FString RuntimeToken = RuntimeModeId.IsEmpty()
			? TEXT("<runtime-mode>")
			: SanitizeGeneratedModeToken(RuntimeModeId);
		return FString::Printf(
			TEXT("generated-mode/%s/%s/<next-request-id>"),
			*SurfaceToken,
			*RuntimeToken
		);
	};

	const auto BuildCoveredCaseTargetLine = [](
		const FString& CaseId,
		const FString& CaseLabel
	) -> FString
	{
		if (CaseId.IsEmpty() && CaseLabel.IsEmpty())
		{
			return TEXT("Owned case target: covered owned case");
		}
		if (CaseLabel.IsEmpty() || CaseLabel == CaseId)
		{
			return FString::Printf(
				TEXT("Owned case target: %s"),
				CaseId.IsEmpty() ? TEXT("n/a") : *CaseId
			);
		}
		return FString::Printf(
			TEXT("Owned case target: %s [%s]"),
			*CaseLabel,
			CaseId.IsEmpty() ? TEXT("n/a") : *CaseId
		);
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution case preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.OwnedCaseSummaryLine = TEXT("Owned case target: n/a");
		Surface.CanonicalStateSummaryLine = TEXT("Canonical state ref: n/a");
		Surface.CurrentSelectionPreviewLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution case preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request envelope preview: %s"),
			OptionLaunchRequestEnvelopePreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestEnvelopePreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestEnvelopePreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestEnvelopePreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionCasePreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
			{
				FHyperTwistTrainingCase MatchingCase;
				if (UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
						RunState.ActiveDeck,
						SelectorId,
						PreviewEntry.OptionId,
						MatchingCase))
				{
					const FString CaseLabel = MatchingCase.PromptLabel.IsEmpty()
						? MatchingCase.CaseId
						: MatchingCase.PromptLabel;
					Entry.PreviewCaseId = MatchingCase.CaseId;
					Entry.PreviewCanonicalStateRef = MatchingCase.CanonicalStateRef;
					Entry.OwnedCaseTargetLine =
						BuildCoveredCaseTargetLine(MatchingCase.CaseId, CaseLabel);
					Entry.CanonicalStateRefLine = MatchingCase.CanonicalStateRef.IsEmpty()
						? TEXT("Canonical state ref: none on the covered owned case.")
						: FString::Printf(
							TEXT("Canonical state ref: %s"),
							*MatchingCase.CanonicalStateRef
						);
					Entry.PreviewStabilityLine =
						TEXT("Preview stability: exact direct owned-case target from imported option coverage.");
					Entry.bHasExactOwnedCaseTarget = !Entry.PreviewCaseId.IsEmpty();
					Entry.bHasExactCanonicalStateRef = !Entry.PreviewCanonicalStateRef.IsEmpty();
					Entry.bMissingCanonicalStateRef =
						Entry.bHasExactOwnedCaseTarget && !Entry.bHasExactCanonicalStateRef;
					Entry.bCanPreview = true;
					++Surface.DirectOwnedCaseTargetOptionCount;
					if (Entry.bHasExactCanonicalStateRef)
					{
						++Surface.ExactCanonicalStateRefOptionCount;
					}
					else if (Entry.bHasExactOwnedCaseTarget)
					{
						++Surface.MissingCanonicalStateRefOptionCount;
					}
				}
				else
				{
					Entry.OwnedCaseTargetLine =
						TEXT("Owned case target: covered owned case could not be resolved from the active deck.");
					Entry.CanonicalStateRefLine = TEXT("Canonical state ref: unavailable");
					Entry.PreviewStabilityLine =
						TEXT("Preview stability: unavailable because the covered case could not be re-resolved from the active deck.");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
				}
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
				Entry.PreviewCaseId = BuildGeneratedModeCaseId(
					PreviewEntry.HypotheticalDeckId,
					PreviewEntry.CurrentStoredRequestId
				);
				Entry.PreviewCanonicalStateRef = BuildGeneratedModeCanonicalStateRef(
					PreviewEntry.HypotheticalSurfaceId,
					PreviewEntry.HypotheticalRuntimeModeId,
					PreviewEntry.CurrentStoredRequestId
				);
				Entry.OwnedCaseTargetLine = Entry.PreviewCaseId.IsEmpty()
					? TEXT("Owned case target on execute: unavailable")
					: FString::Printf(
						TEXT("Owned case target on execute: %s"),
						*Entry.PreviewCaseId
					);
				Entry.CanonicalStateRefLine = Entry.PreviewCanonicalStateRef.IsEmpty()
					? TEXT("Canonical state ref on execute: unavailable")
					: FString::Printf(
						TEXT("Canonical state ref on execute: %s"),
						*Entry.PreviewCanonicalStateRef
					);
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: exact while execute reuses the current stored request envelope.");
				Entry.bHasExactOwnedCaseTarget = !Entry.PreviewCaseId.IsEmpty();
				Entry.bHasExactCanonicalStateRef = !Entry.PreviewCanonicalStateRef.IsEmpty();
				Entry.bMissingCanonicalStateRef =
					Entry.bHasExactOwnedCaseTarget && !Entry.bHasExactCanonicalStateRef;
				Entry.bCanPreview = true;
				++Surface.StoredRequestExactTargetOptionCount;
				if (Entry.bHasExactCanonicalStateRef)
				{
					++Surface.ExactCanonicalStateRefOptionCount;
				}
				else if (Entry.bHasExactOwnedCaseTarget)
				{
					++Surface.MissingCanonicalStateRefOptionCount;
				}
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				Entry.PreviewCaseIdTemplate =
					BuildGeneratedModeCaseIdTemplate(PreviewEntry.HypotheticalDeckId);
				Entry.PreviewCanonicalStateRefTemplate =
					BuildGeneratedModeCanonicalStateRefTemplate(
						PreviewEntry.HypotheticalSurfaceId,
						PreviewEntry.HypotheticalRuntimeModeId
					);
				Entry.OwnedCaseTargetLine = FString::Printf(
					TEXT("Owned case target after request refresh: %s"),
					Entry.PreviewCaseIdTemplate.IsEmpty()
						? TEXT("unavailable")
						: *Entry.PreviewCaseIdTemplate
				);
				Entry.CanonicalStateRefLine = FString::Printf(
					TEXT("Canonical state ref after request refresh: %s"),
					Entry.PreviewCanonicalStateRefTemplate.IsEmpty()
						? TEXT("unavailable")
						: *Entry.PreviewCanonicalStateRefTemplate
				);
				Entry.PreviewStabilityLine = PreviewEntry.bWouldPersistFirstStoredRequestEnvelope
					? TEXT("Preview stability: template only until execute persists the first stored request envelope.")
					: (PreviewEntry.bWouldRefreshStoredRequestEnvelope
						? TEXT("Preview stability: template only until execute refreshes the stored request envelope.")
						: TEXT("Preview stability: template only until execute replaces the stored request envelope."));
				Entry.bHasOwnedCaseTargetTemplate = !Entry.PreviewCaseIdTemplate.IsEmpty();
				Entry.bHasCanonicalStateRefTemplate =
					!Entry.PreviewCanonicalStateRefTemplate.IsEmpty();
				Entry.bCanPreview = true;
				++Surface.RefreshTemplateTargetOptionCount;
				if (Entry.bHasCanonicalStateRefTemplate)
				{
					++Surface.TemplateCanonicalStateRefOptionCount;
				}
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.OwnedCaseTargetLine =
					TEXT("Owned case target: blocked until every required selector is resolved.");
				Entry.CanonicalStateRefLine =
					TEXT("Canonical state ref: blocked until every required selector is resolved.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.OwnedCaseTargetLine =
					TEXT("Owned case target: blocked until a structurally valid launch payload can be derived.");
				Entry.CanonicalStateRefLine =
					TEXT("Canonical state ref: blocked until a structurally valid launch payload can be derived.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.OwnedCaseTargetLine = TEXT("Owned case target: unavailable");
				Entry.CanonicalStateRefLine = TEXT("Canonical state ref: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*PreviewEntry.DetailLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactOwnedCaseTarget =
				Entry.bHasExactOwnedCaseTarget;
			Surface.bCurrentSelectionHasOwnedCaseTargetTemplate =
				Entry.bHasOwnedCaseTargetTemplate;
			Surface.bCurrentSelectionHasExactCanonicalStateRef =
				Entry.bHasExactCanonicalStateRef;
			Surface.bCurrentSelectionHasCanonicalStateRefTemplate =
				Entry.bHasCanonicalStateRefTemplate;
			Surface.bCurrentSelectionMissingCanonicalStateRef =
				Entry.bMissingCanonicalStateRef;
			Surface.CurrentSelectionPreviewLine = FString::Printf(
				TEXT("%s | %s"),
				*Entry.OwnedCaseTargetLine,
				*Entry.CanonicalStateRefLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionCasePreviewOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectOwnedCaseTargets = Surface.DirectOwnedCaseTargetOptionCount > 0;
	Surface.bHasStoredRequestExactTargets =
		Surface.StoredRequestExactTargetOptionCount > 0;
	Surface.bHasRefreshTemplateTargets = Surface.RefreshTemplateTargetOptionCount > 0;
	Surface.bHasBlockedTargets = Surface.BlockedOptionCount > 0;

	Surface.OwnedCaseSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Owned case target: %d direct-case | %d stored-request exact | %d refresh-template | %d blocked | %d unavailable"),
			Surface.DirectOwnedCaseTargetOptionCount,
			Surface.StoredRequestExactTargetOptionCount,
			Surface.RefreshTemplateTargetOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Owned case target: no imported options");
	Surface.CanonicalStateSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Canonical state ref: %d exact | %d template | %d missing | %d blocked | %d unavailable"),
			Surface.ExactCanonicalStateRefOptionCount,
			Surface.TemplateCanonicalStateRefOptionCount,
			Surface.MissingCanonicalStateRefOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Canonical state ref: no imported options");

	if (Surface.CurrentSelectionPreviewLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionPreviewLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionPreviewLine =
				TEXT("Current selection has no additional owned-execution case preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionPreviewLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionPreviewLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution case preview exposes %d direct-case option%s, %d stored-request exact option%s, %d refresh-template option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectOwnedCaseTargetOptionCount,
			Surface.DirectOwnedCaseTargetOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.StoredRequestExactTargetOptionCount,
			Surface.StoredRequestExactTargetOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.RefreshTemplateTargetOptionCount,
			Surface.RefreshTemplateTargetOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution case preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution case preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request envelope preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestEnvelopePreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestEnvelopePreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionPromptPreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionOwnedExecutionPromptPreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
		OptionLaunchRequestPreviewSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionPromptPreviewSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Owned-Execution Prompt Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Prompt Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Prompt Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution prompt preview requires a selector id from the active selector roster.");
		Surface.PromptLabelSummaryLine = TEXT("Prompt label: n/a");
		Surface.PromptKindSummaryLine = TEXT("Prompt kind: n/a");
		Surface.CurrentSelectionPromptLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingCase* SeedCase = RunState.ActiveDeck.Cases.FindByPredicate(
		[](const FHyperTwistTrainingCase& Candidate)
		{
			return Candidate.IsStructurallyValid();
		}
	);

	const auto DescribePromptKind = [](const EHyperTwistTrainingPromptKind PromptKind) -> FString
	{
		switch (PromptKind)
		{
			case EHyperTwistTrainingPromptKind::Algorithm:
				return TEXT("Algorithm");
			case EHyperTwistTrainingPromptKind::State:
				return TEXT("State");
			case EHyperTwistTrainingPromptKind::Recognition:
				return TEXT("Recognition");
			case EHyperTwistTrainingPromptKind::Memo:
				return TEXT("Memo");
			case EHyperTwistTrainingPromptKind::Sequence:
				return TEXT("Sequence");
			default:
				return TEXT("Unknown");
		}
	};

	const auto ResolveGeneratedModePromptKind = [](
		const FHyperTwistTrainingCase& InSeedCase,
		const FString& RuntimeModeId,
		const FString& GeneratorType
	) -> EHyperTwistTrainingPromptKind
	{
		const FString NormalizedRuntimeModeId = RuntimeModeId.ToLower();
		const FString NormalizedGeneratorType = GeneratorType.ToLower();
		if (NormalizedRuntimeModeId.Contains(TEXT("recognition"))
			|| NormalizedGeneratorType.Contains(TEXT("recognition")))
		{
			return EHyperTwistTrainingPromptKind::Recognition;
		}
		if (NormalizedRuntimeModeId.Contains(TEXT("state"))
			|| NormalizedGeneratorType.Contains(TEXT("state"))
			|| NormalizedRuntimeModeId.Contains(TEXT("scramble"))
			|| NormalizedGeneratorType.Contains(TEXT("scramble")))
		{
			return EHyperTwistTrainingPromptKind::State;
		}
		if ((InSeedCase.PromptKind == EHyperTwistTrainingPromptKind::Algorithm
				|| InSeedCase.PromptKind == EHyperTwistTrainingPromptKind::Sequence
				|| InSeedCase.PromptKind == EHyperTwistTrainingPromptKind::Memo)
			&& InSeedCase.CanonicalNotation.IsEmpty())
		{
			return EHyperTwistTrainingPromptKind::State;
		}

		return InSeedCase.PromptKind;
	};

	const auto BuildSelectorSummaryFromPreviewEntry =
		[](const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
			PreviewEntry) -> FString
	{
		if (PreviewEntry.SelectorChoiceEntries.Num() <= 0)
		{
			return TEXT("no selector choices");
		}

		TArray<FString> SelectorParts;
		for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestSelectorChoiceEntrySurface&
			ChoiceEntry : PreviewEntry.SelectorChoiceEntries)
		{
			const FString Label = ChoiceEntry.SelectorLabel.IsEmpty()
				? (ChoiceEntry.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : ChoiceEntry.SelectorId)
				: ChoiceEntry.SelectorLabel;
			const FString Value = ChoiceEntry.DisplayValue.IsEmpty()
				? (ChoiceEntry.SelectedValue.IsEmpty() ? FString(TEXT("n/a")) : ChoiceEntry.SelectedValue)
				: ChoiceEntry.DisplayValue;
			SelectorParts.Add(FString::Printf(TEXT("%s=%s"), *Label, *Value));
		}

		return SelectorParts.Num() > 0 ? FString::Join(SelectorParts, TEXT(" | "))
			: TEXT("no selector choices");
	};

	const auto BuildGeneratedPromptLabel = [](
		const FString& PromptBaseLabel,
		const FString& SelectorSummary
	) -> FString
	{
		return !PromptBaseLabel.IsEmpty() && !SelectorSummary.IsEmpty()
			? FString::Printf(TEXT("%s | %s"), *PromptBaseLabel, *SelectorSummary)
			: PromptBaseLabel;
	};

	const auto BuildPromptLabelLine = [](const FString& PromptLabel) -> FString
	{
		return PromptLabel.IsEmpty()
			? TEXT("Prompt label: none")
			: FString::Printf(TEXT("Prompt label: %s"), *PromptLabel);
	};

	const auto BuildPromptKindLine = [&DescribePromptKind](
		const EHyperTwistTrainingPromptKind PromptKind
	) -> FString
	{
		return FString::Printf(
			TEXT("Prompt kind: %s"),
			*DescribePromptKind(PromptKind)
		);
	};

	const auto IncrementPromptKindCount = [&Surface](
		const EHyperTwistTrainingPromptKind PromptKind
	)
	{
		switch (PromptKind)
		{
			case EHyperTwistTrainingPromptKind::Algorithm:
				++Surface.AlgorithmPromptKindOptionCount;
				break;
			case EHyperTwistTrainingPromptKind::State:
				++Surface.StatePromptKindOptionCount;
				break;
			case EHyperTwistTrainingPromptKind::Recognition:
				++Surface.RecognitionPromptKindOptionCount;
				break;
			case EHyperTwistTrainingPromptKind::Memo:
				++Surface.MemoPromptKindOptionCount;
				break;
			case EHyperTwistTrainingPromptKind::Sequence:
				++Surface.SequencePromptKindOptionCount;
				break;
			default:
				break;
		}
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution prompt preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.PromptLabelSummaryLine = TEXT("Prompt label: n/a");
		Surface.PromptKindSummaryLine = TEXT("Prompt kind: n/a");
		Surface.CurrentSelectionPromptLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution prompt preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionPromptPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
			{
				FHyperTwistTrainingCase MatchingCase;
				if (UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
						RunState.ActiveDeck,
						SelectorId,
						PreviewEntry.OptionId,
						MatchingCase))
				{
					Entry.PreviewPromptLabel = MatchingCase.PromptLabel.IsEmpty()
						? MatchingCase.CaseId
						: MatchingCase.PromptLabel;
					Entry.PreviewPromptKind = MatchingCase.PromptKind;
					Entry.PreviewPromptKindLabel = DescribePromptKind(MatchingCase.PromptKind);
					Entry.PromptLabelLine = BuildPromptLabelLine(Entry.PreviewPromptLabel);
					Entry.PromptKindLine = BuildPromptKindLine(MatchingCase.PromptKind);
					Entry.PromptSourceLine =
						TEXT("Prompt source: exact direct covered-case prompt presentation.");
					Entry.PreviewStabilityLine =
						TEXT("Preview stability: exact direct owned-case prompt preview from imported option coverage.");
					Entry.bHasExactPromptPreview = true;
					Entry.bHasPromptLabelText = !Entry.PreviewPromptLabel.IsEmpty();
					Entry.bCanPreview = true;
					++Surface.DirectPromptPreviewOptionCount;
					IncrementPromptKindCount(MatchingCase.PromptKind);
				}
				else
				{
					Entry.PromptLabelLine = TEXT("Prompt label: unavailable");
					Entry.PromptKindLine = TEXT("Prompt kind: unavailable");
					Entry.PromptSourceLine =
						TEXT("Prompt source: unavailable because the covered case could not be re-resolved from the active deck.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
				}
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				if (SeedCase == nullptr)
				{
					Entry.PromptLabelLine = TEXT("Prompt label: unavailable");
					Entry.PromptKindLine = TEXT("Prompt kind: unavailable");
					Entry.PromptSourceLine =
						TEXT("Prompt source: unavailable because the active generated-mode surface has no structurally valid seed case.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
					break;
				}

				Entry.PreviewPromptKind = ResolveGeneratedModePromptKind(
					*SeedCase,
					PreviewEntry.HypotheticalRuntimeModeId,
					PreviewEntry.HypotheticalGeneratorType
				);
				Entry.PreviewPromptKindLabel = DescribePromptKind(Entry.PreviewPromptKind);
				Entry.PreviewPromptLabel = BuildGeneratedPromptLabel(
					!PreviewEntry.HypotheticalSurfaceLabel.IsEmpty()
						? PreviewEntry.HypotheticalSurfaceLabel
						: RunState.ActiveDeck.Title,
					BuildSelectorSummaryFromPreviewEntry(PreviewEntry)
				);
				Entry.PromptLabelLine = BuildPromptLabelLine(Entry.PreviewPromptLabel);
				Entry.PromptKindLine = BuildPromptKindLine(Entry.PreviewPromptKind);
				Entry.PromptSourceLine =
					TEXT("Prompt source: exact generated-mode owned execution prompt composition from the active surface and selector payload.");
				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
					? TEXT("Preview stability: exact while execute reuses the current stored request.")
					: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bHasExactPromptPreview = true;
				Entry.bHasPromptLabelText = !Entry.PreviewPromptLabel.IsEmpty();
				Entry.bCanPreview = true;
				++Surface.GeneratedPromptPreviewOptionCount;
				IncrementPromptKindCount(Entry.PreviewPromptKind);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.PromptLabelLine =
					TEXT("Prompt label: blocked until every required selector is resolved.");
				Entry.PromptKindLine =
					TEXT("Prompt kind: blocked until every required selector is resolved.");
				Entry.PromptSourceLine =
					TEXT("Prompt source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.PromptLabelLine =
					TEXT("Prompt label: blocked until a structurally valid launch payload can be derived.");
				Entry.PromptKindLine =
					TEXT("Prompt kind: blocked until a structurally valid launch payload can be derived.");
				Entry.PromptSourceLine =
					TEXT("Prompt source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.PromptLabelLine = TEXT("Prompt label: unavailable");
				Entry.PromptKindLine = TEXT("Prompt kind: unavailable");
				Entry.PromptSourceLine = TEXT("Prompt source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*PreviewEntry.DetailLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactPromptPreview = Entry.bHasExactPromptPreview;
			Surface.bCurrentSelectionHasPromptLabelText = Entry.bHasPromptLabelText;
			Surface.CurrentSelectionPromptLine = FString::Printf(
				TEXT("%s | %s"),
				*Entry.PromptLabelLine,
				*Entry.PromptKindLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionPromptPreviewOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectPromptPreviewOptions = Surface.DirectPromptPreviewOptionCount > 0;
	Surface.bHasGeneratedPromptPreviewOptions =
		Surface.GeneratedPromptPreviewOptionCount > 0;
	Surface.bHasBlockedPromptPreviewOptions = Surface.BlockedOptionCount > 0;

	Surface.PromptLabelSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Prompt label: %d direct-case exact | %d generated exact | %d blocked | %d unavailable"),
			Surface.DirectPromptPreviewOptionCount,
			Surface.GeneratedPromptPreviewOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Prompt label: no imported options");
	Surface.PromptKindSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Prompt kind: %d algorithm | %d state | %d recognition | %d memo | %d sequence"),
			Surface.AlgorithmPromptKindOptionCount,
			Surface.StatePromptKindOptionCount,
			Surface.RecognitionPromptKindOptionCount,
			Surface.MemoPromptKindOptionCount,
			Surface.SequencePromptKindOptionCount
		)
		: TEXT("Prompt kind: no imported options");

	if (Surface.CurrentSelectionPromptLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionPromptLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionPromptLine =
				TEXT("Current selection has no additional owned-execution prompt preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionPromptLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionPromptLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution prompt preview exposes %d direct-case exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectPromptPreviewOptionCount,
			Surface.DirectPromptPreviewOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedPromptPreviewOptionCount,
			Surface.GeneratedPromptPreviewOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution prompt preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution prompt preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryPreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryPreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
		OptionLaunchRequestPreviewSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryPreviewSurface Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline = TEXT("Generated Mode Selector Option Owned-Execution Delivery Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Delivery Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Delivery Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution delivery preview requires a selector id from the active selector roster.");
		Surface.DeliveryModeSummaryLine = TEXT("Delivery mode: n/a");
		Surface.RevealPostureSummaryLine = TEXT("Reveal posture: n/a");
		Surface.TimeTargetSummaryLine = TEXT("Time target: n/a");
		Surface.CurrentSelectionExecutionLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingCase* SeedCase = RunState.ActiveDeck.Cases.FindByPredicate(
		[](const FHyperTwistTrainingCase& Candidate)
		{
			return Candidate.IsStructurallyValid();
		}
	);

	const auto DescribeDeliveryMode = [](
		const EHyperTwistTrainingDeliveryMode DeliveryMode
	) -> FString
	{
		switch (DeliveryMode)
		{
			case EHyperTwistTrainingDeliveryMode::Timer:
				return TEXT("Timer");
			case EHyperTwistTrainingDeliveryMode::VirtualCube:
				return TEXT("Virtual Cube");
			case EHyperTwistTrainingDeliveryMode::SmartDevice:
				return TEXT("Smart Device");
			case EHyperTwistTrainingDeliveryMode::RecognitionAssisted:
				return TEXT("Recognition Assisted");
			case EHyperTwistTrainingDeliveryMode::CoachReviewed:
				return TEXT("Coach Reviewed");
			default:
				return TEXT("Unknown");
		}
	};

	const auto BuildDeliveryModeLine = [&DescribeDeliveryMode](
		const EHyperTwistTrainingDeliveryMode DeliveryMode
	) -> FString
	{
		return FString::Printf(
			TEXT("Delivery mode on execute: %s"),
			*DescribeDeliveryMode(DeliveryMode)
		);
	};

	const auto BuildTimeTargetLine = [](
		const int32 TimeTargetMs
	) -> FString
	{
		return TimeTargetMs > 0
			? FString::Printf(TEXT("Time target on execute: %d ms"), TimeTargetMs)
			: TEXT("Time target on execute: none");
	};

	const auto IncrementDeliveryModeCount = [&Surface](
		const EHyperTwistTrainingDeliveryMode DeliveryMode
	)
	{
		switch (DeliveryMode)
		{
			case EHyperTwistTrainingDeliveryMode::Timer:
				++Surface.TimerDeliveryOptionCount;
				break;
			case EHyperTwistTrainingDeliveryMode::VirtualCube:
				++Surface.VirtualCubeDeliveryOptionCount;
				break;
			case EHyperTwistTrainingDeliveryMode::SmartDevice:
				++Surface.SmartDeviceDeliveryOptionCount;
				break;
			case EHyperTwistTrainingDeliveryMode::RecognitionAssisted:
				++Surface.RecognitionAssistedDeliveryOptionCount;
				break;
			case EHyperTwistTrainingDeliveryMode::CoachReviewed:
				++Surface.CoachReviewedDeliveryOptionCount;
				break;
			default:
				break;
		}
	};

	const auto IncrementRevealCounts = [&Surface](
		const bool bSupportsAlgorithmRevealOnExecute,
		const bool bRevealConfiguredByDeckPolicy,
		const bool bHasRevealNotation
	)
	{
		if (bSupportsAlgorithmRevealOnExecute)
		{
			++Surface.RevealEnabledOptionCount;
		}
		else if (bRevealConfiguredByDeckPolicy && !bHasRevealNotation)
		{
			++Surface.MissingRevealNotationOptionCount;
		}
		else
		{
			++Surface.RevealDisabledOptionCount;
		}
	};

	const auto IncrementTimeTargetCounts = [&Surface](const bool bHasTimeTarget)
	{
		if (bHasTimeTarget)
		{
			++Surface.TimedOptionCount;
		}
		else
		{
			++Surface.UntargetedOptionCount;
		}
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution delivery preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.DeliveryModeSummaryLine = TEXT("Delivery mode: n/a");
		Surface.RevealPostureSummaryLine = TEXT("Reveal posture: n/a");
		Surface.TimeTargetSummaryLine = TEXT("Time target: n/a");
		Surface.CurrentSelectionExecutionLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution delivery preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionDeliveryPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
			{
				FHyperTwistTrainingCase MatchingCase;
				if (UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
						RunState.ActiveDeck,
						SelectorId,
						PreviewEntry.OptionId,
						MatchingCase))
				{
					Entry.PreviewDeliveryMode = RunState.Session.Mode;
					Entry.PreviewDeliveryModeLabel = DescribeDeliveryMode(Entry.PreviewDeliveryMode);
					Entry.DeliveryModeLine = BuildDeliveryModeLine(Entry.PreviewDeliveryMode);
					Entry.bRevealConfiguredByDeckPolicy =
						RunState.ActiveDeck.bSupportsAlgorithmReveal;
					Entry.bHasRevealNotation = !MatchingCase.CanonicalNotation.IsEmpty();
					Entry.bSupportsAlgorithmRevealOnExecute =
						Entry.bRevealConfiguredByDeckPolicy && Entry.bHasRevealNotation;
					Entry.RevealPostureLine = !Entry.bRevealConfiguredByDeckPolicy
						? TEXT("Reveal posture on execute: disabled by the active deck reveal policy.")
						: (Entry.bHasRevealNotation
							? TEXT("Reveal posture on execute: algorithm reveal remains enabled on the covered owned case.")
							: TEXT("Reveal posture on execute: the active deck keeps reveal enabled, but the covered owned case has no canonical notation."));
					Entry.PreviewTimeTargetMs = MatchingCase.TimeTargetMs;
					Entry.bHasTimeTarget = Entry.PreviewTimeTargetMs > 0;
					Entry.TimeTargetLine = BuildTimeTargetLine(Entry.PreviewTimeTargetMs);
					Entry.DeliverySourceLine =
						TEXT("Delivery source: exact direct covered-case execution posture from the active session mode and covered case.");
					Entry.PreviewStabilityLine =
						TEXT("Preview stability: exact direct owned-case execution posture from covered-case launch.");
					Entry.bHasExactDeliveryPreview = true;
					Entry.bCanPreview = true;
					++Surface.DirectExactOptionCount;
					IncrementDeliveryModeCount(Entry.PreviewDeliveryMode);
					IncrementRevealCounts(
						Entry.bSupportsAlgorithmRevealOnExecute,
						Entry.bRevealConfiguredByDeckPolicy,
						Entry.bHasRevealNotation
					);
					IncrementTimeTargetCounts(Entry.bHasTimeTarget);
				}
				else
				{
					Entry.DeliveryModeLine = TEXT("Delivery mode on execute: unavailable");
					Entry.RevealPostureLine = TEXT("Reveal posture on execute: unavailable");
					Entry.TimeTargetLine = TEXT("Time target on execute: unavailable");
					Entry.DeliverySourceLine =
						TEXT("Delivery source: unavailable because the covered case could not be re-resolved from the active deck.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
				}
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				if (SeedCase == nullptr)
				{
					Entry.DeliveryModeLine = TEXT("Delivery mode on execute: unavailable");
					Entry.RevealPostureLine = TEXT("Reveal posture on execute: unavailable");
					Entry.TimeTargetLine = TEXT("Time target on execute: unavailable");
					Entry.DeliverySourceLine =
						TEXT("Delivery source: unavailable because the active generated-mode surface has no structurally valid seed case.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
					break;
				}

				Entry.PreviewDeliveryMode = PreviewEntry.HypotheticalDeliveryMode;
				Entry.PreviewDeliveryModeLabel = DescribeDeliveryMode(Entry.PreviewDeliveryMode);
				Entry.DeliveryModeLine = BuildDeliveryModeLine(Entry.PreviewDeliveryMode);
				Entry.bRevealConfiguredByDeckPolicy = false;
				Entry.bHasRevealNotation = false;
				Entry.bSupportsAlgorithmRevealOnExecute = false;
				Entry.RevealPostureLine =
					TEXT("Reveal posture on execute: disabled because generated owned execution clears canonical notation.");
				Entry.PreviewTimeTargetMs = SeedCase->TimeTargetMs;
				Entry.bHasTimeTarget = Entry.PreviewTimeTargetMs > 0;
				Entry.TimeTargetLine = BuildTimeTargetLine(Entry.PreviewTimeTargetMs);
				Entry.DeliverySourceLine =
					TEXT("Delivery source: exact generated-mode owned execution posture from the selector payload and execute launch config.");
				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
					? TEXT("Preview stability: exact while execute reuses the current stored request.")
					: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bHasExactDeliveryPreview = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				IncrementDeliveryModeCount(Entry.PreviewDeliveryMode);
				IncrementRevealCounts(
					Entry.bSupportsAlgorithmRevealOnExecute,
					Entry.bRevealConfiguredByDeckPolicy,
					Entry.bHasRevealNotation
				);
				IncrementTimeTargetCounts(Entry.bHasTimeTarget);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.DeliveryModeLine =
					TEXT("Delivery mode on execute: blocked until every required selector is resolved.");
				Entry.RevealPostureLine =
					TEXT("Reveal posture on execute: blocked until every required selector is resolved.");
				Entry.TimeTargetLine =
					TEXT("Time target on execute: blocked until every required selector is resolved.");
				Entry.DeliverySourceLine =
					TEXT("Delivery source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.DeliveryModeLine =
					TEXT("Delivery mode on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.RevealPostureLine =
					TEXT("Reveal posture on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.TimeTargetLine =
					TEXT("Time target on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.DeliverySourceLine =
					TEXT("Delivery source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.DeliveryModeLine = TEXT("Delivery mode on execute: unavailable");
				Entry.RevealPostureLine = TEXT("Reveal posture on execute: unavailable");
				Entry.TimeTargetLine = TEXT("Time target on execute: unavailable");
				Entry.DeliverySourceLine = TEXT("Delivery source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*PreviewEntry.DetailLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactDeliveryPreview =
				Entry.bHasExactDeliveryPreview;
			Surface.bCurrentSelectionSupportsAlgorithmRevealOnExecute =
				Entry.bSupportsAlgorithmRevealOnExecute;
			Surface.bCurrentSelectionHasRevealNotation = Entry.bHasRevealNotation;
			Surface.bCurrentSelectionHasTimeTarget = Entry.bHasTimeTarget;
			Surface.CurrentSelectionExecutionLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.DeliveryModeLine,
				*Entry.RevealPostureLine,
				*Entry.TimeTargetLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionDeliveryPreviewOptions = Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectDeliveryPreviewOptions = Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedDeliveryPreviewOptions = Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedDeliveryPreviewOptions = Surface.BlockedOptionCount > 0;

	Surface.DeliveryModeSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Delivery mode: %d timer | %d virtual-cube | %d smart-device | %d recognition-assisted | %d coach-reviewed"),
			Surface.TimerDeliveryOptionCount,
			Surface.VirtualCubeDeliveryOptionCount,
			Surface.SmartDeviceDeliveryOptionCount,
			Surface.RecognitionAssistedDeliveryOptionCount,
			Surface.CoachReviewedDeliveryOptionCount
		)
		: TEXT("Delivery mode: no imported options");
	Surface.RevealPostureSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Reveal posture: %d enabled | %d disabled | %d missing-notation | %d blocked | %d unavailable"),
			Surface.RevealEnabledOptionCount,
			Surface.RevealDisabledOptionCount,
			Surface.MissingRevealNotationOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Reveal posture: no imported options");
	Surface.TimeTargetSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Time target: %d targeted | %d untargeted | %d blocked | %d unavailable"),
			Surface.TimedOptionCount,
			Surface.UntargetedOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Time target: no imported options");

	if (Surface.CurrentSelectionExecutionLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionExecutionLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionExecutionLine =
				TEXT("Current selection has no additional owned-execution delivery preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionExecutionLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionExecutionLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution delivery preview exposes %d direct-case exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution delivery preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution delivery preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}

FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionPuzzleSubsetDifficultyPreviewSurface
UHyperTwistTrainingCoachLibrary::DeriveCoachGeneratedModeSelectorOptionOwnedExecutionPuzzleSubsetDifficultyPreviewSurface(
	const FHyperTwistTrainingRunState& RunState,
	const FString& SelectorId,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionMenuSurface& OptionMenuSurface,
	const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewSurface&
		OptionLaunchRequestPreviewSurface
)
{
	FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionPuzzleSubsetDifficultyPreviewSurface
		Surface;
	Surface.SelectorId = SelectorId;
	Surface.SelectorLabel = OptionMenuSurface.SelectorLabel;
	Surface.BindingLabel = OptionMenuSurface.BindingLabel;
	Surface.Headline =
		TEXT("Generated Mode Selector Option Owned-Execution Puzzle/Subset/Difficulty Preview");
	Surface.bHasSelector = OptionMenuSurface.bHasSelector;

	if (!SelectorId.IsEmpty())
	{
		Surface.Headline = OptionMenuSurface.SelectorLabel.IsEmpty()
			? FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Puzzle/Subset/Difficulty Preview: %s"),
				*SelectorId
			)
			: FString::Printf(
				TEXT("Generated Mode Selector Option Owned-Execution Puzzle/Subset/Difficulty Preview: %s"),
				*OptionMenuSurface.SelectorLabel
			);
	}

	if (SelectorId.IsEmpty())
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution puzzle/subset/difficulty preview requires a selector id from the active selector roster.");
		Surface.PuzzleIdSummaryLine = TEXT("Puzzle id: n/a");
		Surface.SubsetIdSummaryLine = TEXT("Subset: n/a");
		Surface.DifficultySummaryLine = TEXT("Difficulty: n/a");
		Surface.CurrentSelectionScopeLine = TEXT("Current selection: n/a");
		Surface.DetailLine = OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("Launch-request preview: n/a")
			: FString::Printf(
				TEXT("Launch-request preview: %s"),
				*OptionLaunchRequestPreviewSurface.StatusLine
			);
		return Surface;
	}

	const FHyperTwistTrainingImportedRuntimeSurface& RuntimeSurface =
		RunState.ActiveDeck.ImportedRuntimeSurface;
	const bool bHasGeneratedModeSurface = RuntimeSurface.IsStructurallyValid()
		&& RuntimeSurface.SurfaceKind.Equals(TEXT("generated-mode"), ESearchCase::IgnoreCase);
	const FHyperTwistTrainingCase* SeedCase = RunState.ActiveDeck.Cases.FindByPredicate(
		[](const FHyperTwistTrainingCase& Candidate)
		{
			return Candidate.IsStructurallyValid();
		}
	);

	const auto DescribeDifficultyBand = [](const float Difficulty) -> FString
	{
		if (Difficulty <= 0.0f)
		{
			return TEXT("Unspecified");
		}
		if (Difficulty <= 0.25f)
		{
			return TEXT("Beginner");
		}
		if (Difficulty <= 0.5f)
		{
			return TEXT("Intermediate");
		}
		if (Difficulty <= 0.75f)
		{
			return TEXT("Advanced");
		}

		return TEXT("Expert");
	};

	const auto BuildDifficultyLine = [&DescribeDifficultyBand](
		const float Difficulty
	) -> FString
	{
		return Difficulty > 0.0f
			? FString::Printf(
				TEXT("Difficulty on execute: %.2f [%s]"),
				Difficulty,
				*DescribeDifficultyBand(Difficulty)
			)
			: TEXT("Difficulty on execute: unspecified");
	};

	const auto IncrementPuzzleFamilyCounts = [&Surface](const FString& PuzzleId)
	{
		FHyperTwistPuzzleDefinitionRef RetainedHyperDefinition;
		if (UHyperTwistTrainingCatalogLibrary::TryResolveRetainedHyperPuzzleDefinition(
			PuzzleId,
			RetainedHyperDefinition
		))
		{
			++Surface.HypercubePuzzleOptionCount;
		}
		else if (PuzzleId.StartsWith(TEXT("cube/")))
		{
			++Surface.CubePuzzleOptionCount;
		}
		else if (PuzzleId.StartsWith(TEXT("hypercube/")))
		{
			++Surface.HypercubePuzzleOptionCount;
		}
		else
		{
			++Surface.OtherPuzzleOptionCount;
		}
	};

	const auto IncrementDifficultyCounts = [&Surface](const float Difficulty)
	{
		if (Difficulty <= 0.0f)
		{
			++Surface.UnspecifiedDifficultyOptionCount;
		}
		else if (Difficulty <= 0.25f)
		{
			++Surface.BeginnerDifficultyOptionCount;
		}
		else if (Difficulty <= 0.5f)
		{
			++Surface.IntermediateDifficultyOptionCount;
		}
		else if (Difficulty <= 0.75f)
		{
			++Surface.AdvancedDifficultyOptionCount;
		}
		else
		{
			++Surface.ExpertDifficultyOptionCount;
		}
	};

	if (!RunState.IsStructurallyValid() || !bHasGeneratedModeSurface)
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution puzzle/subset/difficulty preview is not currently available.")
			: OptionMenuSurface.StatusLine;
		Surface.PuzzleIdSummaryLine = TEXT("Puzzle id: n/a");
		Surface.SubsetIdSummaryLine = TEXT("Subset: n/a");
		Surface.DifficultySummaryLine = TEXT("Difficulty: n/a");
		Surface.CurrentSelectionScopeLine = OptionMenuSurface.bHasUnresolvedSelectionDetail
			? OptionMenuSurface.UnresolvedSelectionLine
			: (OptionMenuSurface.bHasSelection
				? TEXT("Current selection remains cached, but no active owned-execution scope preview is available.")
				: TEXT("Current selection: unresolved"));
		Surface.DetailLine = FString::Printf(
			TEXT("Launch-request preview: %s"),
			OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
				? TEXT("n/a")
				: *OptionLaunchRequestPreviewSurface.StatusLine
		);
		return Surface;
	}

	for (const FHyperTwistTrainingCoachGeneratedModeSelectorOptionLaunchRequestPreviewEntrySurface&
		PreviewEntry : OptionLaunchRequestPreviewSurface.OptionEntries)
	{
		FHyperTwistTrainingCoachGeneratedModeSelectorOptionOwnedExecutionPuzzleSubsetDifficultyPreviewEntrySurface
			Entry;
		Entry.OptionId = PreviewEntry.OptionId;
		Entry.Label = PreviewEntry.Label;
		Entry.OptionValue = PreviewEntry.OptionValue;
		Entry.LaunchRequestPreviewKind = PreviewEntry.LaunchRequestPreviewKind;
		Entry.bMatchesCurrentSelection = PreviewEntry.bMatchesCurrentSelection;
		Entry.bStartsOwnedCaseImmediately = PreviewEntry.bStartsOwnedCaseImmediately;

		switch (PreviewEntry.LaunchRequestPreviewKind)
		{
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				DirectOwnedCaseStart:
			{
				FHyperTwistTrainingCase MatchingCase;
				if (UHyperTwistTrainingCatalogLibrary::TryGetImportedRuntimeSelectorOptionCaseFromDeck(
						RunState.ActiveDeck,
						SelectorId,
						PreviewEntry.OptionId,
						MatchingCase))
				{
					Entry.PreviewPuzzleId = MatchingCase.PuzzleId;
					Entry.PreviewSubsetId = MatchingCase.SubsetId;
					Entry.PreviewDifficulty = MatchingCase.Difficulty;
					Entry.PreviewDifficultyBandLabel =
						DescribeDifficultyBand(Entry.PreviewDifficulty);
					Entry.bHasPuzzleId = !Entry.PreviewPuzzleId.IsEmpty();
					Entry.bHasSubsetId = !Entry.PreviewSubsetId.IsEmpty();
					Entry.bHasDifficulty = Entry.PreviewDifficulty > 0.0f;
					Entry.PuzzleIdLine = Entry.bHasPuzzleId
						? FString::Printf(
							TEXT("Puzzle id on execute: %s"),
							*Entry.PreviewPuzzleId
						)
						: TEXT("Puzzle id on execute: unavailable");
					Entry.SubsetIdLine = Entry.bHasSubsetId
						? FString::Printf(
							TEXT("Subset on execute: %s"),
							*Entry.PreviewSubsetId
						)
						: TEXT("Subset on execute: none");
					Entry.DifficultyLine = BuildDifficultyLine(Entry.PreviewDifficulty);
					Entry.ScopeSourceLine =
						TEXT("Scope source: exact direct covered-case scope from the resolved imported option case.");
					Entry.PreviewStabilityLine =
						TEXT("Preview stability: exact direct owned-case scope preview from covered-case launch.");
					Entry.bHasExactScopePreview = true;
					Entry.bCanPreview = true;
					++Surface.DirectExactOptionCount;
					if (Entry.bHasPuzzleId)
					{
						IncrementPuzzleFamilyCounts(Entry.PreviewPuzzleId);
					}
					if (Entry.bHasSubsetId)
					{
						++Surface.SubsetScopedOptionCount;
					}
					else
					{
						++Surface.UnscopedSubsetOptionCount;
					}
					IncrementDifficultyCounts(Entry.PreviewDifficulty);
				}
				else
				{
					Entry.PuzzleIdLine = TEXT("Puzzle id on execute: unavailable");
					Entry.SubsetIdLine = TEXT("Subset on execute: unavailable");
					Entry.DifficultyLine = TEXT("Difficulty on execute: unavailable");
					Entry.ScopeSourceLine =
						TEXT("Scope source: unavailable because the covered case could not be re-resolved from the active deck.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
				}
				break;
			}

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				StoredRequestReusable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				RefreshRequired:
				if (SeedCase == nullptr)
				{
					Entry.PuzzleIdLine = TEXT("Puzzle id on execute: unavailable");
					Entry.SubsetIdLine = TEXT("Subset on execute: unavailable");
					Entry.DifficultyLine = TEXT("Difficulty on execute: unavailable");
					Entry.ScopeSourceLine =
						TEXT("Scope source: unavailable because the active generated-mode surface has no structurally valid seed case.");
					Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
					Entry.bCanPreview = false;
					++Surface.UnavailableOptionCount;
					break;
				}

				Entry.PreviewPuzzleId = PreviewEntry.HypotheticalPuzzleId;
				Entry.PreviewSubsetId = RunState.ActiveDeck.SubsetId;
				Entry.PreviewDifficulty = SeedCase->Difficulty;
				Entry.PreviewDifficultyBandLabel =
					DescribeDifficultyBand(Entry.PreviewDifficulty);
				Entry.bHasPuzzleId = !Entry.PreviewPuzzleId.IsEmpty();
				Entry.bHasSubsetId = !Entry.PreviewSubsetId.IsEmpty();
				Entry.bHasDifficulty = Entry.PreviewDifficulty > 0.0f;
				Entry.PuzzleIdLine = Entry.bHasPuzzleId
					? FString::Printf(
						TEXT("Puzzle id on execute: %s"),
						*Entry.PreviewPuzzleId
					)
					: TEXT("Puzzle id on execute: unavailable");
				Entry.SubsetIdLine = Entry.bHasSubsetId
					? FString::Printf(
						TEXT("Subset on execute: %s"),
						*Entry.PreviewSubsetId
					)
					: TEXT("Subset on execute: none");
				Entry.DifficultyLine = BuildDifficultyLine(Entry.PreviewDifficulty);
				Entry.ScopeSourceLine =
					TEXT("Scope source: exact generated owned execution scope from the hypothetical launch-config puzzle id, active deck subset, and seed-case difficulty.");
				Entry.PreviewStabilityLine =
					PreviewEntry.LaunchRequestPreviewKind
						== EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
							StoredRequestReusable
					? TEXT("Preview stability: exact while execute reuses the current stored request.")
					: TEXT("Preview stability: exact even though execute still needs launch-request refresh.");
				Entry.bHasExactScopePreview = true;
				Entry.bCanPreview = true;
				++Surface.GeneratedExactOptionCount;
				if (Entry.bHasPuzzleId)
				{
					IncrementPuzzleFamilyCounts(Entry.PreviewPuzzleId);
				}
				if (Entry.bHasSubsetId)
				{
					++Surface.SubsetScopedOptionCount;
				}
				else
				{
					++Surface.UnscopedSubsetOptionCount;
				}
				IncrementDifficultyCounts(Entry.PreviewDifficulty);
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				UnresolvedAfterChoice:
				Entry.PuzzleIdLine =
					TEXT("Puzzle id on execute: blocked until every required selector is resolved.");
				Entry.SubsetIdLine =
					TEXT("Subset on execute: blocked until every required selector is resolved.");
				Entry.DifficultyLine =
					TEXT("Difficulty on execute: blocked until every required selector is resolved.");
				Entry.ScopeSourceLine =
					TEXT("Scope source: blocked while selector coverage remains incomplete.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while selector coverage remains incomplete.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::
				PayloadUnavailable:
				Entry.PuzzleIdLine =
					TEXT("Puzzle id on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.SubsetIdLine =
					TEXT("Subset on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.DifficultyLine =
					TEXT("Difficulty on execute: blocked until a structurally valid launch payload can be derived.");
				Entry.ScopeSourceLine =
					TEXT("Scope source: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.PreviewStabilityLine =
					TEXT("Preview stability: blocked while the hypothetical generated-mode payload remains structurally invalid.");
				Entry.bPreviewBlocked = true;
				Entry.bCanPreview = true;
				++Surface.BlockedOptionCount;
				break;

			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::Unavailable:
			case EHyperTwistTrainingCoachGeneratedModeOptionLaunchRequestPreviewKind::None:
			default:
				Entry.PuzzleIdLine = TEXT("Puzzle id on execute: unavailable");
				Entry.SubsetIdLine = TEXT("Subset on execute: unavailable");
				Entry.DifficultyLine = TEXT("Difficulty on execute: unavailable");
				Entry.ScopeSourceLine = TEXT("Scope source: unavailable");
				Entry.PreviewStabilityLine = TEXT("Preview stability: unavailable");
				Entry.bCanPreview = false;
				++Surface.UnavailableOptionCount;
				break;
		}

		Entry.DetailLine = PreviewEntry.DetailLine.IsEmpty()
			? Entry.PreviewStabilityLine
			: FString::Printf(
				TEXT("%s | %s"),
				*Entry.PreviewStabilityLine,
				*PreviewEntry.DetailLine
			);

		if (Entry.bMatchesCurrentSelection)
		{
			Surface.bCurrentSelectionHasExactScopePreview = Entry.bHasExactScopePreview;
			Surface.bCurrentSelectionHasPuzzleId = Entry.bHasPuzzleId;
			Surface.bCurrentSelectionHasSubsetId = Entry.bHasSubsetId;
			Surface.bCurrentSelectionHasDifficulty = Entry.bHasDifficulty;
			Surface.CurrentSelectionScopeLine = FString::Printf(
				TEXT("%s | %s | %s"),
				*Entry.PuzzleIdLine,
				*Entry.SubsetIdLine,
				*Entry.DifficultyLine
			);
		}

		Surface.OptionEntries.Add(MoveTemp(Entry));
	}

	Surface.bHasOwnedExecutionPuzzleSubsetDifficultyPreviewOptions =
		Surface.OptionEntries.Num() > 0;
	Surface.bHasDirectScopePreviewOptions = Surface.DirectExactOptionCount > 0;
	Surface.bHasGeneratedScopePreviewOptions = Surface.GeneratedExactOptionCount > 0;
	Surface.bHasBlockedScopePreviewOptions = Surface.BlockedOptionCount > 0;

	Surface.PuzzleIdSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Puzzle id: %d cube | %d hypercube | %d other | %d blocked | %d unavailable"),
			Surface.CubePuzzleOptionCount,
			Surface.HypercubePuzzleOptionCount,
			Surface.OtherPuzzleOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Puzzle id: no imported options");
	Surface.SubsetIdSummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Subset: %d scoped | %d unscoped | %d blocked | %d unavailable"),
			Surface.SubsetScopedOptionCount,
			Surface.UnscopedSubsetOptionCount,
			Surface.BlockedOptionCount,
			Surface.UnavailableOptionCount
		)
		: TEXT("Subset: no imported options");
	Surface.DifficultySummaryLine = Surface.OptionEntries.Num() > 0
		? FString::Printf(
			TEXT("Difficulty: %d beginner | %d intermediate | %d advanced | %d expert | %d unspecified"),
			Surface.BeginnerDifficultyOptionCount,
			Surface.IntermediateDifficultyOptionCount,
			Surface.AdvancedDifficultyOptionCount,
			Surface.ExpertDifficultyOptionCount,
			Surface.UnspecifiedDifficultyOptionCount
		)
		: TEXT("Difficulty: no imported options");

	if (Surface.CurrentSelectionScopeLine.IsEmpty())
	{
		if (OptionMenuSurface.bHasUnresolvedSelectionDetail)
		{
			Surface.CurrentSelectionScopeLine = OptionMenuSurface.UnresolvedSelectionLine;
		}
		else if (OptionMenuSurface.bHasSelection)
		{
			Surface.CurrentSelectionScopeLine =
				TEXT("Current selection has no additional owned-execution scope preview.");
		}
		else if (OptionMenuSurface.bHasSelector)
		{
			Surface.CurrentSelectionScopeLine = TEXT("Current selection: unresolved");
		}
		else
		{
			Surface.CurrentSelectionScopeLine = TEXT("Current selection: n/a");
		}
	}

	if (OptionMenuSurface.bHasSelector && Surface.OptionEntries.Num() > 0)
	{
		Surface.StatusLine = FString::Printf(
			TEXT("Generated-mode selector option owned-execution puzzle/subset/difficulty preview exposes %d direct-case exact option%s, %d generated exact option%s, %d blocked option%s, and %d unavailable option%s."),
			Surface.DirectExactOptionCount,
			Surface.DirectExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.GeneratedExactOptionCount,
			Surface.GeneratedExactOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.BlockedOptionCount,
			Surface.BlockedOptionCount == 1 ? TEXT("") : TEXT("s"),
			Surface.UnavailableOptionCount,
			Surface.UnavailableOptionCount == 1 ? TEXT("") : TEXT("s")
		);
	}
	else if (OptionMenuSurface.bHasSelector)
	{
		Surface.StatusLine =
			TEXT("Generated-mode selector option owned-execution puzzle/subset/difficulty preview is active, but this selector does not expose imported options.");
	}
	else
	{
		Surface.StatusLine = OptionMenuSurface.StatusLine.IsEmpty()
			? TEXT("Generated-mode selector option owned-execution puzzle/subset/difficulty preview is not currently available.")
			: OptionMenuSurface.StatusLine;
	}

	const FString SelectorSummary = Surface.SelectorLabel.IsEmpty()
		? (Surface.SelectorId.IsEmpty() ? FString(TEXT("n/a")) : Surface.SelectorId)
		: Surface.SelectorLabel;
	const FString BindingSummary = Surface.BindingLabel.IsEmpty()
		? FString(TEXT("n/a"))
		: Surface.BindingLabel;
	Surface.DetailLine = FString::Printf(
		TEXT("Launch-request preview: %s | Selector: %s | Binding: %s"),
		OptionLaunchRequestPreviewSurface.StatusLine.IsEmpty()
			? TEXT("n/a")
			: *OptionLaunchRequestPreviewSurface.StatusLine,
		*SelectorSummary,
		*BindingSummary
	);

	return Surface;
}
