#include "HyperTwistBootstrap/HyperTwistContractLibrary.h"

#include "HyperTwistMemory/HyperTwistMemoryCoreLibrary.h"
#include "HyperTwistSkills/HyperTwistSkillCoreLibrary.h"
#include "HyperTwistRecognition/HyperTwistRecognitionReplayLibrary.h"
#include "HyperTwistReplay/HyperTwistReplayReviewLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingCatalogLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingCoachLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingMediaExportLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingRepositoryLibrary.h"
#include "HyperTwistTraining/HyperTwistTrainingSharedAssetLibrary.h"
#include "JsonObjectConverter.h"

namespace HyperTwistContractLibraryInternal
{
	FHyperTwistVisionFontReviewProfile MakeDefaultQbrFontReviewProfile(const FString& ProfileId);
	TArray<FHyperTwistVisionFontReviewDescriptor> MakeQbrSupportedFontReviews();
	TArray<FHyperTwistVisionLocaleOption> MakeQbrSupportedVisionLocales();
	FHyperTwistVisionLocaleOption ResolveVisionLocaleOption(
		const TArray<FHyperTwistVisionLocaleOption>& SupportedLocales,
		const FString& PreferredLocaleCode
	);

	template <typename TStruct>
	FString SerializeStructToJson(const TStruct& Value)
	{
		FString Json;
		FJsonObjectConverter::UStructToJsonObjectString(TStruct::StaticStruct(), &Value, Json, 0, 0);
		return Json;
	}

	template <typename TStruct>
	bool DeserializeStructFromJson(const FString& Json, TStruct& OutValue)
	{
		return FJsonObjectConverter::JsonObjectStringToUStruct(Json, &OutValue, 0, 0);
	}

	FHyperTwistSkillControlProfile MakeSampleSkillControlProfile(const bool bMasterEnabled)
	{
		FHyperTwistSkillControlProfile ControlProfile;
		ControlProfile.ProfileId = bMasterEnabled
			? TEXT("skill-controls/default")
			: TEXT("skill-controls/all-skills-off");
		ControlProfile.DisplayLabel = bMasterEnabled
			? TEXT("Default Skill Controls")
			: TEXT("All Skills Off");
		ControlProfile.bMasterEnabled = bMasterEnabled;
		ControlProfile.bDurableSettingsExposed = true;
		ControlProfile.bImmediateMenuControlExposed = true;
		ControlProfile.Summary = bMasterEnabled
			? TEXT("Default first-party skill control profile.")
			: TEXT("Control profile proving the core product remains valid with all skills off.");
		return ControlProfile;
	}

	FHyperTwistSkillControlProfile MakeSampleSkillAuditControlProfile()
	{
		FHyperTwistSkillControlProfile ControlProfile = MakeSampleSkillControlProfile(true);
		ControlProfile.ProfileId = TEXT("skill-controls/audit-sample");
		ControlProfile.DisplayLabel = TEXT("Audit Sample Skill Controls");
		ControlProfile.Overrides = {
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/review-architecture");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/memory-resume-briefing");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/resume-session");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/search-history");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/recall-memory");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/generate-compact-view");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/capture-session-template");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/capture-follow-up-routine");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/extract-docs");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/extract-design-spec");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/capture-browser-trace");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/discover-browser-api");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/translate-design-shell");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/translate-design-interaction");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/review-proposal");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/review-diff");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/wrap-bounded-workflow");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/review-implementation");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/specify-bounded-delegation");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/synthesize-plan");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/chain-bounded-workflow");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/provider-routing-inspector");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/inspect-provider-profile");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/setup-byok-profile");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/diagnose-provider-routing");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/audit-provider-usage");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/inspect-provider-topology");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/diagnose-route-service");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/specify-domain-packaging");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/specify-domain-pack-grouping");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/review-training-replay-pack");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/curate-curriculum-content-pack");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/prepare-media-export-pack");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/compose-replay-explainer-pack");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/prepare-media-parser-pack");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}(),
			[]()
			{
				FHyperTwistSkillControlOverride OverrideState;
				OverrideState.SkillId = TEXT("skill/curate-shared-fixture-pack");
				OverrideState.bHasEnabledOverride = true;
				OverrideState.bEnabled = true;
				return OverrideState;
			}()
		};
		ControlProfile.Summary =
			TEXT("Sample control profile enabling audit-ledger success, failure, and cancel paths.");
		return ControlProfile;
	}

	FHyperTwistCoachSessionQueueSummary MakeSampleCoachSessionQueueSummaryManual()
	{
		FHyperTwistCoachSessionQueueSummary QueueSummary;
		const FHyperTwistTrainingRunStepResult StepResult =
			UHyperTwistContractLibrary::MakeSampleTrainingRunStepResult();
		if (!StepResult.IsStructurallyValid())
		{
			return QueueSummary;
		}

		QueueSummary.UserId = StepResult.UpdatedRunState.Session.UserId;
		QueueSummary.ReferenceUtc = TEXT("2026-04-28T12:12:00Z");
		QueueSummary.FocusDeckId = StepResult.UpdatedRunState.Session.DeckId;
		QueueSummary.FocusMethodSegmentId = TEXT("cfop-cross");
		QueueSummary.PrimaryQueueLabel = TEXT("primary-brief");
		QueueSummary.NextQueueLabel = TEXT("follow-up-brief");
		QueueSummary.bHasImmediateQueue = true;
		QueueSummary.bNeedsArchiveAwareSequencing = true;

		FHyperTwistCoachSessionQueueEntry PrimaryEntry;
		PrimaryEntry.EntryId = TEXT("coach_queue_primary");
		PrimaryEntry.SourceLabel = TEXT("primary-brief");
		PrimaryEntry.Priority = EHyperTwistCoachPriority::Elevated;
		PrimaryEntry.PriorityScore = 78.0f;
		PrimaryEntry.Headline = TEXT("Primary coach review block");
		PrimaryEntry.SuggestedMode = EHyperTwistTrainingDeliveryMode::CoachReviewed;
		PrimaryEntry.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
		PrimaryEntry.FocusDeckId = QueueSummary.FocusDeckId;
		PrimaryEntry.FocusMethodSegmentId = QueueSummary.FocusMethodSegmentId;
		PrimaryEntry.FocusCaseIds = { TEXT("cross_case_1"), TEXT("cross_case_2") };
		QueueSummary.Entries.Add(PrimaryEntry);

		FHyperTwistCoachSessionQueueEntry FollowUpEntry;
		FollowUpEntry.EntryId = TEXT("coach_queue_follow_up");
		FollowUpEntry.SourceLabel = TEXT("follow-up-brief");
		FollowUpEntry.Priority = EHyperTwistCoachPriority::Advisory;
		FollowUpEntry.PriorityScore = 61.0f;
		FollowUpEntry.Headline = TEXT("Follow-up coaching block");
		FollowUpEntry.SuggestedMode = EHyperTwistTrainingDeliveryMode::VirtualCube;
		FollowUpEntry.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
		FollowUpEntry.FocusDeckId = QueueSummary.FocusDeckId;
		FollowUpEntry.FocusMethodSegmentId = QueueSummary.FocusMethodSegmentId;
		FollowUpEntry.FocusCaseIds = { TEXT("cross_case_2"), TEXT("cross_case_3") };
		FollowUpEntry.bRequiresFollowUp = true;
		QueueSummary.Entries.Add(FollowUpEntry);

		FHyperTwistCoachSessionQueueEntry ArchiveEntry;
		ArchiveEntry.EntryId = TEXT("coach_queue_archive");
		ArchiveEntry.SourceLabel = TEXT("archive-policy");
		ArchiveEntry.Priority = EHyperTwistCoachPriority::Advisory;
		ArchiveEntry.PriorityScore = 56.0f;
		ArchiveEntry.Headline = TEXT("Archive retention review block");
		ArchiveEntry.SuggestedMode = EHyperTwistTrainingDeliveryMode::Timer;
		ArchiveEntry.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
		ArchiveEntry.FocusDeckId = QueueSummary.FocusDeckId;
		ArchiveEntry.FocusMethodSegmentId = QueueSummary.FocusMethodSegmentId;
		ArchiveEntry.FocusCaseIds = { TEXT("cross_case_4") };
		ArchiveEntry.bRequiresArchiveRetentionTuning = true;
		QueueSummary.Entries.Add(ArchiveEntry);

		return QueueSummary;
	}

	FHyperTwistTrainingCoachSessionQueueState MakeSampleCoachSessionQueueStateManual()
	{
		FHyperTwistTrainingCoachSessionQueueState QueueState =
			UHyperTwistTrainingRepositoryLibrary::BuildCoachSessionQueueState(
				MakeSampleCoachSessionQueueSummaryManual(),
				TEXT("coach_queue_active"),
				TEXT("2026-04-28T12:12:00Z")
			);

		QueueState = UHyperTwistTrainingRepositoryLibrary::DeferCoachSessionQueueEntry(
			QueueState,
			TEXT("coach_queue_follow_up"),
			TEXT("2026-04-28T18:00:00Z"),
			TEXT("follow-up-held-behind-primary"),
			false,
			TEXT("2026-04-28T12:13:00Z")
		);
		QueueState = UHyperTwistTrainingRepositoryLibrary::DeferCoachSessionQueueEntry(
			QueueState,
			TEXT("coach_queue_archive"),
			TEXT("2026-04-29T09:00:00Z"),
			TEXT("archive-retention-window"),
			true,
			TEXT("2026-04-28T12:14:00Z")
		);

		return QueueState;
	}

	FHyperTwistTrainingRepositoryState AppendSampleCoachArtifacts(
		const FHyperTwistTrainingRepositoryState& RepositoryState
	)
	{
		FHyperTwistTrainingRepositoryState UpdatedState = RepositoryState;

		const FHyperTwistTrainingCoachActionPlan CoachActionPlan =
			UHyperTwistContractLibrary::MakeSampleTrainingCoachActionPlan();
		if (CoachActionPlan.IsStructurallyValid())
		{
			UpdatedState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
				UpdatedState,
				CoachActionPlan
			);
		}

		const FHyperTwistTrainingCoachSessionQueueState CoachSessionQueueState =
			MakeSampleCoachSessionQueueStateManual();
		if (CoachSessionQueueState.IsStructurallyValid())
		{
			UpdatedState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
				UpdatedState,
				CoachSessionQueueState
			);
		}

		return UpdatedState;
	}

	FString ResolveSampleRepositoryUserId(const FHyperTwistTrainingRepositoryState& RepositoryState)
	{
		if (RepositoryState.RunRecords.Num() > 0 &&
			!RepositoryState.RunRecords[0].Session.UserId.IsEmpty())
		{
			return RepositoryState.RunRecords[0].Session.UserId;
		}

		if (RepositoryState.LearnerStates.Num() > 0 &&
			!RepositoryState.LearnerStates[0].UserId.IsEmpty())
		{
			return RepositoryState.LearnerStates[0].UserId;
		}

		if (RepositoryState.ReviewPlans.Num() > 0 &&
			!RepositoryState.ReviewPlans[0].UserId.IsEmpty())
		{
			return RepositoryState.ReviewPlans[0].UserId;
		}

		if (RepositoryState.StoredSessionTemplates.Num() > 0 &&
			!RepositoryState.StoredSessionTemplates[0].UserId.IsEmpty())
		{
			return RepositoryState.StoredSessionTemplates[0].UserId;
		}

		if (RepositoryState.StoredCoachActionPlans.Num() > 0 &&
			!RepositoryState.StoredCoachActionPlans[0].UserId.IsEmpty())
		{
			return RepositoryState.StoredCoachActionPlans[0].UserId;
		}

		if (RepositoryState.StoredCoachSessionQueues.Num() > 0 &&
			!RepositoryState.StoredCoachSessionQueues[0].UserId.IsEmpty())
		{
			return RepositoryState.StoredCoachSessionQueues[0].UserId;
		}

		return FString();
	}

	FHyperTwistTrainingRepositoryState BuildSampleTrainingRepositoryStateBase()
	{
		const FHyperTwistTrainingRunStepResult StepResult =
			UHyperTwistContractLibrary::MakeSampleTrainingRunStepResult();
		if (!StepResult.IsStructurallyValid())
		{
			return FHyperTwistTrainingRepositoryState();
		}

		FHyperTwistTrainingRepositoryState RepositoryState;
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::RecordRunState(
			RepositoryState,
			StepResult.UpdatedRunState
		);

		const TArray<FHyperTwistTrainingSessionTemplate> DerivedTemplates =
			UHyperTwistTrainingRepositoryLibrary::DeriveTrainingSessionTemplates(
				RepositoryState,
				StepResult.UpdatedRunState.Session.UserId,
				TEXT("2026-04-28T12:05:00Z")
			);
		if (DerivedTemplates.Num() > 0)
		{
			FHyperTwistTrainingSessionTemplate CustomizedTemplate = DerivedTemplates[0];
			CustomizedTemplate.Title = TEXT("Pinned Recovery Review");
			CustomizedTemplate.GuidanceLabel = TEXT("user-customized-recovery");
			CustomizedTemplate.RecommendedCaseCount = FMath::Max(2, CustomizedTemplate.RecommendedCaseCount);
			CustomizedTemplate.SuggestedMode = EHyperTwistTrainingDeliveryMode::VirtualCube;
			CustomizedTemplate.SourceTemplateId = CustomizedTemplate.TemplateId;
			CustomizedTemplate.bUserCustomized = true;
			CustomizedTemplate.LastUpdatedAtUtc = TEXT("2026-04-28T12:10:00Z");
			RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertStoredTrainingSessionTemplate(
				RepositoryState,
				CustomizedTemplate
			);
		}

		const FHyperTwistTrainingMethodDrillFavoriteEntry FavoriteEntry =
			UHyperTwistContractLibrary::MakeSampleMethodDrillFavoriteEntry();
		if (FavoriteEntry.IsStructurallyValid())
		{
			RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertMethodDrillFavorite(
				RepositoryState,
				FavoriteEntry
			);
		}

		const FHyperTwistTrainingMethodDrillBatch DrillBatch =
			UHyperTwistContractLibrary::MakeSampleMethodDrillBatch();
		if (DrillBatch.IsStructurallyValid())
		{
			RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertMethodDrillBatch(
				RepositoryState,
				DrillBatch
			);
		}

		return RepositoryState;
	}

	void AppendLe16(TArray<uint8>& Buffer, const uint16 Value)
	{
		Buffer.Add(static_cast<uint8>(Value & 0xff));
		Buffer.Add(static_cast<uint8>((Value >> 8) & 0xff));
	}

	void AppendLe32(TArray<uint8>& Buffer, const uint32 Value)
	{
		Buffer.Add(static_cast<uint8>(Value & 0xff));
		Buffer.Add(static_cast<uint8>((Value >> 8) & 0xff));
		Buffer.Add(static_cast<uint8>((Value >> 16) & 0xff));
		Buffer.Add(static_cast<uint8>((Value >> 24) & 0xff));
	}

	TArray<uint8> MakeSilentMonoPcm16Wav(const int32 SampleRateHz, const int32 DurationMs)
	{
		const int32 ClampedSampleRate = FMath::Max(SampleRateHz, 8000);
		const int32 ClampedDurationMs = FMath::Max(DurationMs, 100);
		const uint32 SampleCount = static_cast<uint32>((static_cast<int64>(ClampedSampleRate) * ClampedDurationMs) / 1000);
		const uint16 ChannelCount = 1;
		const uint16 BitsPerSample = 16;
		const uint16 BlockAlign = static_cast<uint16>(ChannelCount * (BitsPerSample / 8));
		const uint32 ByteRate = static_cast<uint32>(ClampedSampleRate) * BlockAlign;
		const uint32 DataSize = SampleCount * BlockAlign;
		const uint32 RiffSize = 36 + DataSize;

		TArray<uint8> Buffer;
		Buffer.Reserve(static_cast<int32>(44 + DataSize));
		Buffer.Append(reinterpret_cast<const uint8*>("RIFF"), 4);
		AppendLe32(Buffer, RiffSize);
		Buffer.Append(reinterpret_cast<const uint8*>("WAVE"), 4);
		Buffer.Append(reinterpret_cast<const uint8*>("fmt "), 4);
		AppendLe32(Buffer, 16);
		AppendLe16(Buffer, 1);
		AppendLe16(Buffer, ChannelCount);
		AppendLe32(Buffer, static_cast<uint32>(ClampedSampleRate));
		AppendLe32(Buffer, ByteRate);
		AppendLe16(Buffer, BlockAlign);
		AppendLe16(Buffer, BitsPerSample);
		Buffer.Append(reinterpret_cast<const uint8*>("data"), 4);
		AppendLe32(Buffer, DataSize);
		Buffer.AddZeroed(static_cast<int32>(DataSize));
		return Buffer;
	}

	FHyperTwistVoiceProfileSummary MakeVoiceProfile(
		const TCHAR* VoiceProfileId,
		const TCHAR* VoiceName,
		const TCHAR* LanguageCode,
		const TCHAR* LanguageFamily,
		const TCHAR* RegionCode,
		const TCHAR* LanguageNameEnglish,
		const TCHAR* Quality,
		const int32 NumSpeakers,
		const TCHAR* ModelCardRelativePath,
		const TArray<FString>& Aliases
	)
	{
		FHyperTwistVoiceProfileSummary Profile;
		Profile.VoiceProfileId = VoiceProfileId;
		Profile.VoiceName = VoiceName;
		Profile.LanguageCode = LanguageCode;
		Profile.LanguageFamily = LanguageFamily;
		Profile.RegionCode = RegionCode;
		Profile.LanguageNameEnglish = LanguageNameEnglish;
		Profile.Quality = Quality;
		Profile.NumSpeakers = NumSpeakers;
		Profile.ModelCardRelativePath = ModelCardRelativePath;
		Profile.Aliases = Aliases;
		return Profile;
	}

	FHyperTwistVoiceAssetReviewProfile MakeDefaultVoiceAssetReviewProfile(const FString& ProfileId)
	{
		FHyperTwistVoiceAssetReviewProfile Profile;
		Profile.VoiceAssetReviewProfileId = ProfileId;
		Profile.VoiceAssetReviewPosture = TEXT("independent-voice-asset-review-required");
		Profile.ShippingPosture = TEXT("not-shipped-in-packet");
		Profile.DownloadWorkflowPosture = TEXT("deferred-out-of-packet");
		Profile.ProvisioningPosture = TEXT("user-supplied-or-sidecar-managed");
		Profile.CodeLicenseBoundary = TEXT("code-license-reviewed-separately");
		Profile.bRequiresIndependentVoiceAssetReview = true;
		Profile.bAllowsBundledVoiceAssetRedistribution = false;
		Profile.bAllowsRuntimeVoiceDownloadInCurrentPacket = false;
		Profile.bSupportsUserManagedVoiceAssets = true;
		Profile.bSupportsSidecarManagedVoiceAssets = true;
		Profile.bRequiresPerVoiceModelCardReview = true;
		return Profile;
	}

	FHyperTwistVoiceAssetDescriptor MakeVoiceAssetDescriptor(
		const TCHAR* VoiceAssetId,
		const TCHAR* VoiceProfileId,
		const TCHAR* ArtifactName,
		const TCHAR* RelativePathHint,
		const TCHAR* ReviewDocumentPath,
		const int32 ApproximateSizeMiB,
		const bool bOptionalForPacket
	)
	{
		FHyperTwistVoiceAssetDescriptor Descriptor;
		Descriptor.VoiceAssetId = VoiceAssetId;
		Descriptor.VoiceProfileId = VoiceProfileId;
		Descriptor.ArtifactName = ArtifactName;
		Descriptor.RelativePathHint = RelativePathHint;
		Descriptor.SourceDocumentPath = TEXT("piper/src/python_run/piper/voices.json");
		Descriptor.ReviewDocumentPath = ReviewDocumentPath;
		Descriptor.AcquisitionMode = TEXT("user-supplied-or-sidecar-managed");
		Descriptor.ReviewPosture = TEXT("per-voice-card-review-required");
		Descriptor.ApproximateSizeMiB = ApproximateSizeMiB;
		Descriptor.bOptionalForPacket = bOptionalForPacket;
		Descriptor.bUserSuppliedOnly = true;
		Descriptor.bBundledWithCodeDistribution = false;
		return Descriptor;
	}

	FHyperTwistVoiceModelReviewProfile MakeDefaultVoiceModelReviewProfile(const FString& ProfileId)
	{
		FHyperTwistVoiceModelReviewProfile Profile;
		Profile.VoiceModelReviewProfileId = ProfileId;
		Profile.ReviewPosture = TEXT("independent-model-and-payload-review-required");
		Profile.ShippingPosture = TEXT("not-shipped-in-packet");
		Profile.DownloadWorkflowPosture = TEXT("deferred-out-of-packet");
		Profile.CodeLicenseBoundary = TEXT("code-license-reviewed-separately");
		Profile.bRequiresIndependentModelLicenseReview = true;
		Profile.bRequiresIndependentPayloadLicenseReview = true;
		Profile.bRequiresTermsAcceptanceReview = true;
		Profile.bAllowsBundledModelRedistribution = false;
		Profile.bAllowsRuntimeModelDownloadInCurrentPacket = false;
		return Profile;
	}

	FHyperTwistVoiceModelReviewDescriptor MakeVoiceModelReviewDescriptor(
		const TCHAR* VoiceModelReviewId,
		const TCHAR* ModelBindingId,
		const TCHAR* VocoderBindingId,
		const TCHAR* VoiceProfileId,
		const TCHAR* RegistryReferencePath,
		const TCHAR* ReviewDocumentPath,
		const TCHAR* ModelLicensePosture,
		const TCHAR* PayloadLicensePosture,
		const bool bTosAcceptanceRequired
	)
	{
		FHyperTwistVoiceModelReviewDescriptor Descriptor;
		Descriptor.VoiceModelReviewId = VoiceModelReviewId;
		Descriptor.ModelBindingId = ModelBindingId;
		Descriptor.VocoderBindingId = VocoderBindingId;
		Descriptor.VoiceProfileId = VoiceProfileId;
		Descriptor.RegistryReferencePath = RegistryReferencePath;
		Descriptor.ReviewDocumentPath = ReviewDocumentPath;
		Descriptor.ModelLicensePosture = ModelLicensePosture;
		Descriptor.PayloadLicensePosture = PayloadLicensePosture;
		Descriptor.AcquisitionMode = TEXT("downloadable-provider-or-user-supplied");
		Descriptor.bTosAcceptanceRequired = bTosAcceptanceRequired;
		Descriptor.bOptionalForPacket = false;
		Descriptor.bBundledWithCodeDistribution = false;
		return Descriptor;
	}

	FHyperTwistNarrationOrchestrationProfile MakeLocalNarrationOrchestrationProfile()
	{
		FHyperTwistNarrationOrchestrationProfile Profile;
		Profile.OrchestrationProfileId = TEXT("local-basic-narration-v1");
		Profile.ServiceLaneId = TEXT("voice/local-sidecar");
		Profile.ModelBindingId = TEXT("voice-model/local-offline-medium-v1");
		Profile.VocoderBindingId = TEXT("vocoder/default-mono-v1");
		Profile.DefaultSpeakerProfileId = TEXT("speaker/default");
		Profile.bEnableSpeakerSelection = false;
		Profile.bEnableLanguageRouting = false;
		Profile.bEnableSentenceSplitting = false;
		Profile.bEnableSpeakerReferenceConditioning = false;
		Profile.bSupportsMultiSpeaker = false;
		Profile.bSupportsMultiLingual = false;
		Profile.bPreferGpu = false;
		return Profile;
	}

	FHyperTwistNarrationOrchestrationProfile MakeAdvancedNarrationOrchestrationProfile()
	{
		FHyperTwistNarrationOrchestrationProfile Profile;
		Profile.OrchestrationProfileId = TEXT("python-multispeaker-narration-v1");
		Profile.ServiceLaneId = TEXT("voice/python-service");
		Profile.ModelBindingId = TEXT("voice-model/multilingual-premium-v1");
		Profile.VocoderBindingId = TEXT("vocoder/high-fidelity-v1");
		Profile.DefaultSpeakerProfileId = TEXT("speaker/companion-guide");
		Profile.bEnableSpeakerSelection = true;
		Profile.bEnableLanguageRouting = true;
		Profile.bEnableSentenceSplitting = true;
		Profile.bEnableSpeakerReferenceConditioning = true;
		Profile.bSupportsMultiSpeaker = true;
		Profile.bSupportsMultiLingual = true;
		Profile.bPreferGpu = true;
		return Profile;
	}

	FHyperTwistTrainingSourceAttribution MakeMethodDrillCleanRoomAttribution()
	{
		FHyperTwistTrainingSourceAttribution Attribution;
		Attribution.SourceMode = EHyperTwistTrainingSourceMode::CleanRoom;
		Attribution.SourceRepo = TEXT("onionhoney/roux-trainers");
		Attribution.SourceLicense = TEXT("GPLv3 clean-room behavioral handoff");
		Attribution.SourceNotes = TEXT("First-party HyperTwist method-stage drill sample built from scrubbed clean-room guidance.");
		return Attribution;
	}

	FHyperTwistTrainingDeck MakeSampleMethodDrillDeck()
	{
		const FHyperTwistTrainingSourceAttribution Attribution = MakeMethodDrillCleanRoomAttribution();

		FHyperTwistTrainingCase RecognitionCaseA;
		RecognitionCaseA.CaseId = TEXT("roux-block-case-01");
		RecognitionCaseA.PuzzleId = TEXT("cube/3x3x3");
		RecognitionCaseA.PromptKind = EHyperTwistTrainingPromptKind::Recognition;
		RecognitionCaseA.PromptLabel = TEXT("Left Block Recognition A");
		RecognitionCaseA.CanonicalStateRef = TEXT("cube/3x3x3:roux:first-block:left:a");
		RecognitionCaseA.CanonicalNotation = TEXT("R U R'");
		RecognitionCaseA.ScrambleNotation = TEXT("U R U' L' U");
		RecognitionCaseA.SubsetId = TEXT("first-block");
		RecognitionCaseA.Difficulty = 0.45f;
		RecognitionCaseA.Tags = {
			TEXT("classic"),
			TEXT("roux"),
			TEXT("block-building"),
			TEXT("subset:first-block"),
			TEXT("stage-recognition")
		};
		RecognitionCaseA.AllowedDeliveryModes = {
			EHyperTwistTrainingDeliveryMode::VirtualCube,
			EHyperTwistTrainingDeliveryMode::RecognitionAssisted,
			EHyperTwistTrainingDeliveryMode::CoachReviewed
		};
		RecognitionCaseA.TimeTargetMs = 0;
		RecognitionCaseA.SourceAttribution = Attribution;

		FHyperTwistTrainingCase RecognitionCaseB = RecognitionCaseA;
		RecognitionCaseB.CaseId = TEXT("roux-block-case-02");
		RecognitionCaseB.PromptLabel = TEXT("Left Block Recognition B");
		RecognitionCaseB.CanonicalStateRef = TEXT("cube/3x3x3:roux:first-block:left:b");
		RecognitionCaseB.CanonicalNotation = TEXT("r U' r'");
		RecognitionCaseB.ScrambleNotation = TEXT("R U2 R' F U'");
		RecognitionCaseB.Difficulty = 0.62f;

		FHyperTwistTrainingDeck DrillDeck;
		DrillDeck.DeckId = TEXT("roux-first-block-recognition");
		DrillDeck.Title = TEXT("First Block Recognition");
		DrillDeck.DeliveryModes = {
			EHyperTwistTrainingDeliveryMode::VirtualCube,
			EHyperTwistTrainingDeliveryMode::RecognitionAssisted,
			EHyperTwistTrainingDeliveryMode::CoachReviewed
		};
		DrillDeck.SelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
		DrillDeck.bUsesRealScrambles = false;
		DrillDeck.bSupportsAlgorithmReveal = true;
		DrillDeck.bSupportsVirtualCube = true;
		DrillDeck.bSupportsSmartCube = false;
		DrillDeck.Cases = {RecognitionCaseA, RecognitionCaseB};
		DrillDeck.DifficultyBand = TEXT("stage");
		DrillDeck.Tags = {
			TEXT("classic"),
			TEXT("roux"),
			TEXT("block-building"),
			TEXT("subset:first-block"),
			TEXT("method-drill")
		};
		DrillDeck.SubsetId = TEXT("first-block");
		DrillDeck.SourceAttribution = Attribution;
		return DrillDeck;
	}

	FHyperTwistVisionCalibrationProfile MakeDefaultClassicCubeCalibrationProfile(const FString& ProfileId)
	{
		FHyperTwistVisionCalibrationProfile Profile;
		Profile.ProfileId = ProfileId;
		Profile.PuzzleId = TEXT("cube/3x3x3");
		Profile.DominantColorMethod = TEXT("kmeans-1");
		Profile.ColorDistanceMethod = TEXT("ciede2000");
		Profile.bPersistsPerUserPalette = true;

		auto AddSwatch = [&Profile](
			const TCHAR* ColorId,
			const TCHAR* Notation,
			const FIntVector Bgr,
			const FVector Lab
		)
		{
			FHyperTwistVisionCalibrationSwatch Swatch;
			Swatch.ColorId = ColorId;
			Swatch.Notation = Notation;
			Swatch.ReferenceBgr = Bgr;
			Swatch.ReferenceLab = Lab;
			Profile.PaletteSwatches.Add(Swatch);
		};

		AddSwatch(TEXT("green"), TEXT("F"), FIntVector(0, 255, 0), FVector(87.737f, -86.185f, 83.181f));
		AddSwatch(TEXT("red"), TEXT("R"), FIntVector(0, 0, 255), FVector(53.233f, 80.109f, 67.220f));
		AddSwatch(TEXT("blue"), TEXT("B"), FIntVector(255, 0, 0), FVector(32.303f, 79.197f, -107.864f));
		AddSwatch(TEXT("orange"), TEXT("L"), FIntVector(0, 165, 255), FVector(74.200f, 23.900f, 78.900f));
		AddSwatch(TEXT("white"), TEXT("U"), FIntVector(255, 255, 255), FVector(100.000f, 0.000f, 0.000f));
		AddSwatch(TEXT("yellow"), TEXT("D"), FIntVector(0, 255, 255), FVector(97.139f, -21.554f, 94.478f));
		return Profile;
	}

	FHyperTwistVisionShellProfile MakeDefaultClassicCubeWebcamShellProfile(const FString& ProfileId)
	{
		FHyperTwistVisionShellProfile Profile;
		Profile.ShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("webcam-overlay");
		Profile.LocaleRoutingMode = TEXT("first-party-locale-cycle");
		Profile.DefaultLocaleCode = TEXT("en");
		Profile.FontReviewProfileId = TEXT("qbr-bundled-font-review-v1");
		Profile.FontReviewProfileDefinition = MakeDefaultQbrFontReviewProfile(Profile.FontReviewProfileId);
		Profile.SupportedFontReviews = MakeQbrSupportedFontReviews();
		Profile.SupportedLocales = MakeQbrSupportedVisionLocales();

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const int32 GridRows,
			const int32 GridColumns,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistVisionShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.GridRows = GridRows;
			Panel.GridColumns = GridColumns;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistVisionShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("preview-sticker-grid"), TEXT("sticker-grid"), TEXT("top-left"), 3, 3, true);
		AddPanel(TEXT("snapshot-sticker-grid"), TEXT("sticker-grid"), TEXT("left-stack-below-preview"), 3, 3, true);
		AddPanel(TEXT("scanned-side-counter"), TEXT("status-readout"), TEXT("bottom-left"), 0, 0, true);
		AddPanel(TEXT("classic-cube-net"), TEXT("cube-net"), TEXT("bottom-right"), 3, 4, true);
		AddPanel(TEXT("locale-indicator"), TEXT("status-readout"), TEXT("top-right"), 0, 0, true);
		AddPanel(TEXT("calibration-swatch-rail"), TEXT("calibration-rail"), TEXT("top-left-offset"), 6, 1, false);

		AddAction(TEXT("capture-snapshot"), TEXT("Space"), TEXT("snapshot-sticker-grid"));
		AddAction(TEXT("toggle-calibration"), TEXT("C"), TEXT("calibration-swatch-rail"));
		AddAction(TEXT("cycle-locale"), TEXT("L"), TEXT("locale-indicator"));
		AddAction(TEXT("close-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistVisionFontReviewProfile MakeDefaultQbrFontReviewProfile(const FString& ProfileId)
	{
		FHyperTwistVisionFontReviewProfile Profile;
		Profile.FontReviewProfileId = ProfileId;
		Profile.ReviewPosture = TEXT("independent-font-license-review-required");
		Profile.ShippingPosture = TEXT("not-shipped-in-packet");
		Profile.ProvisioningPosture = TEXT("user-supplied-or-platform-provided");
		Profile.CodeLicenseBoundary = TEXT("code-license-reviewed-separately");
		Profile.bRequiresIndependentFontLicenseReview = true;
		Profile.bAllowsBundledFontRedistribution = false;
		Profile.bAllowsRuntimeFontDownloadInCurrentPacket = false;
		Profile.bRequiresComplexScriptCoverageVerification = true;
		return Profile;
	}

	FString NormalizeBrowserFaceHint(const FString& FaceId)
	{
		FString Normalized = FaceId;
		Normalized = Normalized.TrimStartAndEnd();
		Normalized.ToUpperInline();
		return Normalized;
	}

	const TArray<FString>& GetClassicCorrectionFaceOrder()
	{
		static const TArray<FString> FaceOrder = {
			TEXT("U"),
			TEXT("R"),
			TEXT("F"),
			TEXT("D"),
			TEXT("L"),
			TEXT("B")
		};
		return FaceOrder;
	}

	int32 GetClassicCorrectionFaceOrderIndex(const FString& FaceId)
	{
		const FString NormalizedFaceId = NormalizeBrowserFaceHint(FaceId);
		const TArray<FString>& FaceOrder = GetClassicCorrectionFaceOrder();
		for (int32 Index = 0; Index < FaceOrder.Num(); ++Index)
		{
			if (FaceOrder[Index] == NormalizedFaceId)
			{
				return Index;
			}
		}

		return MAX_int32;
	}

	float CalculateCommittedFaceConfidence(const FHyperTwistVisionCommittedFaceState& FaceState)
	{
		if (FaceState.LatestOrderedStickers.Num() <= 0)
		{
			return 0.0f;
		}

		float ConfidenceSum = 0.0f;
		for (const FHyperTwistVisionObservedSticker& Sticker : FaceState.LatestOrderedStickers)
		{
			ConfidenceSum += Sticker.Confidence;
		}

		return ConfidenceSum / static_cast<float>(FaceState.LatestOrderedStickers.Num());
	}

	void UpsertCorrectionTarget(
		TArray<FHyperTwistVisionCorrectionTarget>& Targets,
		const FHyperTwistVisionCorrectionTarget& Candidate
	)
	{
		const FString CandidateFaceId = NormalizeBrowserFaceHint(Candidate.FaceId);
		const int32 ExistingIndex = Targets.IndexOfByPredicate(
			[&CandidateFaceId](const FHyperTwistVisionCorrectionTarget& ExistingTarget)
			{
				return NormalizeBrowserFaceHint(ExistingTarget.FaceId) == CandidateFaceId;
			}
		);

		if (ExistingIndex == INDEX_NONE)
		{
			Targets.Add(Candidate);
			return;
		}

		if (Candidate.PriorityOrdinal < Targets[ExistingIndex].PriorityOrdinal)
		{
			Targets[ExistingIndex] = Candidate;
			return;
		}

		if (Candidate.PriorityOrdinal == Targets[ExistingIndex].PriorityOrdinal
			&& Candidate.bManualReviewPreferred
			&& !Targets[ExistingIndex].bManualReviewPreferred)
		{
			Targets[ExistingIndex].bManualReviewPreferred = true;
		}
	}

	FHyperTwistVisionBrowserAssetReviewProfile MakeDefaultRubixCubeSolverBrowserAssetReviewProfile(
		const FString& ProfileId
	);

	TArray<FHyperTwistVisionBrowserAssetReviewDescriptor> MakeRubixCubeSolverBrowserAssetReviews();

	FHyperTwistVisionBrowserAssetReviewDescriptor ResolveBrowserAssetReviewDescriptor(
		const TArray<FHyperTwistVisionBrowserAssetReviewDescriptor>& SupportedReviews,
		const FString& PreferredDescriptorId
	);

	FHyperTwistVisionBrowserShellProfile MakeDefaultClassicCubeBrowserShellProfile(const FString& ProfileId)
	{
		FHyperTwistVisionBrowserShellProfile Profile;
		Profile.BrowserShellProfileId = ProfileId;
		Profile.TransportKind = TEXT("websocket");
		Profile.TransportEndpoint = TEXT("ws://localhost:8090/");
		Profile.CaptureIntervalMs = 100;
		Profile.bSupportsManualCubeEdit = true;
		Profile.bSupportsPlaybackStage = false;
		Profile.BrowserAssetReviewProfileId = TEXT("rubix-browser-asset-review-v1");
		Profile.BrowserAssetReviewProfileDefinition =
			MakeDefaultRubixCubeSolverBrowserAssetReviewProfile(Profile.BrowserAssetReviewProfileId);
		Profile.DefaultBrowserAssetReviewDescriptorId =
			TEXT("browser-asset-review/rubix-cube-solver/twistysim");
		Profile.SupportedBrowserAssetReviews = MakeRubixCubeSolverBrowserAssetReviews();
		Profile.OrderedStageIds = {
			TEXT("home-page"),
			TEXT("video-stream"),
			TEXT("cube-edit")
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistVisionShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddAction(TEXT("start-browser-capture"), TEXT("button:start-capture"), TEXT("home-page"));
		AddAction(TEXT("finish-browser-capture"), TEXT("button:finish-capture"), TEXT("video-stream"));
		AddAction(TEXT("apply-manual-corrections"), TEXT("button:apply-corrections"), TEXT("cube-edit"));
		AddAction(TEXT("restart-browser-session"), TEXT("button:restart-session"), TEXT("cube-edit"));
		return Profile;
	}

	FHyperTwistVisionBrowserAssetReviewProfile MakeDefaultRubixCubeSolverBrowserAssetReviewProfile(
		const FString& ProfileId
	)
	{
		FHyperTwistVisionBrowserAssetReviewProfile Profile;
		Profile.BrowserAssetReviewProfileId = ProfileId;
		Profile.ReviewPosture = TEXT("independent-browser-asset-license-review-required");
		Profile.ShippingPosture = TEXT("not-shipped-in-packet");
		Profile.ProvisioningPosture = TEXT("user-supplied-or-review-cleared-replacement");
		Profile.CodeLicenseBoundary = TEXT("code-license-reviewed-separately");
		Profile.bRequiresIndependentBrowserAssetReview = true;
		Profile.bAllowsBundledBrowserAssetRedistribution = false;
		Profile.bAllowsRuntimeBrowserAssetDownloadInCurrentPacket = false;
		Profile.bPlaybackVisualizationOwnershipDeferred = true;
		return Profile;
	}

	TArray<FHyperTwistVisionBrowserAssetReviewDescriptor> MakeRubixCubeSolverBrowserAssetReviews()
	{
		FHyperTwistVisionBrowserAssetReviewDescriptor Descriptor;
		Descriptor.BrowserAssetReviewDescriptorId =
			TEXT("browser-asset-review/rubix-cube-solver/twistysim");
		Descriptor.UpstreamComponentId =
			TEXT("vivaansinghvi07/rubix-cube-solver/frontend/lib/twistysim.min.js");
		Descriptor.AssetPathHint = TEXT("frontend/lib/twistysim.min.js");
		Descriptor.AssetKind = TEXT("browser-visualization-script");
		Descriptor.ReviewDocumentPath = TEXT("browser/twistysim/license-review");
		Descriptor.AcquisitionMode = TEXT("user-supplied-or-review-cleared-replacement");
		Descriptor.ReviewPosture = TEXT("per-asset-license-review-required");
		Descriptor.bBundledWithCodeDistribution = false;
		Descriptor.bPlaybackVisualizationDeferred = true;
		return {Descriptor};
	}

	FHyperTwistVisionBrowserAssetReviewDescriptor ResolveBrowserAssetReviewDescriptor(
		const TArray<FHyperTwistVisionBrowserAssetReviewDescriptor>& SupportedReviews,
		const FString& PreferredDescriptorId
	)
	{
		for (const FHyperTwistVisionBrowserAssetReviewDescriptor& Descriptor : SupportedReviews)
		{
			if (Descriptor.BrowserAssetReviewDescriptorId.Equals(
				PreferredDescriptorId,
				ESearchCase::IgnoreCase
			))
			{
				return Descriptor;
			}
		}

		if (SupportedReviews.Num() > 0)
		{
			return SupportedReviews[0];
		}

		FHyperTwistVisionBrowserAssetReviewDescriptor FallbackDescriptor;
		FallbackDescriptor.BrowserAssetReviewDescriptorId =
			TEXT("browser-asset-review/rubix-cube-solver/twistysim");
		FallbackDescriptor.UpstreamComponentId =
			TEXT("vivaansinghvi07/rubix-cube-solver/frontend/lib/twistysim.min.js");
		FallbackDescriptor.AssetPathHint = TEXT("frontend/lib/twistysim.min.js");
		FallbackDescriptor.AssetKind = TEXT("browser-visualization-script");
		FallbackDescriptor.ReviewDocumentPath = TEXT("browser/twistysim/license-review");
		FallbackDescriptor.AcquisitionMode = TEXT("user-supplied-or-review-cleared-replacement");
		FallbackDescriptor.ReviewPosture = TEXT("per-asset-license-review-required");
		FallbackDescriptor.bBundledWithCodeDistribution = false;
		FallbackDescriptor.bPlaybackVisualizationDeferred = true;
		return FallbackDescriptor;
	}

	FHyperTwistVisionSolveExplanationProfile MakeDefaultClassicCubeSolveExplanationProfile(
		const FString& ProfileId
	)
	{
		FHyperTwistVisionSolveExplanationProfile Profile;
		Profile.ExplanationProfileId = ProfileId;
		Profile.PuzzleId = TEXT("cube/3x3x3");
		Profile.RecommendationMode = TEXT("bounded-stage-ladder-v1");
		Profile.LocaleGuidanceMode = TEXT("qbr-locale-guidance-routing-v1");
		Profile.DefaultLocaleCode = TEXT("en");
		Profile.StartingOrientationHint = TEXT("front: green | top: white");
		Profile.FontReviewProfileId = TEXT("qbr-bundled-font-review-v1");
		Profile.FontReviewProfileDefinition = MakeDefaultQbrFontReviewProfile(Profile.FontReviewProfileId);
		Profile.SupportedFontReviews = MakeQbrSupportedFontReviews();
		Profile.bSupportsStageRecommendation = true;
		Profile.bSupportsStepNavigation = true;
		Profile.bSupportsPlaybackStage = false;
		Profile.SupportedLocales = MakeQbrSupportedVisionLocales();

		auto AddStep = [&Profile](
			const TCHAR* StepId,
			const TCHAR* StageId,
			const TCHAR* Title,
			const TCHAR* Description,
			const TCHAR* RecommendationLine,
			const int32 StageOrdinal
		)
		{
			FHyperTwistVisionSolveExplanationStep Step;
			Step.StepId = StepId;
			Step.StageId = StageId;
			Step.Title = Title;
			Step.Description = Description;
			Step.RecommendationLine = RecommendationLine;
			Step.StageOrdinal = StageOrdinal;
			Step.bPlaybackDeferred = true;
			Profile.Steps.Add(Step);
		};

		AddStep(
			TEXT("orient-centers-step"),
			TEXT("orient-centers"),
			TEXT("Orient Centers"),
			TEXT("Check the cube orientation and align the center reference before turning into the solve ladder."),
			TEXT("Confirm the edited net and lock the reference orientation before solve guidance begins."),
			0
		);
		AddStep(
			TEXT("solve-white-cross-step"),
			TEXT("solve-white-cross"),
			TEXT("Build First Cross"),
			TEXT("Assemble the opening cross with edge placement matched against the side colors."),
			TEXT("Start with a stable cross so later first-layer turns stay bounded and readable."),
			1
		);
		AddStep(
			TEXT("solve-first-layer-corners-step"),
			TEXT("solve-first-layer-corners"),
			TEXT("Place First-Layer Corners"),
			TEXT("Insert the matching corners to finish the first layer without disturbing the cross."),
			TEXT("Close the first layer before moving into the middle-band edge work."),
			2
		);
		AddStep(
			TEXT("solve-second-layer-edges-step"),
			TEXT("solve-second-layer-edges"),
			TEXT("Solve Middle-Layer Edges"),
			TEXT("Move the non-top edges into their middle-layer slots while preserving the solved first layer."),
			TEXT("Complete the middle layer so orientation-only work remains on the last layer."),
			3
		);
		AddStep(
			TEXT("solve-oll-edges-step"),
			TEXT("solve-oll-edges"),
			TEXT("Orient Last-Layer Edges"),
			TEXT("Turn the last-layer edges so the top-face color is established across the edge ring."),
			TEXT("Orient the last-layer edges before promoting corner orientation."),
			4
		);
		AddStep(
			TEXT("solve-oll-corners-step"),
			TEXT("solve-oll-corners"),
			TEXT("Orient Last-Layer Corners"),
			TEXT("Resolve the remaining top-face corner orientation while keeping the lower layers intact."),
			TEXT("Finish top-face orientation before any final permutation pass."),
			5
		);
		AddStep(
			TEXT("solve-pll-corners-step"),
			TEXT("solve-pll-corners"),
			TEXT("Permute Last-Layer Corners"),
			TEXT("Cycle the last-layer corners into their destination positions after orientation is complete."),
			TEXT("Place the last-layer corners first so the final edge permutation stays bounded."),
			6
		);
		AddStep(
			TEXT("solve-pll-edges-step"),
			TEXT("solve-pll-edges"),
			TEXT("Permute Last-Layer Edges"),
			TEXT("Finish the solve by cycling the last-layer edges into their final positions."),
			TEXT("Close with the last-layer edges; playback ownership remains deferred in this packet."),
			7
		);

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistVisionShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddAction(TEXT("start-solve-explanation"), TEXT("button:start-explanation"), TEXT("cube-edit"));
		AddAction(TEXT("step-solve-forward"), TEXT("button:next-step"), TEXT("solve-explanation-stage"));
		AddAction(TEXT("step-solve-backward"), TEXT("button:previous-step"), TEXT("solve-explanation-stage"));
		AddAction(TEXT("restart-solve-explanation"), TEXT("button:restart-explanation"), TEXT("solve-explanation-stage"));
		return Profile;
	}

	FHyperTwistVisionCorrectionProfile MakeDefaultClassicCubeCorrectionProfile(const FString& ProfileId)
	{
		FHyperTwistVisionCorrectionProfile Profile;
		Profile.CorrectionProfileId = ProfileId;
		Profile.PuzzleId = TEXT("cube/3x3x3");
		Profile.CorrectionMode = TEXT("bounded-multi-face-correction-v1");
		Profile.bSupportsTargetedRescan = true;
		Profile.bSupportsManualCubeEdit = true;
		Profile.bSupportsStageRestart = true;

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistVisionShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddAction(TEXT("capture-target-face"), TEXT("button:capture-target-face"), TEXT("video-stream"));
		AddAction(TEXT("rescan-target-face"), TEXT("button:rescan-target-face"), TEXT("video-stream"));
		AddAction(TEXT("apply-manual-corrections"), TEXT("button:apply-corrections"), TEXT("cube-edit"));
		AddAction(TEXT("restart-browser-session"), TEXT("button:restart-session"), TEXT("cube-edit"));
		return Profile;
	}

	bool HasAppliedResolutionForFace(
		const TArray<FHyperTwistVisionCorrectionResolution>& ResolutionLedger,
		const FHyperTwistVisionCommittedFaceState& FaceState
	)
	{
		const FString NormalizedFaceId = NormalizeBrowserFaceHint(FaceState.FaceId);
		return ResolutionLedger.ContainsByPredicate(
			[&NormalizedFaceId, &FaceState](const FHyperTwistVisionCorrectionResolution& Resolution)
			{
				return NormalizeBrowserFaceHint(Resolution.FaceId) == NormalizedFaceId
					&& Resolution.ObservationId == FaceState.LatestObservationId
					&& Resolution.RevisionCount == FaceState.RevisionCount;
			}
		);
	}

	void ResolveMockClassicFaceSwatch(
		const FString& FaceId,
		FString& OutColorId,
		FString& OutNotation,
		FIntVector& OutSampleBgr
	)
	{
		const FString NormalizedFaceId = FaceId.ToUpper();
		if (NormalizedFaceId == TEXT("U"))
		{
			OutColorId = TEXT("white");
			OutNotation = TEXT("U");
			OutSampleBgr = FIntVector(255, 255, 255);
			return;
		}
		if (NormalizedFaceId == TEXT("R"))
		{
			OutColorId = TEXT("red");
			OutNotation = TEXT("R");
			OutSampleBgr = FIntVector(0, 0, 255);
			return;
		}
		if (NormalizedFaceId == TEXT("D"))
		{
			OutColorId = TEXT("yellow");
			OutNotation = TEXT("D");
			OutSampleBgr = FIntVector(0, 255, 255);
			return;
		}
		if (NormalizedFaceId == TEXT("L"))
		{
			OutColorId = TEXT("orange");
			OutNotation = TEXT("L");
			OutSampleBgr = FIntVector(0, 165, 255);
			return;
		}
		if (NormalizedFaceId == TEXT("B"))
		{
			OutColorId = TEXT("blue");
			OutNotation = TEXT("B");
			OutSampleBgr = FIntVector(255, 0, 0);
			return;
		}

		OutColorId = TEXT("green");
		OutNotation = TEXT("F");
		OutSampleBgr = FIntVector(0, 255, 0);
	}

	FHyperTwistVisionFaceObservation MakeMockClassicFaceObservation(
		const FString& ObservationId,
		const FString& FaceId,
		const float StickerConfidence,
		const bool bCommitReady
	)
	{
		FHyperTwistVisionFaceObservation Observation;
		Observation.ObservationId = ObservationId;
		Observation.FaceId = FaceId;
		Observation.OrderingProfile = TEXT("3x3-row-major");
		Observation.CandidateContourCount = 12;
		Observation.AcceptedContourCount = 9;
		Observation.bFoundStableThreeByThreeGrid = true;
		Observation.bOrderingStable = true;
		Observation.bCommitReady = bCommitReady;

		FString ColorId;
		FString Notation;
		FIntVector SampleBgr = FIntVector::ZeroValue;
		ResolveMockClassicFaceSwatch(FaceId, ColorId, Notation, SampleBgr);

		for (int32 GridIndex = 0; GridIndex < 9; ++GridIndex)
		{
			FHyperTwistVisionObservedSticker Sticker;
			Sticker.GridIndex = GridIndex;
			Sticker.GridRow = GridIndex / 3;
			Sticker.GridColumn = GridIndex % 3;
			Sticker.ColorId = ColorId;
			Sticker.Notation = Notation;
			Sticker.SampleBgr = SampleBgr;
			Sticker.Confidence = StickerConfidence;
			Observation.OrderedStickers.Add(Sticker);
		}

		return Observation;
	}

	FHyperTwistVisionReconstructionSession MakeMockClassicReconstructionSession(
		const FString& SessionId,
		const TArray<FString>& FaceIds,
		const float StickerConfidence
	)
	{
		FHyperTwistVisionReconstructionSession Session;
		Session.SessionId = SessionId;
		Session.PuzzleId = TEXT("cube/3x3x3");
		Session.ReconstructionProfile = TEXT("classic-face-vote-v1");
		Session.OrientationProfile = TEXT("classic-target-face-net-v1");
		Session.bUsesObservationVoting = true;
		Session.bHasStableOrientation = FaceIds.Num() > 0;

		const TArray<FString> ExpectedFaces = {
			TEXT("U"),
			TEXT("R"),
			TEXT("F"),
			TEXT("D"),
			TEXT("L"),
			TEXT("B")
		};

		for (const FString& FaceId : FaceIds)
		{
			FHyperTwistVisionFaceObservation Observation = MakeMockClassicFaceObservation(
				FString::Printf(TEXT("%s/%s"), *SessionId, *FaceId),
				FaceId,
				StickerConfidence,
				true
			);

			FHyperTwistVisionCommittedFaceState FaceState;
			FaceState.FaceId = FaceId;
			FaceState.LatestObservationId = Observation.ObservationId;
			FaceState.OrderingProfile = Observation.OrderingProfile;
			FaceState.ObservationCount = 1;
			FaceState.RevisionCount = 0;
			FaceState.LatestOrderedStickers = Observation.OrderedStickers;

			for (const FHyperTwistVisionObservedSticker& Sticker : Observation.OrderedStickers)
			{
				FHyperTwistVisionStickerVoteTally Tally;
				Tally.Notation = Sticker.Notation;
				Tally.ColorId = Sticker.ColorId;
				Tally.VoteCount = 1;

				FHyperTwistVisionReconstructionStickerVote Vote;
				Vote.GridIndex = Sticker.GridIndex;
				Vote.GridRow = Sticker.GridRow;
				Vote.GridColumn = Sticker.GridColumn;
				Vote.WinningNotation = Sticker.Notation;
				Vote.WinningColorId = Sticker.ColorId;
				Vote.WinningVoteCount = 1;
				Vote.TotalVoteCount = 1;
				Vote.Tallies.Add(Tally);
				FaceState.StickerVotes.Add(Vote);
			}

			Session.CommittedFaces.Add(FaceState);
		}

		Session.TotalCommittedFaceCount = Session.CommittedFaces.Num();
		Session.TotalRevisionCount = 0;
		Session.ConfidenceRollup = StickerConfidence;

		for (const FString& ExpectedFace : ExpectedFaces)
		{
			if (!FaceIds.Contains(ExpectedFace))
			{
				Session.MissingFaces.Add(ExpectedFace);
			}
		}
		Session.bHasCompleteClassicCubeNet = Session.MissingFaces.Num() == 0;
		return Session;
	}

	FHyperTwistVisionShellState MakeClassicCubeWebcamShellState(
		const FHyperTwistVisionSessionConfig& SessionConfig,
		const FHyperTwistVisionReconstructionSession& ReconstructionSession,
		const FString& PreferredTargetFaceHint,
		const FString& PreferredCommittedFaceId
	)
	{
		FHyperTwistVisionShellState ShellState;
		const FHyperTwistVisionShellProfile ShellProfile =
			SessionConfig.ShellProfileDefinition.IsStructurallyValid()
				? SessionConfig.ShellProfileDefinition
				: MakeDefaultClassicCubeWebcamShellProfile(
					!SessionConfig.ShellProfileId.IsEmpty()
						? SessionConfig.ShellProfileId
						: TEXT("classic-cube-webcam-shell-v1")
				);
		const FHyperTwistVisionLocaleOption ActiveLocaleOption = ResolveVisionLocaleOption(
			ShellProfile.SupportedLocales,
			ShellProfile.DefaultLocaleCode
		);
		ShellState.ShellProfileId = !SessionConfig.ShellProfileId.IsEmpty()
			? SessionConfig.ShellProfileId
			: TEXT("classic-cube-webcam-shell-v1");
		ShellState.LocaleCode = ActiveLocaleOption.LocaleCode;
		ShellState.LocaleDisplayLabel = ActiveLocaleOption.DisplayLabel;
		ShellState.ActiveLocaleScriptDirectionId = ActiveLocaleOption.ScriptDirectionId;
		ShellState.ActiveLocaleTextFlowProfileId = ActiveLocaleOption.TextFlowProfileId;
		ShellState.ActiveLocalePresentationProfileId = ActiveLocaleOption.PresentationProfileId;
		ShellState.FontReviewProfileId = ShellProfile.FontReviewProfileId;
		ShellState.ActiveFontReviewDescriptorId = ActiveLocaleOption.FontReviewDescriptorId;
		ShellState.bActiveLocaleRequiresComplexTextShaping =
			ActiveLocaleOption.bRequiresComplexTextShaping;
		ShellState.bBundledFontAssetDeferred = ActiveLocaleOption.bBundledFontAssetDeferred;
		ShellState.TargetSideCount = 6;
		ShellState.TargetFaceHint = !PreferredTargetFaceHint.IsEmpty() ? PreferredTargetFaceHint : TEXT("F");
		ShellState.LastCommittedFaceId = PreferredCommittedFaceId;
		ShellState.CalibrationProfileId = !SessionConfig.CalibrationProfile.IsEmpty()
			? SessionConfig.CalibrationProfile
			: SessionConfig.CalibrationProfileDefinition.ProfileId;
		for (const FHyperTwistVisionLocaleOption& LocaleOption : ShellProfile.SupportedLocales)
		{
			ShellState.AvailableLocaleCodes.AddUnique(LocaleOption.LocaleCode);
		}

		if (ReconstructionSession.IsStructurallyValid())
		{
			ShellState.ScannedSideCount = FMath::Max(0, ReconstructionSession.TotalCommittedFaceCount);
			for (const FHyperTwistVisionCommittedFaceState& FaceState : ReconstructionSession.CommittedFaces)
			{
				if (!FaceState.FaceId.IsEmpty())
				{
					ShellState.CapturedFaceIds.Add(FaceState.FaceId);
				}
			}

			if (ShellState.TargetFaceHint.IsEmpty() && ReconstructionSession.MissingFaces.Num() > 0)
			{
				ShellState.TargetFaceHint = ReconstructionSession.MissingFaces[0];
			}

			if (ShellState.LastCommittedFaceId.IsEmpty() && ReconstructionSession.CommittedFaces.Num() > 0)
			{
				ShellState.LastCommittedFaceId = ReconstructionSession.CommittedFaces.Last().FaceId;
			}
		}

		return ShellState;
	}

	FHyperTwistVisionBrowserShellState MakeClassicCubeBrowserShellState(
		const FHyperTwistVisionSessionConfig& SessionConfig,
		const FHyperTwistVisionReconstructionSession& ReconstructionSession,
		const FHyperTwistVisionFaceObservation& ObservedFace
	)
	{
		FHyperTwistVisionBrowserShellState BrowserShellState;
		const FHyperTwistVisionBrowserShellProfile BrowserShellProfile =
			SessionConfig.BrowserShellProfileDefinition.IsStructurallyValid()
				? SessionConfig.BrowserShellProfileDefinition
				: MakeDefaultClassicCubeBrowserShellProfile(
					!SessionConfig.BrowserShellProfileId.IsEmpty()
						? SessionConfig.BrowserShellProfileId
						: TEXT("classic-cube-browser-shell-v1")
				);

		BrowserShellState.BrowserShellProfileId = BrowserShellProfile.BrowserShellProfileId;
		BrowserShellState.TransportKind = BrowserShellProfile.TransportKind;
		BrowserShellState.TransportEndpoint = BrowserShellProfile.TransportEndpoint;
		BrowserShellState.CaptureIntervalMs = BrowserShellProfile.CaptureIntervalMs;
		BrowserShellState.BrowserAssetReviewProfileId = BrowserShellProfile.BrowserAssetReviewProfileId;
		BrowserShellState.CubeDimension = 3;
		BrowserShellState.ExpectedFaceCount = 6;
		BrowserShellState.CommittedFaceCount = ReconstructionSession.IsStructurallyValid()
			? FMath::Max(0, ReconstructionSession.TotalCommittedFaceCount)
			: 0;
		BrowserShellState.TargetFaceHint = !ObservedFace.FaceId.IsEmpty()
			? NormalizeBrowserFaceHint(ObservedFace.FaceId)
			: TEXT("F");
		const FHyperTwistVisionBrowserAssetReviewDescriptor ActiveAssetReview =
			ResolveBrowserAssetReviewDescriptor(
				BrowserShellProfile.SupportedBrowserAssetReviews,
				BrowserShellProfile.DefaultBrowserAssetReviewDescriptorId
			);
		BrowserShellState.ActiveBrowserAssetReviewDescriptorId =
			ActiveAssetReview.BrowserAssetReviewDescriptorId;
		BrowserShellState.bBundledBrowserAssetDeferred =
			!ActiveAssetReview.bBundledWithCodeDistribution;
		BrowserShellState.bTransportRouteReady = true;
		BrowserShellState.bPlaybackDeferred = !BrowserShellProfile.bSupportsPlaybackStage;
		BrowserShellState.bSnapshotReady = ObservedFace.IsStructurallyValid() && ObservedFace.bCommitReady;

		if (ReconstructionSession.bHasCompleteClassicCubeNet)
		{
			BrowserShellState.ActiveStageId = TEXT("cube-edit");
			BrowserShellState.bVideoStreamVisible = false;
			BrowserShellState.bManualCubeEditVisible = true;
			BrowserShellState.bManualCubeEditReady = true;
		}
		else
		{
			BrowserShellState.ActiveStageId = TEXT("video-stream");
			BrowserShellState.bVideoStreamVisible = true;
			BrowserShellState.bManualCubeEditVisible = false;
			BrowserShellState.bManualCubeEditReady = false;
		}

		if (BrowserShellState.TargetFaceHint.IsEmpty()
			&& ReconstructionSession.IsStructurallyValid()
			&& ReconstructionSession.MissingFaces.Num() > 0)
		{
			BrowserShellState.TargetFaceHint =
				NormalizeBrowserFaceHint(ReconstructionSession.MissingFaces[0]);
		}

		return BrowserShellState;
	}

	FHyperTwistSpeechMicrophoneShellProfile MakeDefaultCoachCommandMicrophoneShellProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechMicrophoneShellProfile Profile;
		Profile.MicrophoneShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("microphone-overlay");
		Profile.CaptureMode = TEXT("vad-gated-short-command");
		Profile.StepWindowMs = 3000;
		Profile.CaptureWindowMs = 10000;
		Profile.KeepWindowMs = 200;
	Profile.AudioContextTokens = 0;
	Profile.VadThreshold = 0.6f;
	Profile.HighPassFrequencyHz = 100.0f;
	Profile.bKeepContextBetweenChunks = false;
	Profile.bSupportsStreamingPreview = true;
	Profile.bSupportsManualCommit = true;
	Profile.PermissionContractId = TEXT("device-permission-shell-v1");
	Profile.CaptureRouteContractId = TEXT("capture-route-readiness-shell-v1");
	Profile.PermissionRequestActionId = TEXT("request-microphone-permission");
	Profile.CaptureRouteRetryActionId = TEXT("retry-capture-route");
	Profile.bSupportsPermissionRequest = true;
	Profile.bSupportsCaptureRouteRetry = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("microphone-status-readout"), TEXT("status-readout"), TEXT("top-left"), true);
		AddPanel(TEXT("vad-meter"), TEXT("level-meter"), TEXT("left-stack-below-status"), true);
		AddPanel(TEXT("transcript-preview"), TEXT("transcript-preview"), TEXT("bottom-left"), true);
		AddPanel(TEXT("command-hints"), TEXT("command-hints"), TEXT("top-right"), true);

		AddAction(TEXT("pause-microphone-capture"), TEXT("P"), TEXT("microphone-status-readout"));
		AddAction(TEXT("resume-microphone-capture"), TEXT("R"), TEXT("microphone-status-readout"));
		AddAction(TEXT("commit-transcript"), TEXT("Enter"), TEXT("transcript-preview"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechDevicePermissionWorkflowProfile
	MakeDefaultSpeechDevicePermissionWorkflowProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechDevicePermissionWorkflowProfile Profile;
		Profile.DevicePermissionWorkflowProfileId = ProfileId;
		Profile.WorkflowKind = TEXT("operator-device-permission-workflow");
		Profile.PermissionContractId = TEXT("device-permission-workflow-v1");
		Profile.SettingsHandoffContractId = TEXT("device-permission-settings-handoff-v1");
		Profile.PermissionRecheckContractId = TEXT("device-permission-recheck-v1");
		Profile.PermissionRequestActionId = TEXT("request-microphone-permission");
		Profile.OpenSettingsActionId = TEXT("open-microphone-privacy-settings");
		Profile.PermissionRecheckActionId = TEXT("recheck-microphone-permission");
		Profile.bSupportsPermissionRequest = true;
		Profile.bSupportsSettingsHandoff = true;
		Profile.bSupportsPermissionRecheck = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("permission-workflow-summary-card"), TEXT("permission-workflow-summary-card"), TEXT("top-left"), true);
		AddPanel(TEXT("permission-settings-handoff-card"), TEXT("permission-settings-handoff-card"), TEXT("left-stack-below-summary"), true);
		AddPanel(TEXT("permission-recheck-card"), TEXT("permission-recheck-card"), TEXT("right-stack-aligned-summary"), true);

		AddAction(TEXT("request-microphone-permission"), TEXT("P"), TEXT("permission-workflow-summary-card"));
		AddAction(TEXT("open-microphone-privacy-settings"), TEXT("S"), TEXT("permission-settings-handoff-card"));
		AddAction(TEXT("recheck-microphone-permission"), TEXT("R"), TEXT("permission-recheck-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechNativeCaptureRouteWorkflowProfile
	MakeDefaultSpeechNativeCaptureRouteWorkflowProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechNativeCaptureRouteWorkflowProfile Profile;
		Profile.NativeCaptureRouteWorkflowProfileId = ProfileId;
		Profile.WorkflowKind = TEXT("first-party-native-capture-route-workflow");
		Profile.OwnershipContractId = TEXT("native-capture-route-ownership-v1");
		Profile.PreparationContractId = TEXT("native-capture-route-preparation-v1");
		Profile.SessionReopenContractId = TEXT("native-capture-route-session-reopen-v1");
		Profile.RouteInspectActionId = TEXT("inspect-native-capture-route");
		Profile.PreparationRetryActionId = TEXT("retry-capture-route");
		Profile.SessionReopenActionId = TEXT("reopen-speech-session");
		Profile.PermissionDependencyActionId = TEXT("resolve-device-permission-workflow");
		Profile.bSupportsRouteInspect = true;
		Profile.bSupportsPreparationRetry = true;
		Profile.bSupportsSessionReopen = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("capture-route-ownership-summary-card"), TEXT("capture-route-ownership-summary-card"), TEXT("top-left"), true);
		AddPanel(TEXT("capture-route-preparation-card"), TEXT("capture-route-preparation-card"), TEXT("left-stack-below-summary"), true);
		AddPanel(TEXT("capture-route-session-reopen-card"), TEXT("capture-route-session-reopen-card"), TEXT("right-stack-aligned-summary"), true);

		AddAction(TEXT("inspect-native-capture-route"), TEXT("I"), TEXT("capture-route-ownership-summary-card"));
		AddAction(TEXT("retry-capture-route"), TEXT("R"), TEXT("capture-route-preparation-card"));
		AddAction(TEXT("reopen-speech-session"), TEXT("O"), TEXT("capture-route-session-reopen-card"));
		AddAction(TEXT("resolve-device-permission-workflow"), TEXT("P"), TEXT("capture-route-ownership-summary-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechNativeCaptureRouteShellProfile
	MakeDefaultSpeechNativeCaptureRouteShellProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechNativeCaptureRouteShellProfile Profile;
		Profile.NativeCaptureRouteShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("operator-native-capture-route-workflow");
		Profile.OwnershipSummarySurfaceMode = TEXT("capture-route-ownership-summary-card");
		Profile.PreparationSurfaceMode = TEXT("capture-route-preparation-card");
		Profile.SessionReopenSurfaceMode = TEXT("capture-route-session-reopen-card");
		Profile.RouteInspectActionId = TEXT("inspect-native-capture-route");
		Profile.PreparationRetryActionId = TEXT("retry-capture-route");
		Profile.SessionReopenActionId = TEXT("reopen-speech-session");
		Profile.PermissionDependencyActionId = TEXT("resolve-device-permission-workflow");
		Profile.bSupportsOwnershipSummaryCard = true;
		Profile.bSupportsPreparationCard = true;
		Profile.bSupportsSessionReopenCard = true;
		Profile.bSupportsPermissionDependencyBanner = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("capture-route-ownership-summary-card"), TEXT("capture-route-ownership-summary-card"), TEXT("top-left"), true);
		AddPanel(TEXT("capture-route-preparation-card"), TEXT("capture-route-preparation-card"), TEXT("left-stack-below-summary"), true);
		AddPanel(TEXT("capture-route-session-reopen-card"), TEXT("capture-route-session-reopen-card"), TEXT("right-stack-aligned-summary"), true);

		AddAction(TEXT("inspect-native-capture-route"), TEXT("I"), TEXT("capture-route-ownership-summary-card"));
		AddAction(TEXT("retry-capture-route"), TEXT("R"), TEXT("capture-route-preparation-card"));
		AddAction(TEXT("reopen-speech-session"), TEXT("O"), TEXT("capture-route-session-reopen-card"));
		AddAction(TEXT("resolve-device-permission-workflow"), TEXT("P"), TEXT("capture-route-ownership-summary-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechExternalDictationShellProfile
	MakeDefaultSpeechExternalDictationShellProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechExternalDictationShellProfile Profile;
		Profile.ExternalDictationShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("operator-external-dictation-shell");
		Profile.TranscriptHistorySurfaceMode = TEXT("rolling-transcript-history");
		Profile.OutputRoutingSurfaceMode = TEXT("clipboard-typing-script-routing");
		Profile.PostProcessOverlaySurfaceMode = TEXT("transcript-post-process-overlay");
		Profile.GlobalHotkeySurfaceMode = TEXT("platform-scoped-dictation-shortcut-lifecycle");
		Profile.InputDeviceSurfaceMode = TEXT("selected-input-device-cycle");
		Profile.OutputDeviceSurfaceMode = TEXT("selected-output-device-cycle");
		Profile.MuteSurfaceMode = TEXT("mute-while-recording-toggle");
		Profile.MicrophoneModeSurfaceMode = TEXT("lazy-close-and-always-on-mode");
		Profile.LocalModelCatalogSurfaceMode = TEXT("local-model-catalog-review");
		Profile.ModelIntegritySurfaceMode = TEXT("payload-integrity-review");
		Profile.ModelUnloadSurfaceMode = TEXT("sidecar-model-unload-policy");
		Profile.StartCaptureActionId = TEXT("start-external-dictation-capture");
		Profile.CancelCaptureActionId = TEXT("cancel-external-dictation-capture");
		Profile.CycleOutputRouteActionId = TEXT("cycle-external-dictation-output-route");
		Profile.CopyTranscriptActionId = TEXT("copy-latest-dictation-transcript");
		Profile.PasteTranscriptActionId = TEXT("paste-latest-dictation-transcript");
		Profile.ScriptDispatchActionId = TEXT("dispatch-dictation-script-output");
		Profile.TogglePostProcessOverlayActionId =
			TEXT("toggle-dictation-post-process-overlay");
		Profile.ReopenSpeechSessionActionId = TEXT("reopen-speech-session");
		Profile.RouteInspectActionId = TEXT("inspect-provider-route");
		Profile.InspectGlobalHotkeyActionId = TEXT("inspect-dictation-global-hotkey");
		Profile.CycleInputDeviceActionId = TEXT("cycle-dictation-input-device");
		Profile.CycleOutputDeviceActionId = TEXT("cycle-dictation-output-device");
		Profile.ToggleMuteWhileRecordingActionId =
			TEXT("toggle-dictation-mute-while-recording");
		Profile.ToggleMicrophoneModeActionId = TEXT("toggle-dictation-microphone-mode");
		Profile.InspectLocalModelCatalogActionId = TEXT("inspect-local-model-catalog");
		Profile.ReviewLocalModelIntegrityActionId = TEXT("review-local-model-integrity");
		Profile.ReviewLocalModelUnloadPolicyActionId =
			TEXT("review-local-model-unload-policy");
		Profile.PrimaryHotkeyBindingLabel = TEXT("ctrl+space");
		Profile.PostProcessHotkeyBindingLabel = TEXT("ctrl+shift+space");
		Profile.RetainedHistoryEntryLimit = 12;
		Profile.bSupportsTranscriptHistoryTimeline = true;
		Profile.bSupportsClipboardRouting = true;
		Profile.bSupportsTypingRouting = true;
		Profile.bSupportsScriptDispatchRouting = true;
		Profile.bSupportsTranscriptPostProcessOverlay = true;
		Profile.bSupportsGlobalHotkeyLifecycle = true;
		Profile.bSupportsInputDeviceSelection = true;
		Profile.bSupportsOutputDeviceSelection = true;
		Profile.bSupportsMuteWhileRecordingToggle = true;
		Profile.bSupportsAlwaysOnMicrophoneMode = true;
		Profile.bSupportsClamshellInputFallback = true;
		Profile.bSupportsLazyCloseLifecycle = true;
		Profile.bSupportsLocalModelCatalogReview = true;
		Profile.bSupportsModelIntegrityReview = true;
		Profile.bSupportsModelUnloadPolicyReview = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("dictation-history-card"), TEXT("dictation-history-card"), TEXT("top-left"), true);
		AddPanel(TEXT("dictation-output-routing-card"), TEXT("dictation-output-routing-card"), TEXT("top-right"), true);
		AddPanel(TEXT("dictation-post-process-card"), TEXT("dictation-post-process-card"), TEXT("right-stack-below-routing"), true);
		AddPanel(TEXT("dictation-readiness-card"), TEXT("dictation-readiness-card"), TEXT("left-stack-below-history"), true);
		AddPanel(TEXT("dictation-hotkey-card"), TEXT("dictation-hotkey-card"), TEXT("left-stack-below-readiness"), true);
		AddPanel(TEXT("dictation-device-card"), TEXT("dictation-device-card"), TEXT("right-stack-below-post-process"), true);
		AddPanel(TEXT("dictation-audio-mode-card"), TEXT("dictation-audio-mode-card"), TEXT("right-stack-below-device"), true);
		AddPanel(TEXT("dictation-model-catalog-card"), TEXT("dictation-model-catalog-card"), TEXT("left-stack-below-hotkey"), true);
		AddPanel(TEXT("dictation-model-integrity-card"), TEXT("dictation-model-integrity-card"), TEXT("right-stack-below-audio-mode"), true);
		AddPanel(TEXT("dictation-model-unload-card"), TEXT("dictation-model-unload-card"), TEXT("right-stack-below-model-integrity"), true);

		AddAction(TEXT("start-external-dictation-capture"), TEXT("Space"), TEXT("dictation-readiness-card"));
		AddAction(TEXT("cancel-external-dictation-capture"), TEXT("Escape"), TEXT("dictation-readiness-card"));
		AddAction(TEXT("cycle-external-dictation-output-route"), TEXT("Tab"), TEXT("dictation-output-routing-card"));
		AddAction(TEXT("copy-latest-dictation-transcript"), TEXT("C"), TEXT("dictation-history-card"));
		AddAction(TEXT("paste-latest-dictation-transcript"), TEXT("V"), TEXT("dictation-output-routing-card"));
		AddAction(TEXT("dispatch-dictation-script-output"), TEXT("R"), TEXT("dictation-output-routing-card"));
		AddAction(TEXT("toggle-dictation-post-process-overlay"), TEXT("P"), TEXT("dictation-post-process-card"));
		AddAction(TEXT("reopen-speech-session"), TEXT("O"), TEXT("dictation-readiness-card"));
		AddAction(TEXT("inspect-provider-route"), TEXT("I"), TEXT("dictation-readiness-card"));
		AddAction(TEXT("inspect-dictation-global-hotkey"), TEXT("Ctrl+Space"), TEXT("dictation-hotkey-card"));
		AddAction(TEXT("cycle-dictation-input-device"), TEXT("Alt+]"), TEXT("dictation-device-card"));
		AddAction(TEXT("cycle-dictation-output-device"), TEXT("Alt+["), TEXT("dictation-device-card"));
		AddAction(TEXT("toggle-dictation-mute-while-recording"), TEXT("M"), TEXT("dictation-audio-mode-card"));
		AddAction(TEXT("toggle-dictation-microphone-mode"), TEXT("A"), TEXT("dictation-audio-mode-card"));
		AddAction(TEXT("inspect-local-model-catalog"), TEXT("L"), TEXT("dictation-model-catalog-card"));
		AddAction(TEXT("review-local-model-integrity"), TEXT("K"), TEXT("dictation-model-integrity-card"));
		AddAction(TEXT("review-local-model-unload-policy"), TEXT("U"), TEXT("dictation-model-unload-card"));
		return Profile;
	}

	FHyperTwistSpeechUsageCostDashboardShellProfile MakeDefaultSpeechUsageCostDashboardShellProfile(
		const FString& ProfileId
	)
	{
		FHyperTwistSpeechUsageCostDashboardShellProfile Profile;
		Profile.DashboardShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("operator-usage-cost-dashboard");
		Profile.UsageSurfaceMode = TEXT("normalized-usage-summary-card");
		Profile.CostSurfaceMode = TEXT("estimate-first-cost-card");
		Profile.EscalationBannerMode = TEXT("route-and-budget-posture-banner");
		Profile.RefreshActionId = TEXT("refresh-provider-usage-cost-dashboard");
		Profile.RouteInspectActionId = TEXT("inspect-provider-route");
		Profile.BudgetInspectActionId = TEXT("review-provider-budget");
		Profile.bSupportsProviderSummary = true;
		Profile.bSupportsEstimateBadges = true;
		Profile.bSupportsQuotaEscalationBanner = true;
		Profile.bSupportsRouteDiagnostics = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("provider-summary-card"), TEXT("provider-summary-card"), TEXT("top-left"), true);
		AddPanel(TEXT("usage-meter-card"), TEXT("usage-meter-card"), TEXT("left-stack-below-provider"), true);
		AddPanel(TEXT("cost-estimate-card"), TEXT("cost-estimate-card"), TEXT("top-right"), true);
		AddPanel(TEXT("quota-state-card"), TEXT("quota-state-card"), TEXT("right-stack-below-cost"), true);
		AddPanel(TEXT("route-diagnostics-card"), TEXT("route-diagnostics-card"), TEXT("bottom-right"), true);

		AddAction(TEXT("refresh-provider-usage-cost-dashboard"), TEXT("F5"), TEXT("provider-summary-card"));
		AddAction(TEXT("inspect-provider-route"), TEXT("P"), TEXT("route-diagnostics-card"));
		AddAction(TEXT("review-provider-budget"), TEXT("B"), TEXT("quota-state-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechUsageCostHistoryExportShellProfile
	MakeDefaultSpeechUsageCostHistoryExportShellProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechUsageCostHistoryExportShellProfile Profile;
		Profile.HistoryExportShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("operator-usage-cost-history-export");
		Profile.HistorySurfaceMode = TEXT("rolling-usage-cost-snapshot-history");
		Profile.ExportSurfaceMode = TEXT("first-party-summary-preview");
		Profile.RefreshActionId = TEXT("refresh-provider-usage-cost-history");
		Profile.ExportPreviewActionId = TEXT("preview-provider-usage-cost-export");
		Profile.CopySummaryActionId = TEXT("copy-provider-usage-cost-summary");
		Profile.RouteInspectActionId = TEXT("inspect-provider-route");
		Profile.BudgetInspectActionId = TEXT("review-provider-budget");
		Profile.RetainedHistoryEntryLimit = 12;
		Profile.bSupportsHistoryTimeline = true;
		Profile.bSupportsExportPreview = true;
		Profile.bSupportsCopySummary = true;
		Profile.bSupportsEstimateWatermark = true;
		Profile.bPreservesFirstPartySummaryOwnership = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("history-timeline-card"), TEXT("history-timeline-card"), TEXT("top-left"), true);
		AddPanel(TEXT("history-summary-card"), TEXT("history-summary-card"), TEXT("left-stack-below-history"), true);
		AddPanel(TEXT("export-preview-card"), TEXT("export-preview-card"), TEXT("top-right"), true);
		AddPanel(TEXT("export-readiness-card"), TEXT("export-readiness-card"), TEXT("right-stack-below-preview"), true);

		AddAction(TEXT("refresh-provider-usage-cost-history"), TEXT("F6"), TEXT("history-timeline-card"));
		AddAction(TEXT("preview-provider-usage-cost-export"), TEXT("E"), TEXT("export-preview-card"));
		AddAction(TEXT("copy-provider-usage-cost-summary"), TEXT("C"), TEXT("export-readiness-card"));
		AddAction(TEXT("inspect-provider-route"), TEXT("P"), TEXT("history-summary-card"));
		AddAction(TEXT("review-provider-budget"), TEXT("B"), TEXT("export-readiness-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechProviderReceiptReviewShellProfile
	MakeDefaultSpeechProviderReceiptReviewShellProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechProviderReceiptReviewShellProfile Profile;
		Profile.ReceiptReviewShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("operator-provider-receipt-review");
		Profile.ReceiptSurfaceMode = TEXT("posted-charge-review");
		Profile.VarianceSurfaceMode = TEXT("estimate-versus-posted-charge");
		Profile.RefreshActionId = TEXT("refresh-provider-receipt-review");
		Profile.PostedChargeInspectActionId = TEXT("inspect-provider-posted-charges");
		Profile.VarianceReviewActionId = TEXT("review-provider-charge-variance");
		Profile.RouteInspectActionId = TEXT("inspect-provider-route");
		Profile.BudgetInspectActionId = TEXT("review-provider-budget");
		Profile.RetainedReceiptEntryLimit = 12;
		Profile.bSupportsReceiptTimeline = true;
		Profile.bSupportsPostedChargeInspection = true;
		Profile.bSupportsVarianceReview = true;
		Profile.bSupportsEstimateOnlyFallback = true;
		Profile.bPreservesFirstPartyReceiptInspectionOwnership = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("receipt-timeline-card"), TEXT("receipt-timeline-card"), TEXT("top-left"), true);
		AddPanel(TEXT("posted-charge-summary-card"), TEXT("posted-charge-summary-card"), TEXT("left-stack-below-receipts"), true);
		AddPanel(TEXT("variance-review-card"), TEXT("variance-review-card"), TEXT("top-right"), true);
		AddPanel(TEXT("receipt-readiness-card"), TEXT("receipt-readiness-card"), TEXT("right-stack-below-variance"), true);

		AddAction(TEXT("refresh-provider-receipt-review"), TEXT("F7"), TEXT("receipt-timeline-card"));
		AddAction(TEXT("inspect-provider-posted-charges"), TEXT("I"), TEXT("posted-charge-summary-card"));
		AddAction(TEXT("review-provider-charge-variance"), TEXT("V"), TEXT("variance-review-card"));
		AddAction(TEXT("inspect-provider-route"), TEXT("P"), TEXT("receipt-readiness-card"));
		AddAction(TEXT("review-provider-budget"), TEXT("B"), TEXT("receipt-readiness-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechProviderBillingSettlementShellProfile
	MakeDefaultSpeechProviderBillingSettlementShellProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechProviderBillingSettlementShellProfile Profile;
		Profile.BillingSettlementShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("operator-provider-billing-settlement");
		Profile.SettlementSurfaceMode = TEXT("posted-charge-settlement-assessment");
		Profile.InvoiceReconciliationMode = TEXT("estimate-versus-provider-invoice");
		Profile.RefreshActionId = TEXT("refresh-provider-billing-settlement");
		Profile.InvoiceReconciliationActionId = TEXT("inspect-provider-invoice-reconciliation");
		Profile.SettlementReadinessActionId = TEXT("review-provider-settlement-readiness");
		Profile.RouteInspectActionId = TEXT("inspect-provider-route");
		Profile.BudgetInspectActionId = TEXT("review-provider-budget");
		Profile.RetainedSettlementEntryLimit = 12;
		Profile.bSupportsSettlementTimeline = true;
		Profile.bSupportsInvoiceReconciliation = true;
		Profile.bSupportsSettlementReadinessReview = true;
		Profile.bSupportsEstimateOnlyFallback = true;
		Profile.bPreservesFirstPartySettlementOwnership = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("settlement-timeline-card"), TEXT("settlement-timeline-card"), TEXT("top-left"), true);
		AddPanel(TEXT("invoice-reconciliation-card"), TEXT("invoice-reconciliation-card"), TEXT("top-right"), true);
		AddPanel(TEXT("settlement-summary-card"), TEXT("settlement-summary-card"), TEXT("left-stack-below-settlement"), true);
		AddPanel(TEXT("settlement-readiness-card"), TEXT("settlement-readiness-card"), TEXT("right-stack-below-reconciliation"), true);

		AddAction(TEXT("refresh-provider-billing-settlement"), TEXT("F8"), TEXT("settlement-timeline-card"));
		AddAction(TEXT("inspect-provider-invoice-reconciliation"), TEXT("R"), TEXT("invoice-reconciliation-card"));
		AddAction(TEXT("review-provider-settlement-readiness"), TEXT("S"), TEXT("settlement-readiness-card"));
		AddAction(TEXT("inspect-provider-route"), TEXT("P"), TEXT("settlement-summary-card"));
		AddAction(TEXT("review-provider-budget"), TEXT("B"), TEXT("settlement-readiness-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechProviderSettlementExceptionShellProfile
	MakeDefaultSpeechProviderSettlementExceptionShellProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechProviderSettlementExceptionShellProfile Profile;
		Profile.SettlementExceptionShellProfileId = ProfileId;
		Profile.ShellKind = TEXT("operator-provider-settlement-exception");
		Profile.ExceptionSurfaceMode = TEXT("settlement-exception-triage");
		Profile.ExternalPortalHandoffMode = TEXT("reference-only-provider-portal-handoff");
		Profile.RefreshActionId = TEXT("refresh-provider-settlement-exceptions");
		Profile.ExceptionInspectActionId = TEXT("inspect-provider-settlement-exception");
		Profile.ExternalPortalHandoffActionId =
			TEXT("review-provider-external-portal-handoff");
		Profile.RouteInspectActionId = TEXT("inspect-provider-route");
		Profile.BudgetInspectActionId = TEXT("review-provider-budget");
		Profile.RetainedExceptionEntryLimit = 12;
		Profile.bSupportsExceptionTimeline = true;
		Profile.bSupportsExternalPortalHandoff = true;
		Profile.bSupportsSettlementExceptionReview = true;
		Profile.bSupportsPendingChargeExceptions = true;
		Profile.bPreservesFirstPartyHandoffOwnership = true;

		auto AddPanel = [&Profile](
			const TCHAR* PanelId,
			const TCHAR* PanelKind,
			const TCHAR* AnchorId,
			const bool bVisibleByDefault
		)
		{
			FHyperTwistSpeechShellPanelLayout Panel;
			Panel.PanelId = PanelId;
			Panel.PanelKind = PanelKind;
			Panel.AnchorId = AnchorId;
			Panel.bVisibleByDefault = bVisibleByDefault;
			Profile.Panels.Add(Panel);
		};

		auto AddAction = [&Profile](
			const TCHAR* ActionId,
			const TCHAR* InputBinding,
			const TCHAR* SurfaceId
		)
		{
			FHyperTwistSpeechShellActionBinding ActionBinding;
			ActionBinding.ActionId = ActionId;
			ActionBinding.InputBinding = InputBinding;
			ActionBinding.SurfaceId = SurfaceId;
			Profile.ActionBindings.Add(ActionBinding);
		};

		AddPanel(TEXT("settlement-exception-timeline-card"), TEXT("settlement-exception-timeline-card"), TEXT("top-left"), true);
		AddPanel(TEXT("external-portal-handoff-card"), TEXT("external-portal-handoff-card"), TEXT("top-right"), true);
		AddPanel(TEXT("exception-summary-card"), TEXT("exception-summary-card"), TEXT("left-stack-below-settlement"), true);
		AddPanel(TEXT("exception-readiness-card"), TEXT("exception-readiness-card"), TEXT("right-stack-below-handoff"), true);

		AddAction(TEXT("refresh-provider-settlement-exceptions"), TEXT("F9"), TEXT("settlement-exception-timeline-card"));
		AddAction(TEXT("inspect-provider-settlement-exception"), TEXT("E"), TEXT("settlement-exception-timeline-card"));
		AddAction(TEXT("review-provider-external-portal-handoff"), TEXT("H"), TEXT("external-portal-handoff-card"));
		AddAction(TEXT("inspect-provider-route"), TEXT("P"), TEXT("exception-summary-card"));
		AddAction(TEXT("review-provider-budget"), TEXT("B"), TEXT("exception-readiness-card"));
		AddAction(TEXT("close-speech-session"), TEXT("Escape"), TEXT("session-root"));
		return Profile;
	}

	FHyperTwistSpeechModelPayloadDescriptor MakeSpeechModelPayloadDescriptor(
		const TCHAR* PayloadId,
		const TCHAR* PayloadKind,
		const TCHAR* ModelFamily,
		const TCHAR* VariantId,
		const TCHAR* ArtifactName,
		const TCHAR* RelativePathHint,
		const TCHAR* SourceDocumentPath,
		const TCHAR* AcquisitionMode,
		const TCHAR* IntegrityCheckKind,
		const TCHAR* IntegrityCheckValue,
		const int32 ApproximateSizeMiB,
		const bool bOptionalForSession
	)
	{
		FHyperTwistSpeechModelPayloadDescriptor Descriptor;
		Descriptor.PayloadId = PayloadId;
		Descriptor.PayloadKind = PayloadKind;
		Descriptor.ModelFamily = ModelFamily;
		Descriptor.VariantId = VariantId;
		Descriptor.ArtifactName = ArtifactName;
		Descriptor.RelativePathHint = RelativePathHint;
		Descriptor.SourceDocumentPath = SourceDocumentPath;
		Descriptor.AcquisitionMode = AcquisitionMode;
		Descriptor.IntegrityCheckKind = IntegrityCheckKind;
		Descriptor.IntegrityCheckValue = IntegrityCheckValue;
		Descriptor.ApproximateSizeMiB = ApproximateSizeMiB;
		Descriptor.bOptionalForSession = bOptionalForSession;
		Descriptor.bUserSuppliedOnly = true;
		Descriptor.bBundledWithCodeDistribution = false;
		return Descriptor;
	}

	FHyperTwistSpeechPayloadCustodyProfile MakeDefaultSpeechPayloadCustodyProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechPayloadCustodyProfile Profile;
		Profile.PayloadCustodyProfileId = ProfileId;
		Profile.PayloadReviewPosture = TEXT("independent-payload-review-required");
		Profile.ShippingPosture = TEXT("not-shipped-in-packet");
		Profile.DownloadWorkflowPosture = TEXT("deferred-out-of-packet");
		Profile.ProvisioningPosture = TEXT("user-supplied-or-sidecar-managed");
		Profile.CodeLicenseBoundary = TEXT("code-license-reviewed-separately");
		Profile.bRequiresIndependentPayloadReview = true;
		Profile.bAllowsBundledPayloadRedistribution = false;
		Profile.bAllowsRuntimeDownloadInCurrentPacket = false;
		Profile.bSupportsUserManagedPayloads = true;
		Profile.bSupportsSidecarManagedPayloads = true;
		Profile.bRequiresIntegrityVerification = true;
		Profile.bPreservesProviderNeutrality = true;
		return Profile;
	}

	TArray<FString> MakeDefaultSpeechProviderModelIds()
	{
		return {
			TEXT("speech-model/whisper.cpp/base.en"),
			TEXT("speech-vad/whisper.cpp/silero-v6.2.0")
		};
	}

	TArray<FString> MakeDefaultSpeechProviderCapabilityFlags()
	{
		return {
			TEXT("transcribe"),
			TEXT("vadSegments"),
			TEXT("grammarHints"),
			TEXT("microphoneCaptureShell"),
			TEXT("devicePermissionShell"),
			TEXT("captureRouteReadinessShell"),
			TEXT("captureRouteRetry"),
			TEXT("nativeCaptureRouteWorkflowShell"),
			TEXT("streamingPreview"),
			TEXT("manualTranscriptCommit"),
			TEXT("batchedTranscribe"),
			TEXT("wordTimestamps"),
			TEXT("languageDetection"),
			TEXT("promptHints"),
			TEXT("normalizedUsageEvents"),
			TEXT("normalizedCostEvents"),
			TEXT("quotaRateLimitState"),
			TEXT("providerUsageCostDashboardShell"),
			TEXT("providerQuotaEscalationBanner"),
			TEXT("providerRouteCostDiagnostics"),
			TEXT("captureRouteOwnershipSummaryCard"),
			TEXT("captureRoutePreparationCard"),
			TEXT("captureRouteSessionReopenCard"),
			TEXT("providerUsageCostHistoryShell"),
			TEXT("providerUsageCostExportPreview"),
			TEXT("providerUsageCostSummaryCopy"),
			TEXT("providerReceiptReviewShell"),
			TEXT("providerPostedChargeInspection"),
			TEXT("providerChargeVarianceReview"),
			TEXT("providerBillingSettlementShell"),
			TEXT("providerInvoiceReconciliation"),
			TEXT("providerSettlementReadinessReview"),
			TEXT("providerSettlementExceptionShell"),
			TEXT("providerExternalPortalHandoff"),
			TEXT("providerSettlementExceptionReview")
		};
	}

	TArray<FString> MakeDefaultSpeechRoutingEligibleProviderClasses()
	{
		return {
			TEXT("official-direct-provider"),
			TEXT("openai-compatible-custom-endpoint"),
			TEXT("byok-endpoint"),
			TEXT("managed-gateway-provider"),
			TEXT("local-self-hosted-provider"),
			TEXT("bounded-speech-sidecar-service"),
			TEXT("first-party-mock-provider")
		};
	}

	TArray<FString> MakeDefaultSpeechRoutingEligibleEndpointClasses()
	{
		return {
			TEXT("official-http-api"),
			TEXT("openai-compatible-http-api"),
			TEXT("managed-gateway-http"),
			TEXT("local-self-hosted-http"),
			TEXT("in-process-mock")
		};
	}

	TArray<FString> MakeDefaultSpeechRoutingRequiredCapabilities()
	{
		return {
			TEXT("transcribe"),
			TEXT("grammarHints"),
			TEXT("manualTranscriptCommit")
		};
	}

	TArray<FString> MakeDefaultSpeechRoutingSupportedTaskKinds()
	{
		return {
			TEXT("transcribe")
		};
	}

	TArray<FString> MakeDefaultSpeechUsageMeterKinds()
	{
		return {
			TEXT("audio-seconds"),
			TEXT("request-count"),
			TEXT("session-count")
		};
	}

	TArray<FString> MakeDefaultSpeechUsageCurrencyCodes()
	{
		return {
			TEXT("USD")
		};
	}

	FHyperTwistSpeechProviderProfile MakeMockSpeechProviderProfile()
	{
		FHyperTwistSpeechProviderProfile Profile;
		Profile.ProviderProfileId = TEXT("speech-provider/mock-offline-profile-v1");
		Profile.DisplayLabel = TEXT("Mock Offline Speech");
		Profile.ProviderClass = TEXT("first-party-mock-provider");
		Profile.EndpointClass = TEXT("in-process-mock");
		Profile.EndpointReferenceId = TEXT("speech/provider-profile/mock-offline");
		Profile.EndpointBaseUrl = TEXT("in-process://mock");
		Profile.AuthMaterialSource = TEXT("not-required");
		Profile.AuthReferenceId.Reset();
		Profile.ModelSelectionMode = TEXT("per-profile-model-map");
		Profile.SupportedModelIds = MakeDefaultSpeechProviderModelIds();
		Profile.CapabilityFlags = MakeDefaultSpeechProviderCapabilityFlags();
		Profile.bEnabled = true;
		Profile.bUserLabeled = false;
		Profile.bSupportsEnableDisable = true;
		Profile.bSupportsCustomBaseUrl = false;
		Profile.bPreservesFirstPartyCustody = true;
		return Profile;
	}

	FHyperTwistSpeechProviderProfile MakeLocalHttpSpeechProviderProfile(
		const FString& ProviderLabel,
		const FString& ServiceEndpoint
	)
	{
		FHyperTwistSpeechProviderProfile Profile;
		Profile.ProviderProfileId = TEXT("speech-provider/local-http-sidecar-profile-v1");
		Profile.DisplayLabel = ProviderLabel.IsEmpty() ? TEXT("Local HTTP Speech Sidecar") : ProviderLabel;
		Profile.ProviderClass = TEXT("bounded-speech-sidecar-service");
		Profile.EndpointClass = TEXT("local-self-hosted-http");
		Profile.EndpointReferenceId = TEXT("speech/provider-profile/local-http-sidecar");
		Profile.EndpointBaseUrl = ServiceEndpoint;
		Profile.AuthMaterialSource = TEXT("first-party-out-of-band-secret-reference");
		Profile.AuthReferenceId = TEXT("speech/byok/local-http-sidecar/default");
		Profile.ModelSelectionMode = TEXT("per-profile-model-map");
		Profile.SupportedModelIds = MakeDefaultSpeechProviderModelIds();
		Profile.CapabilityFlags = MakeDefaultSpeechProviderCapabilityFlags();
		Profile.bEnabled = true;
		Profile.bUserLabeled = true;
		Profile.bSupportsEnableDisable = true;
		Profile.bSupportsCustomBaseUrl = true;
		Profile.bPreservesFirstPartyCustody = true;
		return Profile;
	}

	FHyperTwistSpeechProviderRoutingPolicy MakeMockSpeechProviderRoutingPolicy()
	{
		FHyperTwistSpeechProviderRoutingPolicy Policy;
		Policy.ProviderRoutingPolicyId = TEXT("speech-provider-routing/local-offline-mock-first-v1");
		Policy.PolicyKind = TEXT("speech-provider-routing");
		Policy.RouteSelectionMode = TEXT("local-offline-mock-first");
		Policy.FallbackMode = TEXT("fail-closed");
		Policy.WorkflowPolicyState = TEXT("first-party-provider-policy-governed");
		Policy.FailureEscalationMode = TEXT("preserve-local-verification-route");
		Policy.UserOverridePosture = TEXT("client-kind-and-profile-override-supported");
		Policy.EligibleProviderClasses = MakeDefaultSpeechRoutingEligibleProviderClasses();
		Policy.EligibleEndpointClasses = MakeDefaultSpeechRoutingEligibleEndpointClasses();
		Policy.RequiredCapabilityFlags = MakeDefaultSpeechRoutingRequiredCapabilities();
		Policy.SupportedTaskKinds = MakeDefaultSpeechRoutingSupportedTaskKinds();
		Policy.bAllowProviderBackedRoutes = false;
		Policy.bAllowMockVerificationRoutes = true;
		Policy.bAllowOpenAiCompatibleCustomEndpointRoutes = true;
		Policy.bAllowUserLabeledByokRoutes = true;
		Policy.bAllowManagedGatewayRoutes = true;
		Policy.bAllowLocalSelfHostedRoutes = true;
		Policy.bRespectsProfileEnableDisable = true;
		Policy.bAllowFailClosedWhenNoEligibleRoute = true;
		Policy.bAllowHealthPostureFallback = false;
		Policy.bPreservesFirstPartyRoutingOwnership = true;
		Policy.bAllowsDonorOwnedRoutingLanguage = false;
		return Policy;
	}

	FHyperTwistSpeechProviderRoutingPolicy MakeProviderBackedSpeechProviderRoutingPolicy()
	{
		FHyperTwistSpeechProviderRoutingPolicy Policy;
		Policy.ProviderRoutingPolicyId = TEXT("speech-provider-routing/provider-backed-sidecar-first-v1");
		Policy.PolicyKind = TEXT("speech-provider-routing");
		Policy.RouteSelectionMode = TEXT("provider-backed-sidecar-first");
		Policy.FallbackMode = TEXT("health-posture-only");
		Policy.WorkflowPolicyState = TEXT("first-party-provider-policy-governed");
		Policy.FailureEscalationMode = TEXT("fail-closed-and-report-health");
		Policy.UserOverridePosture = TEXT("profile-or-client-kind-override-supported");
		Policy.EligibleProviderClasses = MakeDefaultSpeechRoutingEligibleProviderClasses();
		Policy.EligibleEndpointClasses = MakeDefaultSpeechRoutingEligibleEndpointClasses();
		Policy.RequiredCapabilityFlags = MakeDefaultSpeechRoutingRequiredCapabilities();
		Policy.SupportedTaskKinds = MakeDefaultSpeechRoutingSupportedTaskKinds();
		Policy.bAllowProviderBackedRoutes = true;
		Policy.bAllowMockVerificationRoutes = true;
		Policy.bAllowOpenAiCompatibleCustomEndpointRoutes = true;
		Policy.bAllowUserLabeledByokRoutes = true;
		Policy.bAllowManagedGatewayRoutes = true;
		Policy.bAllowLocalSelfHostedRoutes = true;
		Policy.bRespectsProfileEnableDisable = true;
		Policy.bAllowFailClosedWhenNoEligibleRoute = true;
		Policy.bAllowHealthPostureFallback = true;
		Policy.bPreservesFirstPartyRoutingOwnership = true;
		Policy.bAllowsDonorOwnedRoutingLanguage = false;
		return Policy;
	}

	FHyperTwistSpeechProviderRouteDecision MakeSpeechProviderRouteDecision(
		const FHyperTwistSpeechProviderRoutingPolicy& Policy,
		const FHyperTwistSpeechProviderProfile& Profile,
		const FString& SelectedServiceLaneId,
		const FString& DecisionSource,
		const FString& RouteStateId,
		const FString& DecisionReason,
		const FString& FailureReason,
		const bool bProviderBackedRouteRequested,
		const bool bProviderBackedRouteSelected,
		const bool bUsedFallbackHealthPosture,
		const bool bRouteReady
	)
	{
		FHyperTwistSpeechProviderRouteDecision Decision;
		Decision.RouteDecisionId = FString::Printf(
			TEXT("speech-route-decision/%s"),
			*Profile.ProviderProfileId
		);
		Decision.ProviderRoutingPolicyId = Policy.ProviderRoutingPolicyId;
		Decision.DecisionSource = DecisionSource;
		Decision.RequestedProviderProfileId = Profile.ProviderProfileId;
		Decision.SelectedProviderProfileId = Profile.ProviderProfileId;
		Decision.SelectedProviderClass = Profile.ProviderClass;
		Decision.SelectedEndpointClass = Profile.EndpointClass;
		Decision.SelectedServiceLaneId = SelectedServiceLaneId.IsEmpty()
			? TEXT("speech/python-service")
			: SelectedServiceLaneId;
		Decision.SelectedTransportKind = Profile.EndpointClass.Equals(TEXT("in-process-mock"), ESearchCase::IgnoreCase)
			? TEXT("in-process")
			: TEXT("http");
		Decision.RouteStateId = RouteStateId;
		Decision.DecisionReason = DecisionReason;
		Decision.FailureReason = FailureReason;
		Decision.FallbackMode = Policy.FallbackMode;
		Decision.bProviderBackedRouteRequested = bProviderBackedRouteRequested;
		Decision.bProviderBackedRouteSelected = bProviderBackedRouteSelected;
		Decision.bUsedFallbackHealthPosture = bUsedFallbackHealthPosture;
		Decision.bSelectedProfileEnabled = Profile.bEnabled;
		Decision.bSelectedCustomEndpointRoute =
			Profile.bUserLabeled
			&& Profile.bSupportsCustomBaseUrl
			&& !Profile.EndpointBaseUrl.IsEmpty()
			&& !Profile.EndpointBaseUrl.Contains(TEXT("127.0.0.1"), ESearchCase::IgnoreCase);
		Decision.bRouteReady = bRouteReady;
		return Decision;
	}

	FHyperTwistSpeechUsageCostAccountingProfile MakeDefaultSpeechUsageCostAccountingProfile(
		const FString& ProfileId
	)
	{
		FHyperTwistSpeechUsageCostAccountingProfile Profile;
		Profile.UsageCostAccountingProfileId = ProfileId;
		Profile.AccountingKind = TEXT("normalized-usage-cost-events");
		Profile.UsageAggregationMode = TEXT("session-and-health-summary");
		Profile.CostAggregationMode = TEXT("estimate-first-with-provider-receipt-optional");
		Profile.QuotaVisibilityMode = TEXT("first-party-health-surface");
		Profile.EscalationMode = TEXT("surface-budget-and-quota-state");
		Profile.UserOverridePosture = TEXT("profile-or-session-override-supported");
		Profile.NormalizedMeterKinds = MakeDefaultSpeechUsageMeterKinds();
		Profile.NormalizedCurrencyCodes = MakeDefaultSpeechUsageCurrencyCodes();
		Profile.bSupportsProviderReceiptNormalization = true;
		Profile.bSupportsEstimateOnlyMode = true;
		Profile.bSupportsQuotaSnapshots = true;
		Profile.bSupportsRateLimitSnapshots = true;
		Profile.bPreservesFirstPartyAccountingOwnership = true;
		Profile.bAllowsDonorOwnedCostGovernance = false;
		return Profile;
	}

	FHyperTwistSpeechNormalizedUsageEvent MakeDefaultSpeechUsageEvent(
		const FHyperTwistSpeechUsageCostAccountingProfile& AccountingProfile,
		const FHyperTwistSpeechProviderProfile& ProviderProfile,
		const FString& ServiceLaneId,
		const FString& EventKind,
		const FString& AggregationWindowId,
		const FString& RawEventReferenceId,
		const float ReportedQuantity,
		const float BilledQuantity,
		const bool bDerivedFromProviderReceipt,
		const bool bEstimateOnly
	)
	{
		FHyperTwistSpeechNormalizedUsageEvent Event;
		Event.UsageEventId = FString::Printf(
			TEXT("speech-usage-event/%s"),
			*ProviderProfile.ProviderProfileId
		);
		Event.UsageCostAccountingProfileId = AccountingProfile.UsageCostAccountingProfileId;
		Event.ProviderProfileId = ProviderProfile.ProviderProfileId;
		Event.ServiceLaneId = ServiceLaneId.IsEmpty()
			? TEXT("speech/python-service")
			: ServiceLaneId;
		Event.EventKind = EventKind.IsEmpty()
			? TEXT("bounded-session-usage-summary")
			: EventKind;
		Event.MeterKind = TEXT("audio-seconds");
		Event.UsageUnitKind = TEXT("audio-seconds");
		Event.AggregationWindowId = AggregationWindowId.IsEmpty()
			? TEXT("current-session")
			: AggregationWindowId;
		Event.CapturedAtUtc = TEXT("2026-05-25T00:00:00Z");
		Event.RawEventReferenceId = RawEventReferenceId.IsEmpty()
			? TEXT("speech-session-default")
			: RawEventReferenceId;
		Event.ReportedQuantity = ReportedQuantity;
		Event.BilledQuantity = BilledQuantity;
		Event.bDerivedFromProviderReceipt = bDerivedFromProviderReceipt;
		Event.bEstimateOnly = bEstimateOnly;
		return Event;
	}

	FHyperTwistSpeechNormalizedCostEvent MakeDefaultSpeechCostEvent(
		const FHyperTwistSpeechUsageCostAccountingProfile& AccountingProfile,
		const FHyperTwistSpeechProviderProfile& ProviderProfile,
		const FString& ServiceLaneId,
		const FString& EventKind,
		const FString& AggregationWindowId,
		const float EstimatedCost,
		const float ReportedCost,
		const bool bEstimateOnly,
		const bool bHasProviderPostedCharge
	)
	{
		FHyperTwistSpeechNormalizedCostEvent Event;
		Event.CostEventId = FString::Printf(
			TEXT("speech-cost-event/%s"),
			*ProviderProfile.ProviderProfileId
		);
		Event.UsageCostAccountingProfileId = AccountingProfile.UsageCostAccountingProfileId;
		Event.ProviderProfileId = ProviderProfile.ProviderProfileId;
		Event.ServiceLaneId = ServiceLaneId.IsEmpty()
			? TEXT("speech/python-service")
			: ServiceLaneId;
		Event.EventKind = EventKind.IsEmpty()
			? TEXT("bounded-session-cost-summary")
			: EventKind;
		Event.CurrencyCode = TEXT("USD");
		Event.PricingSourceId = bHasProviderPostedCharge
			? TEXT("provider-posted-charge")
			: TEXT("first-party-estimate");
		Event.AggregationWindowId = AggregationWindowId.IsEmpty()
			? TEXT("current-session")
			: AggregationWindowId;
		Event.CapturedAtUtc = TEXT("2026-05-25T00:00:00Z");
		Event.EstimatedCost = EstimatedCost;
		Event.ReportedCost = ReportedCost;
		Event.bEstimateOnly = bEstimateOnly;
		Event.bHasProviderPostedCharge = bHasProviderPostedCharge;
		return Event;
	}

	TArray<FHyperTwistVisionLocaleOption> MakeQbrSupportedVisionLocales()
	{
		auto MakeLocale = [](
			const TCHAR* LocaleCode,
			const TCHAR* DisplayLabel,
			const TCHAR* ScriptDirectionId,
			const TCHAR* TextFlowProfileId,
			const bool bRequiresComplexTextShaping,
			const TCHAR* FontReviewDescriptorId
		)
		{
			FHyperTwistVisionLocaleOption LocaleOption;
			LocaleOption.LocaleCode = LocaleCode;
			LocaleOption.DisplayLabel = DisplayLabel;
			LocaleOption.GuidanceModeId = TEXT("qbr-locale-guidance-routing-v1");
			LocaleOption.ScriptDirectionId = ScriptDirectionId;
			LocaleOption.TextFlowProfileId = TextFlowProfileId;
			LocaleOption.PresentationProfileId = TEXT("qbr-locale-presentation-v1");
			LocaleOption.FontReviewDescriptorId = FontReviewDescriptorId;
			LocaleOption.bRequiresComplexTextShaping = bRequiresComplexTextShaping;
			LocaleOption.bBundledFontAssetDeferred = true;
			return LocaleOption;
		};

		return {
			MakeLocale(TEXT("en"), TEXT("English"), TEXT("ltr"), TEXT("word-space-delimited"), false, TEXT("font-review/qbr/latin-core")),
			MakeLocale(TEXT("hu"), TEXT("Hungarian"), TEXT("ltr"), TEXT("word-space-delimited"), false, TEXT("font-review/qbr/latin-core")),
			MakeLocale(TEXT("de"), TEXT("Deutsch"), TEXT("ltr"), TEXT("word-space-delimited"), false, TEXT("font-review/qbr/latin-core")),
			MakeLocale(TEXT("fr"), TEXT("French"), TEXT("ltr"), TEXT("word-space-delimited"), false, TEXT("font-review/qbr/latin-core")),
			MakeLocale(TEXT("es"), TEXT("Spanish"), TEXT("ltr"), TEXT("word-space-delimited"), false, TEXT("font-review/qbr/latin-core")),
			MakeLocale(TEXT("nl"), TEXT("Nederlands"), TEXT("ltr"), TEXT("word-space-delimited"), false, TEXT("font-review/qbr/latin-core")),
			MakeLocale(TEXT("zh"), TEXT("简体中文"), TEXT("ltr"), TEXT("cjk-character-wrap"), false, TEXT("font-review/qbr/cjk-simplified")),
			MakeLocale(TEXT("zh-tw"), TEXT("台灣繁體中文"), TEXT("ltr"), TEXT("cjk-character-wrap"), false, TEXT("font-review/qbr/cjk-traditional")),
			MakeLocale(TEXT("ar"), TEXT("العربية"), TEXT("rtl"), TEXT("rtl-word-space-delimited"), true, TEXT("font-review/qbr/arabic-core")),
			MakeLocale(TEXT("fa"), TEXT("فارسی"), TEXT("rtl"), TEXT("rtl-word-space-delimited"), true, TEXT("font-review/qbr/persian-core"))
		};
	}

	TArray<FHyperTwistVisionFontReviewDescriptor> MakeQbrSupportedFontReviews()
	{
		auto MakeFontReview = [](
			const TCHAR* DescriptorId,
			const TCHAR* LocaleCode,
			const TCHAR* FontFamilyId,
			const TCHAR* ScriptCoverageProfileId,
			const TCHAR* ReviewDocumentPath
		)
		{
			FHyperTwistVisionFontReviewDescriptor Descriptor;
			Descriptor.FontReviewDescriptorId = DescriptorId;
			Descriptor.LocaleCode = LocaleCode;
			Descriptor.FontFamilyId = FontFamilyId;
			Descriptor.ScriptCoverageProfileId = ScriptCoverageProfileId;
			Descriptor.ReviewDocumentPath = ReviewDocumentPath;
			Descriptor.AcquisitionMode = TEXT("user-supplied-or-platform-provided");
			Descriptor.ReviewPosture = TEXT("per-font-license-review-required");
			Descriptor.bBundledWithCodeDistribution = false;
			Descriptor.bStandaloneDonorRenderingDeferred = true;
			return Descriptor;
		};

		return {
			MakeFontReview(TEXT("font-review/qbr/latin-core"), TEXT("en"), TEXT("ui-font/latin-core"), TEXT("latin-basic-word-space"), TEXT("locale/latin/font-license-review")),
			MakeFontReview(TEXT("font-review/qbr/cjk-simplified"), TEXT("zh"), TEXT("ui-font/cjk-simplified-core"), TEXT("cjk-character-wrap"), TEXT("locale/zh/font-license-review")),
			MakeFontReview(TEXT("font-review/qbr/cjk-traditional"), TEXT("zh-tw"), TEXT("ui-font/cjk-traditional-core"), TEXT("cjk-character-wrap"), TEXT("locale/zh-tw/font-license-review")),
			MakeFontReview(TEXT("font-review/qbr/arabic-core"), TEXT("ar"), TEXT("ui-font/arabic-core"), TEXT("rtl-arabic-complex-shaping"), TEXT("locale/ar/font-license-review")),
			MakeFontReview(TEXT("font-review/qbr/persian-core"), TEXT("fa"), TEXT("ui-font/persian-core"), TEXT("rtl-persian-complex-shaping"), TEXT("locale/fa/font-license-review"))
		};
	}

	FHyperTwistVisionLocaleOption ResolveVisionLocaleOption(
		const TArray<FHyperTwistVisionLocaleOption>& SupportedLocales,
		const FString& PreferredLocaleCode
	)
	{
		const FString NormalizedPreferredLocale = PreferredLocaleCode.TrimStartAndEnd().ToLower();
		for (const FHyperTwistVisionLocaleOption& LocaleOption : SupportedLocales)
		{
			if (LocaleOption.LocaleCode.Equals(NormalizedPreferredLocale, ESearchCase::IgnoreCase))
			{
				return LocaleOption;
			}
		}

		if (SupportedLocales.Num() > 0)
		{
			return SupportedLocales[0];
		}

		FHyperTwistVisionLocaleOption FallbackLocale;
		FallbackLocale.LocaleCode = TEXT("en");
		FallbackLocale.DisplayLabel = TEXT("English");
		FallbackLocale.GuidanceModeId = TEXT("qbr-locale-guidance-routing-v1");
		FallbackLocale.ScriptDirectionId = TEXT("ltr");
		FallbackLocale.TextFlowProfileId = TEXT("word-space-delimited");
		FallbackLocale.PresentationProfileId = TEXT("qbr-locale-presentation-v1");
		FallbackLocale.FontReviewDescriptorId = TEXT("font-review/qbr/latin-core");
		FallbackLocale.bRequiresComplexTextShaping = false;
		FallbackLocale.bBundledFontAssetDeferred = true;
		return FallbackLocale;
	}

	FHyperTwistSpeechQuotaRateLimitState MakeDefaultSpeechQuotaRateLimitState(
		const FHyperTwistSpeechUsageCostAccountingProfile& AccountingProfile,
		const FHyperTwistSpeechProviderProfile& ProviderProfile,
		const FString& ServiceLaneId,
		const FString& StateReason,
		const bool bQuotaKnown,
		const bool bRateLimited,
		const bool bHardBlocked,
		const int32 RemainingRequestCount,
		const int32 RemainingAudioSeconds,
		const float RemainingEstimatedSpendUsd
	)
	{
		FHyperTwistSpeechQuotaRateLimitState State;
		State.QuotaStateId = FString::Printf(
			TEXT("speech-quota-state/%s"),
			*ProviderProfile.ProviderProfileId
		);
		State.UsageCostAccountingProfileId = AccountingProfile.UsageCostAccountingProfileId;
		State.ProviderProfileId = ProviderProfile.ProviderProfileId;
		State.ServiceLaneId = ServiceLaneId.IsEmpty()
			? TEXT("speech/python-service")
			: ServiceLaneId;
		State.RateLimitWindowId = TEXT("per-minute");
		State.ResetAtUtc = TEXT("2026-05-25T00:01:00Z");
		State.StateReason = StateReason.IsEmpty() ? TEXT("within-budget") : StateReason;
		State.RemainingRequestCount = RemainingRequestCount;
		State.RemainingAudioSeconds = RemainingAudioSeconds;
		State.RemainingEstimatedSpendUsd = RemainingEstimatedSpendUsd;
		State.bQuotaKnown = bQuotaKnown;
		State.bRateLimited = bRateLimited;
		State.bHardBlocked = bHardBlocked;
		return State;
	}

	FHyperTwistSpeechByokCustodyProfile MakeDefaultSpeechByokCustodyProfile(const FString& ProfileId)
	{
		FHyperTwistSpeechByokCustodyProfile Profile;
		Profile.ByokCustodyProfileId = ProfileId;
		Profile.KeyCustodyPosture = TEXT("first-party-user-supplied");
		Profile.EndpointCustodyPosture = TEXT("first-party-custom-endpoint-owned");
		Profile.SecretStoragePosture = TEXT("out-of-band-secret-reference-only");
		Profile.ProfileLabelingPosture = TEXT("user-labeled-byok-profile-supported");
		Profile.EnablementPosture = TEXT("per-profile-enable-disable-supported");
		Profile.SupportedProviderClasses = {
			TEXT("official-direct-provider"),
			TEXT("openai-compatible-custom-endpoint"),
			TEXT("byok-endpoint"),
			TEXT("managed-gateway-provider"),
			TEXT("local-self-hosted-provider"),
			TEXT("bounded-speech-sidecar-service")
		};
		Profile.bSupportsOfficialProviderProfiles = true;
		Profile.bSupportsOpenAiCompatibleCustomEndpoints = true;
		Profile.bSupportsManagedGatewayProfiles = true;
		Profile.bSupportsLocalSelfHostedProfiles = true;
		Profile.bSupportsBoundedSidecarProfiles = true;
		Profile.bSupportsUserLabeledProfiles = true;
		Profile.bSupportsPerProfileModelMaps = true;
		Profile.bSupportsPerProfileAuthMaterial = true;
		Profile.bSupportsEnableDisableControls = true;
		Profile.bStoresSecretsOutOfBand = true;
		Profile.bPreservesProviderNeutrality = true;
		Profile.bAllowsDonorOwnedKeyCustody = false;
		return Profile;
	}

	TArray<FHyperTwistSpeechModelPayloadDescriptor> MakeDefaultSpeechModelPayloads()
	{
		return {
			MakeSpeechModelPayloadDescriptor(
				TEXT("speech-model/whisper.cpp/base.en"),
				TEXT("whisper-ggml-model"),
				TEXT("whisper"),
				TEXT("base.en"),
				TEXT("ggml-base.en.bin"),
				TEXT("models/ggml-base.en.bin"),
				TEXT("whisper.cpp/models/README.md"),
				TEXT("manual-download-or-convert"),
				TEXT("sha1"),
				TEXT("137c40403d78fd54d454da0f9bd998f78703390c"),
				142,
				false
			),
			MakeSpeechModelPayloadDescriptor(
				TEXT("speech-vad/whisper.cpp/silero-v6.2.0"),
				TEXT("whisper-vad-model"),
				TEXT("silero-vad"),
				TEXT("silero-v6.2.0"),
				TEXT("ggml-silero-v6.2.0.bin"),
				TEXT("models/ggml-silero-v6.2.0.bin"),
				TEXT("whisper.cpp/README.md"),
				TEXT("manual-download-or-convert"),
				TEXT(""),
				TEXT(""),
				2,
				true
			)
		};
	}

	FHyperTwistVisionCorrectionState MakeClassicCubeCorrectionState(
		const FHyperTwistVisionSessionConfig& SessionConfig,
		const FHyperTwistVisionReconstructionSession& ReconstructionSession,
		const FHyperTwistVisionFaceObservation& ObservedFace,
		const TArray<FString>& Warnings,
		const TArray<FHyperTwistVisionCorrectionResolution>& ResolutionLedger
	)
	{
		static constexpr float LowConfidenceThreshold = 0.85f;

		FHyperTwistVisionCorrectionState CorrectionState;
		const FHyperTwistVisionCorrectionProfile CorrectionProfile =
			SessionConfig.CorrectionProfileDefinition.IsStructurallyValid()
				? SessionConfig.CorrectionProfileDefinition
				: MakeDefaultClassicCubeCorrectionProfile(
					!SessionConfig.CorrectionProfileId.IsEmpty()
						? SessionConfig.CorrectionProfileId
						: TEXT("classic-cube-correction-shell-v1")
				);

		CorrectionState.CorrectionProfileId = CorrectionProfile.CorrectionProfileId;
		CorrectionState.MissingFaceCount = ReconstructionSession.IsStructurallyValid()
			? ReconstructionSession.MissingFaces.Num()
			: 6;
		CorrectionState.ResolutionLedger = ResolutionLedger;
		CorrectionState.ResolvedCorrectionCount = ResolutionLedger.Num();
		if (ResolutionLedger.Num() > 0)
		{
			CorrectionState.LastResolution = ResolutionLedger.Last();
		}
		CorrectionState.bManualCubeEditVisible =
			CorrectionProfile.bSupportsManualCubeEdit && ReconstructionSession.bHasCompleteClassicCubeNet;
		CorrectionState.bStageRestartVisible =
			CorrectionProfile.bSupportsStageRestart && Warnings.Num() > 0;

		TArray<FHyperTwistVisionCorrectionTarget> PendingTargets;
		TArray<FHyperTwistVisionCorrectionContradiction> Contradictions;
		if (ReconstructionSession.IsStructurallyValid())
		{
			for (const FHyperTwistVisionCommittedFaceState& FaceState : ReconstructionSession.CommittedFaces)
			{
				const FString FaceId = NormalizeBrowserFaceHint(FaceState.FaceId);
				const bool bHasCompleteNet = ReconstructionSession.bHasCompleteClassicCubeNet;
				if (HasAppliedResolutionForFace(ResolutionLedger, FaceState))
				{
					continue;
				}

				if (FaceState.bHasConflicts)
				{
					FHyperTwistVisionCorrectionContradiction Contradiction;
					Contradiction.ContradictionId = FString::Printf(TEXT("conflict-%s"), *FaceId);
					Contradiction.FaceId = FaceId;
					Contradiction.ContradictionKind = TEXT("conflicting-face");
					Contradiction.ObservationId = FaceState.LatestObservationId;
					Contradiction.RevisionCount = FaceState.RevisionCount;
					Contradiction.StatusLine =
						FString::Printf(TEXT("Face %s has conflicting sticker votes."), *FaceId);
					Contradiction.DetailLine =
						TEXT("At least one sticker vote disagrees with the current winner. Re-scan the face or review the manual cube edit before solve guidance continues.");
					Contradiction.bBlocksSolveExplanation = true;
					Contradiction.bManualReviewPreferred = bHasCompleteNet;
					for (const FHyperTwistVisionReconstructionStickerVote& Vote : FaceState.StickerVotes)
					{
						if (Vote.bHadConflict)
						{
							Contradiction.AffectedStickerIndices.Add(Vote.GridIndex);
						}
					}
					Contradictions.Add(Contradiction);

					FHyperTwistVisionCorrectionTarget Target;
					Target.FaceId = FaceId;
					Target.ReasonId = TEXT("conflicting-face");
					Target.RecommendedActionId = bHasCompleteNet
						? TEXT("apply-manual-corrections")
						: TEXT("rescan-target-face");
					Target.StatusLine = bHasCompleteNet
						? FString::Printf(TEXT("Review face %s before solve guidance begins."), *FaceId)
						: FString::Printf(TEXT("Re-scan face %s before capture advances."), *FaceId);
					Target.DetailLine = bHasCompleteNet
						? TEXT("Conflicting sticker votes survived the bounded reconstruction pass. Use cube edit or a targeted re-scan to close the contradiction.")
						: TEXT("Conflicting sticker votes are present while capture is still open. Re-scan the face before committing the remaining sides.");
					Target.PriorityOrdinal = 0;
					Target.bManualReviewPreferred = bHasCompleteNet;
					UpsertCorrectionTarget(PendingTargets, Target);
				}

				if (FaceState.RevisionCount > 0)
				{
					FHyperTwistVisionCorrectionContradiction Contradiction;
					Contradiction.ContradictionId = FString::Printf(TEXT("revision-%s"), *FaceId);
					Contradiction.FaceId = FaceId;
					Contradiction.ContradictionKind = TEXT("manual-revision");
					Contradiction.ObservationId = FaceState.LatestObservationId;
					Contradiction.RevisionCount = FaceState.RevisionCount;
					Contradiction.StatusLine =
						FString::Printf(TEXT("Face %s was recommitted and needs review."), *FaceId);
					Contradiction.DetailLine = FString::Printf(
						TEXT("The latest bounded reconstruction includes %d revision(s) on face %s. Preserve the latest capture or review the cube edit before solve guidance continues."),
						FaceState.RevisionCount,
						*FaceId
					);
					Contradiction.bBlocksSolveExplanation = true;
					Contradiction.bManualReviewPreferred = bHasCompleteNet;
					Contradictions.Add(Contradiction);

					FHyperTwistVisionCorrectionTarget Target;
					Target.FaceId = FaceId;
					Target.ReasonId = TEXT("revised-face");
					Target.RecommendedActionId = bHasCompleteNet
						? TEXT("apply-manual-corrections")
						: TEXT("rescan-target-face");
					Target.StatusLine = bHasCompleteNet
						? FString::Printf(TEXT("Review the revised face %s before solve guidance begins."), *FaceId)
						: FString::Printf(TEXT("Re-scan revised face %s before capture advances."), *FaceId);
					Target.DetailLine = FString::Printf(
						TEXT("Face %s has already been recommitted %d time(s) in this bounded session."),
						*FaceId,
						FaceState.RevisionCount
					);
					Target.PriorityOrdinal = 1;
					Target.bManualReviewPreferred = bHasCompleteNet;
					UpsertCorrectionTarget(PendingTargets, Target);
				}

				const float FaceConfidence = CalculateCommittedFaceConfidence(FaceState);
				if (FaceConfidence > 0.0f && FaceConfidence < LowConfidenceThreshold)
				{
					FHyperTwistVisionCorrectionTarget Target;
					Target.FaceId = FaceId;
					Target.ReasonId = TEXT("low-confidence-face");
					Target.RecommendedActionId = bHasCompleteNet
						? TEXT("apply-manual-corrections")
						: TEXT("rescan-target-face");
					Target.StatusLine = bHasCompleteNet
						? FString::Printf(TEXT("Review low-confidence face %s before solve guidance begins."), *FaceId)
						: FString::Printf(TEXT("Re-scan low-confidence face %s before capture advances."), *FaceId);
					Target.DetailLine = FString::Printf(
						TEXT("Average sticker confidence %.2f on face %s is below the bounded correction threshold %.2f."),
						FaceConfidence,
						*FaceId,
						LowConfidenceThreshold
					);
					Target.PriorityOrdinal = 2;
					Target.bManualReviewPreferred = bHasCompleteNet;
					UpsertCorrectionTarget(PendingTargets, Target);
				}
			}

			for (const FString& MissingFaceId : ReconstructionSession.MissingFaces)
			{
				const FString FaceId = NormalizeBrowserFaceHint(MissingFaceId);
				FHyperTwistVisionCorrectionTarget Target;
				Target.FaceId = FaceId;
				Target.ReasonId = TEXT("missing-face");
				Target.RecommendedActionId = TEXT("capture-target-face");
				Target.StatusLine =
					FString::Printf(TEXT("Capture face %s to continue the bounded reconstruction pass."), *FaceId);
				Target.DetailLine = FString::Printf(
					TEXT("Commit the next missing face. %d face(s) still need capture before solve guidance unlocks."),
					ReconstructionSession.MissingFaces.Num()
				);
				Target.PriorityOrdinal = 3;
				Target.bManualReviewPreferred = false;
				UpsertCorrectionTarget(PendingTargets, Target);
			}
		}

		if (PendingTargets.Num() == 0)
		{
			const FString FallbackFaceId = !ObservedFace.FaceId.IsEmpty()
				? NormalizeBrowserFaceHint(ObservedFace.FaceId)
				: TEXT("F");

			if (Warnings.Num() > 0)
			{
				FHyperTwistVisionCorrectionTarget Target;
				Target.FaceId = FallbackFaceId;
				Target.ReasonId = TEXT("warning-restart");
				Target.RecommendedActionId = TEXT("restart-browser-session");
				Target.StatusLine = TEXT("Restart the capture stage before correction continues.");
				Target.DetailLine = FString::Printf(
					TEXT("The bounded correction shell reported: %s"),
					*FString::Join(Warnings, TEXT(" | "))
				);
				Target.PriorityOrdinal = 0;
				Target.bManualReviewPreferred = false;
				UpsertCorrectionTarget(PendingTargets, Target);
			}
			else if (!ReconstructionSession.IsStructurallyValid())
			{
				FHyperTwistVisionCorrectionTarget Target;
				Target.FaceId = FallbackFaceId;
				Target.ReasonId = TEXT("capture-bootstrap");
				Target.RecommendedActionId = TEXT("capture-target-face");
				Target.StatusLine =
					FString::Printf(TEXT("Capture face %s to start bounded correction routing."), *FallbackFaceId);
				Target.DetailLine =
					TEXT("No committed reconstruction session is available yet. Capture the first face before correction or solve guidance can advance.");
				Target.PriorityOrdinal = 3;
				Target.bManualReviewPreferred = false;
				UpsertCorrectionTarget(PendingTargets, Target);
			}
		}

		PendingTargets.Sort(
			[](const FHyperTwistVisionCorrectionTarget& Left, const FHyperTwistVisionCorrectionTarget& Right)
			{
				if (Left.PriorityOrdinal != Right.PriorityOrdinal)
				{
					return Left.PriorityOrdinal < Right.PriorityOrdinal;
				}

				return GetClassicCorrectionFaceOrderIndex(Left.FaceId)
					< GetClassicCorrectionFaceOrderIndex(Right.FaceId);
			}
		);
		Contradictions.Sort(
			[](const FHyperTwistVisionCorrectionContradiction& Left, const FHyperTwistVisionCorrectionContradiction& Right)
			{
				return GetClassicCorrectionFaceOrderIndex(Left.FaceId)
					< GetClassicCorrectionFaceOrderIndex(Right.FaceId);
			}
		);

		CorrectionState.PendingTargets = PendingTargets;
		CorrectionState.Contradictions = Contradictions;
		CorrectionState.ContradictionCount = Contradictions.Num();
		CorrectionState.bCorrectionRequired = PendingTargets.Num() > 0;
		CorrectionState.bManualReviewRequired = Contradictions.Num() > 0;
		CorrectionState.bCorrectionComplete =
			ReconstructionSession.bHasCompleteClassicCubeNet && !CorrectionState.bCorrectionRequired;
		CorrectionState.bSolveExplanationBlocked = !CorrectionState.bCorrectionComplete;

		if (CorrectionState.bCorrectionRequired)
		{
			CorrectionState.ActiveTarget = PendingTargets[0];
			CorrectionState.ActiveTargetFaceId = CorrectionState.ActiveTarget.FaceId;
			CorrectionState.RecommendationStatusLine = CorrectionState.ActiveTarget.StatusLine;
			CorrectionState.RecommendationDetailLine = CorrectionState.ActiveTarget.DetailLine;
			CorrectionState.NextRecommendedActionId = CorrectionState.ActiveTarget.RecommendedActionId;
			CorrectionState.bTargetedRescanVisible =
				CorrectionState.ActiveTarget.RecommendedActionId == TEXT("capture-target-face")
				|| CorrectionState.ActiveTarget.RecommendedActionId == TEXT("rescan-target-face");
			CorrectionState.bManualCubeEditVisible =
				CorrectionProfile.bSupportsManualCubeEdit
				&& (ReconstructionSession.bHasCompleteClassicCubeNet
					|| CorrectionState.ActiveTarget.RecommendedActionId == TEXT("apply-manual-corrections"));
			CorrectionState.bStageRestartVisible =
				CorrectionProfile.bSupportsStageRestart
				&& (Warnings.Num() > 0
					|| CorrectionState.ActiveTarget.RecommendedActionId == TEXT("restart-browser-session"));
			CorrectionState.bManualReviewRequired =
				CorrectionState.bManualReviewRequired || CorrectionState.ActiveTarget.bManualReviewPreferred;
			CorrectionState.RecommendedStageId =
				CorrectionState.ActiveTarget.RecommendedActionId == TEXT("apply-manual-corrections")
					? TEXT("cube-edit")
					: TEXT("video-stream");
		}
		else
		{
			CorrectionState.RecommendedStageId = TEXT("orient-centers");
			CorrectionState.RecommendationStatusLine =
				TEXT("Correction is clear; solve guidance can begin.");
			CorrectionState.RecommendationDetailLine =
				TEXT("No missing faces, contradictions, or low-confidence targets remain in the bounded correction shell.");
			CorrectionState.NextRecommendedActionId = TEXT("start-solve-explanation");
			CorrectionState.bTargetedRescanVisible = false;
			CorrectionState.bManualCubeEditVisible =
				CorrectionProfile.bSupportsManualCubeEdit && ReconstructionSession.bHasCompleteClassicCubeNet;
		}

		return CorrectionState;
	}

	FHyperTwistVisionSolveExplanationState MakeClassicCubeSolveExplanationState(
		const FHyperTwistVisionSessionConfig& SessionConfig,
		const FHyperTwistVisionReconstructionSession& ReconstructionSession,
		const FHyperTwistVisionCorrectionState& CorrectionState
	)
	{
		FHyperTwistVisionSolveExplanationState SolveExplanationState;
		const FHyperTwistVisionSolveExplanationProfile SolveExplanationProfile =
			SessionConfig.SolveExplanationProfileDefinition.IsStructurallyValid()
				? SessionConfig.SolveExplanationProfileDefinition
				: MakeDefaultClassicCubeSolveExplanationProfile(
					!SessionConfig.SolveExplanationProfileId.IsEmpty()
						? SessionConfig.SolveExplanationProfileId
						: TEXT("classic-cube-solve-explanation-v1")
				);
		const FString PreferredLocaleCode =
			SessionConfig.ShellProfileDefinition.IsStructurallyValid()
				? SessionConfig.ShellProfileDefinition.DefaultLocaleCode
				: SolveExplanationProfile.DefaultLocaleCode;
		const FHyperTwistVisionLocaleOption ActiveLocaleOption = ResolveVisionLocaleOption(
			SolveExplanationProfile.SupportedLocales,
			PreferredLocaleCode
		);

		SolveExplanationState.ExplanationProfileId = SolveExplanationProfile.ExplanationProfileId;
		SolveExplanationState.ActiveLocaleCode = ActiveLocaleOption.LocaleCode;
		SolveExplanationState.ActiveLocaleDisplayLabel = ActiveLocaleOption.DisplayLabel;
		SolveExplanationState.ActiveLocaleScriptDirectionId = ActiveLocaleOption.ScriptDirectionId;
		SolveExplanationState.ActiveLocaleTextFlowProfileId = ActiveLocaleOption.TextFlowProfileId;
		SolveExplanationState.ActiveLocalePresentationProfileId = ActiveLocaleOption.PresentationProfileId;
		SolveExplanationState.FontReviewProfileId = SolveExplanationProfile.FontReviewProfileId;
		SolveExplanationState.ActiveFontReviewDescriptorId = ActiveLocaleOption.FontReviewDescriptorId;
		SolveExplanationState.bActiveLocaleRequiresComplexTextShaping =
			ActiveLocaleOption.bRequiresComplexTextShaping;
		SolveExplanationState.bBundledFontAssetDeferred =
			ActiveLocaleOption.bBundledFontAssetDeferred;
		SolveExplanationState.LocaleGuidanceMode = SolveExplanationProfile.LocaleGuidanceMode;
		SolveExplanationState.StartingOrientationHint = SolveExplanationProfile.StartingOrientationHint;
		SolveExplanationState.TotalStepCount = SolveExplanationProfile.Steps.Num();
		SolveExplanationState.bPlaybackDeferred = !SolveExplanationProfile.bSupportsPlaybackStage;
		SolveExplanationState.bRequiresFullReconstruction = true;
		SolveExplanationState.bLocaleCycleVisible = SolveExplanationProfile.SupportedLocales.Num() > 1;
		SolveExplanationState.bStartingOrientationHintVisible =
			!SolveExplanationProfile.StartingOrientationHint.IsEmpty();

		if (ReconstructionSession.bHasCompleteClassicCubeNet
			&& CorrectionState.IsStructurallyValid()
			&& CorrectionState.bCorrectionComplete)
		{
			SolveExplanationState.RecommendedStageId =
				SolveExplanationProfile.Steps.Num() > 0
					? SolveExplanationProfile.Steps[0].StageId
					: TEXT("orient-centers");
			SolveExplanationState.RecommendationStatusLine =
				TEXT("Solve guidance is ready after cube-edit review.");
			SolveExplanationState.RecommendationDetailLine =
				TEXT("Review any manual corrections, then start the bounded stage ladder. Playback ownership stays deferred in this packet.");
			SolveExplanationState.CurrentStepOrdinal = -1;
			SolveExplanationState.bReadyForExplanation = true;
			SolveExplanationState.bStartExplanationVisible = true;
			SolveExplanationState.bNextStepVisible = false;
			SolveExplanationState.bPreviousStepVisible = false;
		}
		else if (ReconstructionSession.bHasCompleteClassicCubeNet
			&& CorrectionState.IsStructurallyValid()
			&& CorrectionState.bCorrectionRequired)
		{
			SolveExplanationState.RecommendedStageId = !CorrectionState.RecommendedStageId.IsEmpty()
				? CorrectionState.RecommendedStageId
				: TEXT("video-stream");
			SolveExplanationState.RecommendationStatusLine =
				TEXT("Solve guidance stays blocked until correction closes.");
			SolveExplanationState.RecommendationDetailLine =
				!CorrectionState.RecommendationDetailLine.IsEmpty()
					? CorrectionState.RecommendationDetailLine
					: TEXT("Finish the bounded correction shell before solve guidance unlocks.");
			SolveExplanationState.CurrentStepOrdinal = -1;
			SolveExplanationState.bReadyForExplanation = false;
			SolveExplanationState.bStartExplanationVisible = false;
			SolveExplanationState.bNextStepVisible = false;
			SolveExplanationState.bPreviousStepVisible = false;
		}
		else
		{
			const int32 RemainingFaceCount = ReconstructionSession.IsStructurallyValid()
				? ReconstructionSession.MissingFaces.Num()
				: 6;
			SolveExplanationState.RecommendedStageId = TEXT("capture-remaining-faces");
			SolveExplanationState.RecommendationStatusLine =
				TEXT("Solve guidance unlocks after capture completes.");
			SolveExplanationState.RecommendationDetailLine = FString::Printf(
				TEXT("Commit the remaining %d face(s) and finish the bounded reconstruction pass before solve guidance unlocks."),
				RemainingFaceCount
			);
			SolveExplanationState.CurrentStepOrdinal = -1;
			SolveExplanationState.bReadyForExplanation = false;
			SolveExplanationState.bStartExplanationVisible = false;
			SolveExplanationState.bNextStepVisible = false;
			SolveExplanationState.bPreviousStepVisible = false;
		}

		return SolveExplanationState;
	}
}

FHyperTwistPuzzleDefinitionRef UHyperTwistContractLibrary::MakeSampleClassicPuzzleDefinition()
{
	FHyperTwistPuzzleDefinitionRef Definition;
	Definition.PuzzleId = TEXT("cube/3x3x3");
	Definition.PuzzleFamily = EHyperTwistPuzzleFamily::ClassicCube;
	Definition.Dimension = 3;
	Definition.DefinitionVersion = TEXT("2026.04");
	Definition.NotationProfile = TEXT("classic-wca");
	Definition.SizeVector = {3, 3, 3};
	return Definition;
}

FHyperTwistPuzzleDefinitionRef UHyperTwistContractLibrary::MakeSampleHyperPuzzleDefinition()
{
	FHyperTwistPuzzleDefinitionRef Definition;
	if (UHyperTwistTrainingCatalogLibrary::TryResolveRetainedHyperPuzzleDefinition(
		TEXT("hypercube/2x2x2x2"),
		Definition
	))
	{
		return Definition;
	}

	Definition.PuzzleId = TEXT("hypercube/2x2x2x2");
	Definition.PuzzleFamily = EHyperTwistPuzzleFamily::Hypercube;
	Definition.Dimension = 4;
	Definition.DefinitionVersion = TEXT("2026.04");
	Definition.NotationProfile = TEXT("hyper-4d");
	Definition.SizeVector = {2, 2, 2, 2};
	return Definition;
}

FHyperTwistPuzzleState UHyperTwistContractLibrary::MakeSampleClassicPuzzleState()
{
	FHyperTwistClassicPieceOrbitState OrbitState;
	OrbitState.Corners.Permutation = {0, 1, 2, 3, 4, 5, 6, 7};
	OrbitState.Corners.Orientation = {0, 0, 0, 0, 0, 0, 0, 0};
	OrbitState.Edges.Permutation = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
	OrbitState.Edges.Orientation = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
	OrbitState.Centers.Permutation = {0, 1, 2, 3, 4, 5};
	OrbitState.Centers.Orientation = {0, 0, 0, 0, 0, 0};

	FHyperTwistPuzzleState State;
	State.Definition = MakeSampleClassicPuzzleDefinition();
	State.StateEncodingKind = EHyperTwistStateEncodingKind::PieceOrbit;
	State.StateEncoding.EncodingProfile = OrbitState.EncodingProfile;
	State.StateEncoding.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(OrbitState);
	State.OrientationFrame.Reference = TEXT("canonical-default");
	State.bIsSolved = true;
	State.Source = EHyperTwistStateSource::Runtime;
	State.CapturedAtUtc = TEXT("2026-04-25T12:00:00Z");
	State.SourceConfidence = -1.0f;
	return State;
}

FHyperTwistPuzzleState UHyperTwistContractLibrary::MakeSampleClassicRecognitionPreviewState()
{
	FHyperTwistClassicFaceletSnapshotState FaceletState;
	FaceletState.U = {TEXT("W"), TEXT("W"), TEXT("W"), TEXT("W"), TEXT("W"), TEXT("W"), TEXT("W"), TEXT("W"), TEXT("W")};
	FaceletState.R = {TEXT("R"), TEXT("R"), TEXT("R"), TEXT("R"), TEXT("R"), TEXT("R"), TEXT("R"), TEXT("R"), TEXT("R")};
	FaceletState.F = {TEXT("G"), TEXT("G"), TEXT("G"), TEXT("G"), TEXT("G"), TEXT("G"), TEXT("G"), TEXT("G"), TEXT("G")};
	FaceletState.D = {TEXT("Y"), TEXT("Y"), TEXT("Y"), TEXT("Y"), TEXT("Y"), TEXT("Y"), TEXT("Y"), TEXT("Y"), TEXT("Y")};
	FaceletState.L = {TEXT("O"), TEXT("O"), TEXT("O"), TEXT("O"), TEXT("O"), TEXT("O"), TEXT("O"), TEXT("O"), TEXT("O")};
	FaceletState.B = {TEXT("B"), TEXT("B"), TEXT("B"), TEXT("B"), TEXT("B"), TEXT("B"), TEXT("B"), TEXT("B"), TEXT("B")};

	FHyperTwistPuzzleState State;
	State.Definition = MakeSampleClassicPuzzleDefinition();
	State.StateEncodingKind = EHyperTwistStateEncodingKind::Facelet;
	State.StateEncoding.EncodingProfile = FaceletState.EncodingProfile;
	State.StateEncoding.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(FaceletState);
	State.OrientationFrame.Reference = TEXT("camera-relative");
	State.bIsSolved = false;
	State.Source = EHyperTwistStateSource::Recognition;
	State.CapturedAtUtc = TEXT("2026-04-25T12:00:00Z");
	State.SourceConfidence = 0.84f;
	State.SourceSessionId = TEXT("vision_01");
	return State;
}

FHyperTwistPuzzleState UHyperTwistContractLibrary::MakeSampleHyperPuzzleState()
{
	FHyperTwistMelinda2x2x2x2StateEncoding HyperState;
	HyperState.PositionToPiece = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
	HyperState.PieceOrientation = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

	FHyperTwistPuzzleState State;
	State.Definition = MakeSampleHyperPuzzleDefinition();
	State.StateEncodingKind = EHyperTwistStateEncodingKind::FamilySpecific;
	State.StateEncoding.EncodingProfile = HyperState.EncodingProfile;
	State.StateEncoding.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(HyperState);
	State.OrientationFrame.Reference = HyperState.FrameProfile;
	State.bIsSolved = true;
	State.Source = EHyperTwistStateSource::Runtime;
	State.CapturedAtUtc = TEXT("2026-04-25T12:00:00Z");
	return State;
}

FHyperTwistTransformation UHyperTwistContractLibrary::MakeSampleClassicTransformation()
{
	FHyperTwistClassicTransformEncoding TransformEncoding;
	TransformEncoding.MoveSequence = {TEXT("R"), TEXT("U"), TEXT("R'"), TEXT("U'")};

	FHyperTwistTransformation Transformation;
	Transformation.Definition = MakeSampleClassicPuzzleDefinition();
	Transformation.TransformKind = EHyperTwistTransformKind::Algorithm;
	Transformation.Notation = TEXT("R U R' U'");
	Transformation.TransformEncoding.EncodingProfile = TransformEncoding.EncodingProfile;
	Transformation.TransformEncoding.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(TransformEncoding);
	Transformation.OriginalNotation = Transformation.Notation;
	return Transformation;
}

FHyperTwistReplayPacket UHyperTwistContractLibrary::MakeSampleRuntimeReplayPacket()
{
	FHyperTwistReplayPhaseMarkPayload PhasePayload;
	PhasePayload.PhaseId = TEXT("phase_exec");
	PhasePayload.PhaseKind = TEXT("execution");
	PhasePayload.PhaseSource = TEXT("explicit");
	PhasePayload.PhaseAction = TEXT("start");

	FHyperTwistReplayMovePayload MovePayload;
	MovePayload.Notation = TEXT("R");
	MovePayload.Source = TEXT("runtime");

	FHyperTwistReplayEvent TimerStartEvent;
	TimerStartEvent.EventId = TEXT("evt_01");
	TimerStartEvent.Sequence = 1;
	TimerStartEvent.TimeMs = 0;
	TimerStartEvent.EventType = EHyperTwistReplayEventType::TimerStart;

	FHyperTwistReplayEvent PhaseEvent;
	PhaseEvent.EventId = TEXT("evt_02");
	PhaseEvent.Sequence = 2;
	PhaseEvent.TimeMs = 100;
	PhaseEvent.EventType = EHyperTwistReplayEventType::PhaseMark;
	PhaseEvent.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(PhasePayload);

	FHyperTwistReplayEvent MoveEvent;
	MoveEvent.EventId = TEXT("evt_03");
	MoveEvent.Sequence = 3;
	MoveEvent.TimeMs = 250;
	MoveEvent.EventType = EHyperTwistReplayEventType::Move;
	MoveEvent.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(MovePayload);

	FHyperTwistPhaseTiming ExecutionTiming;
	ExecutionTiming.PhaseKind = TEXT("execution");
	ExecutionTiming.StartedAtMs = 100;
	ExecutionTiming.EndedAtMs = 12450;
	ExecutionTiming.DurationMs = 12350;

	FHyperTwistReplayPacket Packet;
	Packet.ReplayId = TEXT("replay_runtime_01");
	Packet.PuzzleDefinition = MakeSampleClassicPuzzleDefinition();
	Packet.CaptureMode = EHyperTwistCaptureMode::Runtime;
	Packet.SessionId = TEXT("session_runtime_01");
	Packet.StartedAtUtc = TEXT("2026-04-25T12:00:00Z");
	Packet.EndedAtUtc = TEXT("2026-04-25T12:00:12Z");
	Packet.Events = {TimerStartEvent, PhaseEvent, MoveEvent};
	Packet.DerivedSummary.TotalTimeMs = 12450;
	Packet.DerivedSummary.MoveCount = 56;
	Packet.DerivedSummary.TPS = 4.93f;
	Packet.DerivedSummary.PhaseTimings = {ExecutionTiming};
	Packet.DerivedSummary.Result = TEXT("completed");
	return Packet;
}

FHyperTwistReplayPacket UHyperTwistContractLibrary::MakeSampleRecognitionReplayPacket()
{
	FHyperTwistReplayRecognitionPayload PreviewPayload;
	PreviewPayload.Snapshot.SnapshotId = TEXT("snap_preview");
	PreviewPayload.Snapshot.State = MakeSampleClassicRecognitionPreviewState();
	PreviewPayload.Snapshot.DerivedHash = TEXT("preview_hash");
	PreviewPayload.Confidence = 0.78f;
	PreviewPayload.ScanStage = TEXT("preview");

	FHyperTwistReplayRecognitionPayload CommitPayload;
	CommitPayload.Snapshot.SnapshotId = TEXT("snap_commit");
	CommitPayload.Snapshot.State = MakeSampleClassicPuzzleState();
	CommitPayload.Snapshot.State.Source = EHyperTwistStateSource::Recognition;
	CommitPayload.Snapshot.State.SourceConfidence = 0.96f;
	CommitPayload.Snapshot.State.SourceSessionId = TEXT("vision_01");
	CommitPayload.Snapshot.DerivedHash = TEXT("commit_hash");
	CommitPayload.Confidence = 0.96f;
	CommitPayload.CommittedFaceOrStage = TEXT("F");
	CommitPayload.ScanStage = TEXT("commit");

	FHyperTwistReplayEvent PreviewEvent;
	PreviewEvent.EventId = TEXT("evt_01");
	PreviewEvent.Sequence = 1;
	PreviewEvent.TimeMs = 0;
	PreviewEvent.EventType = EHyperTwistReplayEventType::RecognitionPreview;
	PreviewEvent.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(PreviewPayload);

	FHyperTwistReplayEvent CommitEvent;
	CommitEvent.EventId = TEXT("evt_02");
	CommitEvent.Sequence = 2;
	CommitEvent.TimeMs = 420;
	CommitEvent.EventType = EHyperTwistReplayEventType::RecognitionCommit;
	CommitEvent.PayloadJson = HyperTwistContractLibraryInternal::SerializeStructToJson(CommitPayload);

	FHyperTwistReplayPacket Packet;
	Packet.ReplayId = TEXT("replay_vision_01");
	Packet.PuzzleDefinition = MakeSampleClassicPuzzleDefinition();
	Packet.CaptureMode = EHyperTwistCaptureMode::Recognition;
	Packet.SessionId = TEXT("vision_01");
	Packet.StartedAtUtc = TEXT("2026-04-25T12:00:00Z");
	Packet.EndedAtUtc = TEXT("2026-04-25T12:00:01Z");
	Packet.Events = {PreviewEvent, CommitEvent};
	Packet.DerivedSummary.TotalTimeMs = 420;
	Packet.DerivedSummary.RecognizedSegments = 1;
	Packet.DerivedSummary.ConfidenceRollup = 0.96f;
	Packet.DerivedSummary.Result = TEXT("committed");
	return Packet;
}

FHyperTwistVisionSessionConfig UHyperTwistContractLibrary::MakeSampleVisionSessionConfig()
{
	FHyperTwistVisionSessionConfig Config;
	Config.SessionId = TEXT("vision_01");
	Config.PuzzleId = TEXT("cube/3x3x3");
	Config.ExpectedPuzzleFamily = EHyperTwistPuzzleFamily::ClassicCube;
	Config.NotationProfile = TEXT("classic-wca");
	Config.CalibrationProfile = TEXT("classic-cube-default");
	Config.CalibrationProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultClassicCubeCalibrationProfile(
			Config.CalibrationProfile
		);
	Config.ShellProfileId = TEXT("classic-cube-webcam-shell-v1");
	Config.ShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultClassicCubeWebcamShellProfile(
			Config.ShellProfileId
		);
	Config.BrowserShellProfileId = TEXT("classic-cube-browser-shell-v1");
	Config.BrowserShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultClassicCubeBrowserShellProfile(
			Config.BrowserShellProfileId
		);
	Config.SolveExplanationProfileId = TEXT("classic-cube-solve-explanation-v1");
	Config.SolveExplanationProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultClassicCubeSolveExplanationProfile(
			Config.SolveExplanationProfileId
		);
	Config.CorrectionProfileId = TEXT("classic-cube-correction-shell-v1");
	Config.CorrectionProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultClassicCubeCorrectionProfile(
			Config.CorrectionProfileId
		);
	Config.FrameSize = FIntPoint(1280, 720);
	Config.MaxFrameRate = 30;
	return Config;
}

FHyperTwistVisionPreviewResult UHyperTwistContractLibrary::MakeMockVisionPreviewResult()
{
	FHyperTwistVisionPreviewResult Result;
	Result.SessionId = TEXT("vision_01");
	Result.FrameId = TEXT("frame_10");
	Result.PreviewConfidence = 0.84f;
	Result.PreviewState.SnapshotId = TEXT("snap_prev_10");
	Result.PreviewState.State = MakeSampleClassicRecognitionPreviewState();
	Result.PreviewState.DerivedHash = TEXT("preview_hash");
	Result.ObservedFace = HyperTwistContractLibraryInternal::MakeMockClassicFaceObservation(
		TEXT("observation_preview_10"),
		TEXT("F"),
		0.84f,
		false
	);
	Result.ShellState = HyperTwistContractLibraryInternal::MakeClassicCubeWebcamShellState(
		UHyperTwistContractLibrary::MakeSampleVisionSessionConfig(),
		FHyperTwistVisionReconstructionSession(),
		Result.ObservedFace.FaceId,
		FString()
	);
	Result.BrowserShellState = HyperTwistContractLibraryInternal::MakeClassicCubeBrowserShellState(
		UHyperTwistContractLibrary::MakeSampleVisionSessionConfig(),
		FHyperTwistVisionReconstructionSession(),
		Result.ObservedFace
	);
	Result.Guidance = TEXT("capture-ready");
	return Result;
}

FHyperTwistVisionCommitResult UHyperTwistContractLibrary::MakeMockVisionCommitResult()
{
	FHyperTwistVisionCommitResult Result;
	Result.SessionId = TEXT("vision_01");
	Result.CommitKind = TEXT("face");
	Result.Snapshot.SnapshotId = TEXT("snap_commit");
	Result.Snapshot.State = MakeSampleClassicPuzzleState();
	Result.Snapshot.State.Source = EHyperTwistStateSource::Recognition;
	Result.Snapshot.State.SourceConfidence = 0.96f;
	Result.Snapshot.State.SourceSessionId = TEXT("vision_01");
	Result.Snapshot.DerivedHash = TEXT("commit_hash");
	Result.Confidence = 0.96f;
	Result.CommittedUnit = TEXT("F");
	Result.ObservedFace = HyperTwistContractLibraryInternal::MakeMockClassicFaceObservation(
		TEXT("observation_commit"),
		TEXT("F"),
		0.96f,
		true
	);
	Result.ReconstructionSession = HyperTwistContractLibraryInternal::MakeMockClassicReconstructionSession(
		Result.SessionId,
		{TEXT("F")},
		Result.Confidence
	);
	const FHyperTwistVisionSessionConfig SessionConfig =
		UHyperTwistContractLibrary::MakeSampleVisionSessionConfig();
	Result.ShellState = HyperTwistContractLibraryInternal::MakeClassicCubeWebcamShellState(
		SessionConfig,
		Result.ReconstructionSession,
		Result.ObservedFace.FaceId,
		Result.CommittedUnit
	);
	Result.BrowserShellState = HyperTwistContractLibraryInternal::MakeClassicCubeBrowserShellState(
		SessionConfig,
		Result.ReconstructionSession,
		Result.ObservedFace
	);
	Result.CorrectionState = HyperTwistContractLibraryInternal::MakeClassicCubeCorrectionState(
		SessionConfig,
		Result.ReconstructionSession,
		Result.ObservedFace,
		Result.Warnings,
		TArray<FHyperTwistVisionCorrectionResolution>()
	);
	Result.SolveExplanationState = HyperTwistContractLibraryInternal::MakeClassicCubeSolveExplanationState(
		SessionConfig,
		Result.ReconstructionSession,
		Result.CorrectionState
	);
	return Result;
}

FHyperTwistVisionFinalizeResult UHyperTwistContractLibrary::MakeMockVisionFinalizeResult()
{
	FHyperTwistVisionFinalizeResult Result;
	Result.SessionId = TEXT("vision_01");
	Result.FinalState = MakeSampleClassicPuzzleState();
	Result.FinalState.Source = EHyperTwistStateSource::Recognition;
	Result.FinalState.SourceConfidence = 0.97f;
	Result.FinalState.SourceSessionId = TEXT("vision_01");
	Result.FinalSnapshot.SnapshotId = TEXT("snap_final");
	Result.FinalSnapshot.State = Result.FinalState;
	Result.FinalSnapshot.DerivedHash = TEXT("final_hash");
	Result.ConfidenceRollup = 0.97f;
	Result.ReconstructionSession = HyperTwistContractLibraryInternal::MakeMockClassicReconstructionSession(
		Result.SessionId,
		{TEXT("U"), TEXT("R"), TEXT("F"), TEXT("D"), TEXT("L"), TEXT("B")},
		Result.ConfidenceRollup
	);
	Result.ReplaySeedEventsJson.Add(SerializeReplayPacketToJson(MakeSampleRecognitionReplayPacket()));
	return Result;
}

FHyperTwistVisionServiceHealth UHyperTwistContractLibrary::MakeMockVisionServiceHealth()
{
	FHyperTwistVisionServiceHealth Health;
	Health.ProviderLabel = TEXT("mock");
	Health.ServiceVersion = TEXT("mock-vision/v1");
	Health.ServiceEndpoint = TEXT("in-process://mock");
	Health.Capabilities = {
		TEXT("liveCamera3x3"),
		TEXT("faceCommitFlow"),
		TEXT("calibrationProfiles"),
		TEXT("orderedFaceObservation"),
		TEXT("reconstructionSession")
	};
	Health.bReady = true;
	return Health;
}

FHyperTwistSpeechSessionConfig UHyperTwistContractLibrary::MakeSampleSpeechSessionConfig()
{
	FHyperTwistSpeechSessionConfig Config;
	Config.SessionId = TEXT("speech_01");
	Config.ListeningContractId = TEXT("listening-threshold-lifecycle");
	Config.InputRouteId = TEXT("queue/listening");
	Config.AudioEncoding = TEXT("pcm-f32le-16khz-mono");
	Config.SampleRateHz = 16000;
	Config.ChannelCount = 1;
	Config.LanguageMode = TEXT("auto");
	Config.TaskKind = TEXT("transcribe");
	Config.GrammarProfileId = TEXT("coach-command-grammar-v1");
	Config.MicrophoneShellProfileId = TEXT("coach-command-microphone-shell-v1");
	Config.MicrophoneShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultCoachCommandMicrophoneShellProfile(
			Config.MicrophoneShellProfileId
		);
	Config.DevicePermissionWorkflowProfileId = TEXT("speech-device-permission-workflow-v1");
	Config.DevicePermissionWorkflowProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechDevicePermissionWorkflowProfile(
			Config.DevicePermissionWorkflowProfileId
		);
	Config.NativeCaptureRouteWorkflowProfileId =
		TEXT("speech-native-capture-route-workflow-v1");
	Config.NativeCaptureRouteWorkflowProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechNativeCaptureRouteWorkflowProfile(
			Config.NativeCaptureRouteWorkflowProfileId
		);
	Config.NativeCaptureRouteShellProfileId = TEXT("speech-native-capture-route-shell-v1");
	Config.NativeCaptureRouteShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechNativeCaptureRouteShellProfile(
			Config.NativeCaptureRouteShellProfileId
		);
	Config.ExternalDictationShellProfileId = TEXT("speech-external-dictation-shell-v1");
	Config.ExternalDictationShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechExternalDictationShellProfile(
			Config.ExternalDictationShellProfileId
		);
	Config.ProviderProfileId = TEXT("speech-provider/local-http-sidecar-profile-v1");
	Config.ProviderProfileDefinition =
		HyperTwistContractLibraryInternal::MakeLocalHttpSpeechProviderProfile(
			TEXT("Local HTTP Speech Sidecar"),
			TEXT("http://127.0.0.1:8766")
		);
	Config.ByokCustodyProfileId = TEXT("speech-byok-custody-profile-v1");
	Config.ByokCustodyProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechByokCustodyProfile(
			Config.ByokCustodyProfileId
		);
	Config.ProviderRoutingPolicyId = TEXT("speech-provider-routing/provider-backed-sidecar-first-v1");
	Config.ProviderRoutingPolicyDefinition =
		HyperTwistContractLibraryInternal::MakeProviderBackedSpeechProviderRoutingPolicy();
	Config.ProviderRouteDecision =
		HyperTwistContractLibraryInternal::MakeSpeechProviderRouteDecision(
			Config.ProviderRoutingPolicyDefinition,
			Config.ProviderProfileDefinition,
			TEXT("speech/python-service"),
			TEXT("sample-session-config"),
			TEXT("route-ready"),
			TEXT("provider-backed-sidecar-route-selected"),
			FString(),
			true,
			true,
			false,
			true
		);
	Config.UsageCostAccountingProfileId = TEXT("speech-usage-cost-accounting-v1");
	Config.UsageCostAccountingProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechUsageCostAccountingProfile(
			Config.UsageCostAccountingProfileId
		);
	Config.UsageEventTemplate =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechUsageEvent(
			Config.UsageCostAccountingProfileDefinition,
			Config.ProviderProfileDefinition,
			TEXT("speech/python-service"),
			TEXT("bounded-session-usage-summary"),
			TEXT("current-session"),
			TEXT("speech-session-default"),
			0.0f,
			0.0f,
			false,
			true
		);
	Config.CostEventTemplate =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechCostEvent(
			Config.UsageCostAccountingProfileDefinition,
			Config.ProviderProfileDefinition,
			TEXT("speech/python-service"),
			TEXT("bounded-session-cost-summary"),
			TEXT("current-session"),
			0.0f,
			0.0f,
			true,
			false
		);
	Config.UsageCostDashboardShellProfileId = TEXT("speech-provider-usage-cost-dashboard-shell-v1");
	Config.UsageCostDashboardShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechUsageCostDashboardShellProfile(
			Config.UsageCostDashboardShellProfileId
		);
	Config.UsageCostHistoryExportShellProfileId =
		TEXT("speech-provider-usage-cost-history-export-shell-v1");
	Config.UsageCostHistoryExportShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechUsageCostHistoryExportShellProfile(
			Config.UsageCostHistoryExportShellProfileId
		);
	Config.ProviderReceiptReviewShellProfileId =
		TEXT("speech-provider-receipt-review-shell-v1");
	Config.ProviderReceiptReviewShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechProviderReceiptReviewShellProfile(
			Config.ProviderReceiptReviewShellProfileId
		);
	Config.ProviderBillingSettlementShellProfileId =
		TEXT("speech-provider-billing-settlement-shell-v1");
	Config.ProviderBillingSettlementShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechProviderBillingSettlementShellProfile(
			Config.ProviderBillingSettlementShellProfileId
		);
	Config.ProviderSettlementExceptionShellProfileId =
		TEXT("speech-provider-settlement-exception-shell-v1");
	Config.ProviderSettlementExceptionShellProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechProviderSettlementExceptionShellProfile(
			Config.ProviderSettlementExceptionShellProfileId
		);
	Config.PayloadCustodyProfileId = TEXT("downloadable-model-payload-custody-v1");
	Config.PayloadCustodyProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechPayloadCustodyProfile(
			Config.PayloadCustodyProfileId
		);
	Config.RequiredModelPayloads = HyperTwistContractLibraryInternal::MakeDefaultSpeechModelPayloads();
	Config.bEnableVad = true;
	Config.bEnableWordTimestamps = false;
	Config.VadPolicy.Threshold = 0.5f;
	Config.VadPolicy.MinSpeechDurationMs = 250;
	Config.VadPolicy.MinSilenceDurationMs = 200;
	Config.VadPolicy.MaxSpeechDurationMs = 12000;
	Config.VadPolicy.SpeechPadMs = 100;
	Config.CommandHints = {
		TEXT("ready coach"),
		TEXT("repeat case"),
		TEXT("next case")
	};
	Config.OrchestrationProfile.OrchestrationProfileId = TEXT("python-batch-transcribe-v1");
	Config.OrchestrationProfile.ServiceLaneId = TEXT("speech/python-service");
	Config.OrchestrationProfile.PreferredBatchSize = 8;
	Config.OrchestrationProfile.ChunkLengthSeconds = 30;
	Config.OrchestrationProfile.BatchCollectionWindowMs = 150;
	Config.OrchestrationProfile.bEnableBatchedInference = true;
	Config.OrchestrationProfile.bConditionOnPreviousText = false;
	Config.OrchestrationProfile.bEnableWordTimestamps = true;
	Config.OrchestrationProfile.bEnableLanguageDetection = true;
	Config.OrchestrationProfile.LanguageDetectionThreshold = 0.5f;
	Config.OrchestrationProfile.LanguageDetectionSegmentCount = 1;
	Config.OrchestrationProfile.PromptRoutingModeId = TEXT("prefix-hotword-session-hints-v1");
	Config.OrchestrationProfile.PrefixHint = TEXT("Coach command:");
	Config.OrchestrationProfile.HotwordHints = {
		TEXT("HyperTwist"),
		TEXT("repeat case"),
		TEXT("next case")
	};
	Config.OrchestrationProfile.RetrievalContextLaneId = TEXT("speech-command-hint-session-memory");
	Config.OrchestrationProfile.MaxRetrievedHintCount = 4;
	Config.OrchestrationProfile.bEnableRetrievedHintAugmentation = true;
	return Config;
}

FHyperTwistSpeechTranscriptResult UHyperTwistContractLibrary::MakeMockSpeechTranscriptResult()
{
	FHyperTwistSpeechTranscriptResult Result;
	Result.SessionId = TEXT("speech_01");
	Result.UtteranceId = TEXT("speech_01_utterance_001");
	Result.LanguageCode = TEXT("en");
	Result.TaskKind = TEXT("transcribe");
	Result.GrammarProfileId = TEXT("coach-command-grammar-v1");
	Result.bIsFinal = true;
	Result.TranscriptText = TEXT("ready coach");
	Result.OrchestrationProfileId = TEXT("python-batch-transcribe-v1");
	Result.ServiceLaneId = TEXT("speech/python-service");
	Result.RequestedBatchSize = 8;
	Result.ProcessedClipCount = 1;
	Result.AppliedBatchCollectionWindowMs = 150;
	Result.bUsedBatchedInference = true;
	Result.bWordTimestampsRequested = true;
	Result.bConditionedOnPreviousText = false;
	Result.bUsedPromptHints = true;
	Result.bUsedRetrievedHintAugmentation = true;
	Result.LanguageProbability = 0.97f;
	Result.AppliedPromptRoutingModeId = TEXT("prefix-hotword-session-hints-v1");
	Result.AppliedPrefixHint = TEXT("Coach command:");
	Result.AppliedHotwordHints = {
		TEXT("HyperTwist"),
		TEXT("repeat case"),
		TEXT("next case")
	};
	Result.AppliedRetrievalContextLaneId = TEXT("speech-command-hint-session-memory");
	Result.AppliedRetrievedHints = {
		TEXT("ready coach"),
		TEXT("repeat case"),
		TEXT("next case")
	};
	Result.RetrievedHintCount = Result.AppliedRetrievedHints.Num();

	FHyperTwistSpeechTranscriptSegment Segment;
	Segment.SegmentOrdinal = 0;
	Segment.Text = Result.TranscriptText;
	Segment.StartMs = 120;
	Segment.EndMs = 840;
	Segment.Confidence = 0.94f;
	Segment.NoSpeechProbability = 0.04f;
	Segment.bGrammarConstrained = true;
	Result.Segments = {Segment};
	return Result;
}

FHyperTwistSpeechServiceHealth UHyperTwistContractLibrary::MakeMockSpeechServiceHealth()
{
	FHyperTwistSpeechServiceHealth Health;
	Health.ProviderLabel = TEXT("mock");
	Health.ServiceVersion = TEXT("mock-speech/v1");
	Health.ServiceEndpoint = TEXT("in-process://mock");
	Health.Capabilities = {
		TEXT("transcribe"),
		TEXT("vadSegments"),
		TEXT("grammarHints"),
		TEXT("sessioned-mock-client"),
		TEXT("microphoneCaptureShell"),
		TEXT("devicePermissionShell"),
		TEXT("captureRouteReadinessShell"),
		TEXT("captureRouteRetry"),
		TEXT("devicePermissionWorkflow"),
		TEXT("devicePermissionSettingsHandoff"),
		TEXT("devicePermissionRecheck"),
		TEXT("nativeCaptureRouteWorkflow"),
		TEXT("nativeCaptureRouteWorkflowShell"),
		TEXT("captureRoutePreparationControl"),
		TEXT("captureRouteOwnershipAssessment"),
		TEXT("captureRouteOwnershipSummaryCard"),
		TEXT("captureRoutePreparationCard"),
		TEXT("captureRouteSessionReopenCard"),
		TEXT("reopenSpeechSession"),
		TEXT("streamingPreview"),
		TEXT("manualTranscriptCommit"),
		TEXT("batchedTranscribe"),
		TEXT("batchWindowTuning"),
		TEXT("wordTimestamps"),
		TEXT("languageDetection"),
		TEXT("promptHints"),
		TEXT("promptRoutingProfiles"),
		TEXT("retrievalHintAugmentation"),
		TEXT("providerProfileCustody"),
		TEXT("byokCustody"),
		TEXT("providerRoutingPolicy"),
		TEXT("providerRouteSelection"),
		TEXT("workflowPolicyState"),
		TEXT("openAiCompatibleCustomEndpointProfile"),
		TEXT("userLabeledByokProfiles"),
		TEXT("downloadableModelPayloadCustody"),
		TEXT("payloadIntegrityReview"),
		TEXT("normalizedUsageEvents"),
		TEXT("normalizedCostEvents"),
		TEXT("quotaRateLimitState"),
		TEXT("providerUsageCostDashboardShell"),
		TEXT("providerQuotaEscalationBanner"),
		TEXT("providerRouteCostDiagnostics"),
		TEXT("providerUsageCostHistoryShell"),
		TEXT("providerUsageCostExportPreview"),
		TEXT("providerUsageCostSummaryCopy"),
		TEXT("providerReceiptReviewShell"),
		TEXT("providerPostedChargeInspection"),
		TEXT("providerChargeVarianceReview"),
		TEXT("providerBillingSettlementShell"),
		TEXT("providerInvoiceReconciliation"),
		TEXT("providerSettlementReadinessReview"),
		TEXT("providerSettlementExceptionShell"),
		TEXT("providerExternalPortalHandoff"),
		TEXT("providerSettlementExceptionReview")
	};
	Health.SupportedOrchestrationProfiles = {
		TEXT("python-batch-transcribe-v1")
	};
	Health.ProviderProfileId = TEXT("speech-provider/mock-offline-profile-v1");
	Health.ProviderProfileDefinition = HyperTwistContractLibraryInternal::MakeMockSpeechProviderProfile();
	Health.ByokCustodyProfileId = TEXT("speech-byok-custody-profile-v1");
	Health.ByokCustodyProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechByokCustodyProfile(
			Health.ByokCustodyProfileId
		);
	Health.ProviderRoutingPolicyId = TEXT("speech-provider-routing/local-offline-mock-first-v1");
	Health.ProviderRoutingPolicyDefinition =
		HyperTwistContractLibraryInternal::MakeMockSpeechProviderRoutingPolicy();
	Health.ProviderRouteDecision =
		HyperTwistContractLibraryInternal::MakeSpeechProviderRouteDecision(
			Health.ProviderRoutingPolicyDefinition,
			Health.ProviderProfileDefinition,
			TEXT("speech/python-service"),
			TEXT("mock-health-default"),
			TEXT("route-ready"),
			TEXT("mock-verification-route-selected"),
			FString(),
			false,
			false,
			false,
			true
		);
	Health.UsageCostAccountingProfileId = TEXT("speech-usage-cost-accounting-v1");
	Health.UsageCostAccountingProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechUsageCostAccountingProfile(
			Health.UsageCostAccountingProfileId
		);
	Health.LatestUsageEvent =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechUsageEvent(
			Health.UsageCostAccountingProfileDefinition,
			Health.ProviderProfileDefinition,
			TEXT("speech/python-service"),
			TEXT("bounded-session-usage-summary"),
			TEXT("service-health-window"),
			TEXT("mock-health-default"),
			0.75f,
			0.0f,
			false,
			true
		);
	Health.LatestCostEvent =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechCostEvent(
			Health.UsageCostAccountingProfileDefinition,
			Health.ProviderProfileDefinition,
			TEXT("speech/python-service"),
			TEXT("bounded-session-cost-summary"),
			TEXT("service-health-window"),
			0.01f,
			0.0f,
			true,
			false
		);
	Health.QuotaRateLimitState =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechQuotaRateLimitState(
			Health.UsageCostAccountingProfileDefinition,
			Health.ProviderProfileDefinition,
			TEXT("speech/python-service"),
			TEXT("within-budget"),
			true,
			false,
			false,
			60,
			3600,
			25.0f
		);
	Health.PayloadCustodyProfileId = TEXT("downloadable-model-payload-custody-v1");
	Health.PayloadCustodyProfileDefinition =
		HyperTwistContractLibraryInternal::MakeDefaultSpeechPayloadCustodyProfile(
			Health.PayloadCustodyProfileId
		);
	Health.SupportedModelPayloadIds = {
		TEXT("speech-model/whisper.cpp/base.en"),
		TEXT("speech-vad/whisper.cpp/silero-v6.2.0")
	};
	Health.SupportedModelPayloads = HyperTwistContractLibraryInternal::MakeDefaultSpeechModelPayloads();
	Health.Capabilities.AddUnique(TEXT("externalDictationShell"));
	Health.Capabilities.AddUnique(TEXT("speechTranscriptHistoryShell"));
	Health.Capabilities.AddUnique(TEXT("speechOutputRoutingShell"));
	Health.Capabilities.AddUnique(TEXT("speechTranscriptPostProcessOverlay"));
	Health.Capabilities.AddUnique(TEXT("speechGlobalHotkeyShell"));
	Health.Capabilities.AddUnique(TEXT("speechDeviceSelectionShell"));
	Health.Capabilities.AddUnique(TEXT("speechMuteWhileRecordingShell"));
	Health.Capabilities.AddUnique(TEXT("speechMicrophoneModeShell"));
	Health.Capabilities.AddUnique(TEXT("speechLocalModelCatalogShell"));
	Health.Capabilities.AddUnique(TEXT("speechModelIntegrityShell"));
	Health.Capabilities.AddUnique(TEXT("speechModelUnloadPolicyShell"));
	Health.Capabilities.AddUnique(TEXT("downloadableModelPayloadCustody"));
	Health.Capabilities.AddUnique(TEXT("payloadIntegrityReview"));
	Health.bReady = true;
	return Health;
}

TArray<FHyperTwistVoiceProfileSummary> UHyperTwistContractLibrary::MakeSampleVoiceProfiles()
{
	return {
		HyperTwistContractLibraryInternal::MakeVoiceProfile(
			TEXT("en_US-lessac-medium"),
			TEXT("Lessac"),
			TEXT("en_US"),
			TEXT("en"),
			TEXT("US"),
			TEXT("English"),
			TEXT("medium"),
			1,
			TEXT("en/en_US/lessac/medium/MODEL_CARD"),
			{TEXT("en-us-lessac")}
		),
		HyperTwistContractLibraryInternal::MakeVoiceProfile(
			TEXT("en_GB-alan-medium"),
			TEXT("Alan"),
			TEXT("en_GB"),
			TEXT("en"),
			TEXT("GB"),
			TEXT("English"),
			TEXT("medium"),
			1,
			TEXT("en/en_GB/alan/medium/MODEL_CARD"),
			{TEXT("en-gb-alan")}
		),
		HyperTwistContractLibraryInternal::MakeVoiceProfile(
			TEXT("de_DE-thorsten-medium"),
			TEXT("Thorsten"),
			TEXT("de_DE"),
			TEXT("de"),
			TEXT("DE"),
			TEXT("German"),
			TEXT("medium"),
			1,
			TEXT("de/de_DE/thorsten/medium/MODEL_CARD"),
			{TEXT("de-de-thorsten")}
		),
		HyperTwistContractLibraryInternal::MakeVoiceProfile(
			TEXT("multilingual-guide-premium"),
			TEXT("Companion Guide"),
			TEXT("mul"),
			TEXT("mul"),
			TEXT("INTL"),
			TEXT("Multilingual"),
			TEXT("premium"),
			32,
			TEXT("mul/intl/companion-guide/premium/MODEL_CARD"),
			{TEXT("xtts-guide"), TEXT("companion-guide")}
		)
	};
}

FHyperTwistVoiceAssetReviewProfile UHyperTwistContractLibrary::MakeSampleVoiceAssetReviewProfile()
{
	return HyperTwistContractLibraryInternal::MakeDefaultVoiceAssetReviewProfile(
		TEXT("downloadable-voice-asset-review-v1")
	);
}

TArray<FHyperTwistVoiceAssetDescriptor> UHyperTwistContractLibrary::MakeSampleLocalVoiceAssetDescriptors()
{
	return {
		HyperTwistContractLibraryInternal::MakeVoiceAssetDescriptor(
			TEXT("voice-asset/piper/en_US-lessac-medium"),
			TEXT("en_US-lessac-medium"),
			TEXT("en_US-lessac-medium.onnx"),
			TEXT("en/en_US/lessac/medium/en_US-lessac-medium.onnx"),
			TEXT("en/en_US/lessac/medium/MODEL_CARD"),
			63,
			false
		),
		HyperTwistContractLibraryInternal::MakeVoiceAssetDescriptor(
			TEXT("voice-asset/piper/en_GB-alan-medium"),
			TEXT("en_GB-alan-medium"),
			TEXT("en_GB-alan-medium.onnx"),
			TEXT("en/en_GB/alan/medium/en_GB-alan-medium.onnx"),
			TEXT("en/en_GB/alan/medium/MODEL_CARD"),
			64,
			false
		),
		HyperTwistContractLibraryInternal::MakeVoiceAssetDescriptor(
			TEXT("voice-asset/piper/de_DE-thorsten-medium"),
			TEXT("de_DE-thorsten-medium"),
			TEXT("de_DE-thorsten-medium.onnx"),
			TEXT("de/de_DE/thorsten/medium/de_DE-thorsten-medium.onnx"),
			TEXT("de/de_DE/thorsten/medium/MODEL_CARD"),
			71,
			false
		)
	};
}

FHyperTwistVoiceModelReviewProfile UHyperTwistContractLibrary::MakeSampleVoiceModelReviewProfile()
{
	return HyperTwistContractLibraryInternal::MakeDefaultVoiceModelReviewProfile(
		TEXT("downloadable-voice-model-review-v1")
	);
}

TArray<FHyperTwistVoiceModelReviewDescriptor>
UHyperTwistContractLibrary::MakeSampleAdvancedVoiceModelReviewDescriptors()
{
	return {
		HyperTwistContractLibraryInternal::MakeVoiceModelReviewDescriptor(
			TEXT("voice-model-review/coqui/multilingual-premium-v1"),
			TEXT("voice-model/multilingual-premium-v1"),
			TEXT("vocoder/high-fidelity-v1"),
			TEXT("multilingual-guide-premium"),
			TEXT("TTS/.models.json::tts_models/multilingual/multi-dataset/xtts_v2"),
			TEXT("TTS/.models.json"),
			TEXT("mixed-per-model-license-selection-required"),
			TEXT("mixed-payload-license-review-required"),
			true
		)
	};
}

FHyperTwistNarrationSynthesisRequest UHyperTwistContractLibrary::MakeSampleNarrationSynthesisRequest()
{
	FHyperTwistNarrationSynthesisRequest Request;
	Request.RequestId = TEXT("narration_01");
	Request.NarrationContractId = TEXT("embodied-companion-narration");
	Request.ServiceLaneId = TEXT("voice/local-sidecar");
	Request.OutputRouteId = TEXT("companion/narration/local");
	Request.VoiceProfileId = TEXT("en_US-lessac-medium");
	Request.LanguageCode = TEXT("en_US");
	Request.OrchestrationProfile = HyperTwistContractLibraryInternal::MakeLocalNarrationOrchestrationProfile();
	Request.ScriptText = TEXT("Good work. Keep your eyes on the next pair.");
	Request.SubtitleSeedText = Request.ScriptText;
	Request.SpeakerId = 0;
	Request.SpeakerProfileId = TEXT("speaker/default");
	Request.LengthScale = 1.0f;
	Request.NoiseScale = 0.667f;
	Request.NoiseW = 0.8f;
	Request.SentenceSilenceSeconds = 0.2f;
	Request.bSplitSentences = false;
	Request.bPreferCuda = false;
	Request.AudioEncodingHint = TEXT("wav-pcm16-mono");
	return Request;
}

FHyperTwistNarrationSynthesisRequest UHyperTwistContractLibrary::MakeSampleAdvancedNarrationSynthesisRequest()
{
	FHyperTwistNarrationSynthesisRequest Request;
	Request.RequestId = TEXT("narration_advanced_01");
	Request.NarrationContractId = TEXT("embodied-companion-narration");
	Request.ServiceLaneId = TEXT("voice/python-service");
	Request.OutputRouteId = TEXT("companion/narration/local");
	Request.VoiceProfileId = TEXT("multilingual-guide-premium");
	Request.LanguageCode = TEXT("fr_FR");
	Request.OrchestrationProfile = HyperTwistContractLibraryInternal::MakeAdvancedNarrationOrchestrationProfile();
	Request.ScriptText = TEXT("Bien joue. Garde les coins alignes pour le prochain exercice.");
	Request.SubtitleSeedText = Request.ScriptText;
	Request.SpeakerId = 7;
	Request.SpeakerProfileId = TEXT("speaker/companion-guide");
	Request.ReferenceVoiceSampleRef = TEXT("mock://voice/companion-guide/reference");
	Request.LengthScale = 0.95f;
	Request.NoiseScale = 0.5f;
	Request.NoiseW = 0.7f;
	Request.SentenceSilenceSeconds = 0.12f;
	Request.bSplitSentences = true;
	Request.bPreferCuda = true;
	Request.AudioEncodingHint = TEXT("wav-pcm16-mono");
	return Request;
}

FHyperTwistNarrationSynthesisResult UHyperTwistContractLibrary::MakeMockNarrationSynthesisResult()
{
	const FHyperTwistNarrationSynthesisRequest Request = MakeSampleNarrationSynthesisRequest();

	FHyperTwistNarrationSynthesisResult Result;
	Result.RequestId = Request.RequestId;
	Result.NarrationContractId = Request.NarrationContractId;
	Result.ServiceLaneId = Request.ServiceLaneId;
	Result.OutputRouteId = Request.OutputRouteId;
	Result.VoiceProfileId = Request.VoiceProfileId;
	Result.LanguageCode = Request.LanguageCode;
	Result.OrchestrationProfileId = Request.OrchestrationProfile.OrchestrationProfileId;
	Result.ModelBindingId = Request.OrchestrationProfile.ModelBindingId;
	Result.VocoderBindingId = Request.OrchestrationProfile.VocoderBindingId;
	Result.SpeakerProfileId = Request.SpeakerProfileId.IsEmpty()
		? Request.OrchestrationProfile.DefaultSpeakerProfileId
		: Request.SpeakerProfileId;
	Result.SubtitleText = Request.SubtitleSeedText;
	Result.AudioEncoding = TEXT("wav-pcm16-mono");
	Result.SampleRateHz = 16000;
	Result.ChannelCount = 1;
	Result.DurationMs = 1400;
	Result.AppliedLengthScale = Request.LengthScale;
	Result.AppliedNoiseScale = Request.NoiseScale;
	Result.AppliedNoiseW = Request.NoiseW;
	Result.AppliedSentenceSilenceSeconds = Request.SentenceSilenceSeconds;
	Result.bUsedSentenceSplitting = Request.bSplitSentences || Request.OrchestrationProfile.bEnableSentenceSplitting;
	Result.bUsedSpeakerSelection =
		Request.OrchestrationProfile.bEnableSpeakerSelection && !Result.SpeakerProfileId.IsEmpty();
	Result.bUsedSpeakerReferenceConditioning =
		Request.OrchestrationProfile.bEnableSpeakerReferenceConditioning && !Request.ReferenceVoiceSampleRef.IsEmpty();
	Result.AudioBytes = HyperTwistContractLibraryInternal::MakeSilentMonoPcm16Wav(
		Result.SampleRateHz,
		Result.DurationMs
	);
	return Result;
}

FHyperTwistVoiceServiceHealth UHyperTwistContractLibrary::MakeMockVoiceServiceHealth()
{
	FHyperTwistVoiceServiceHealth Health;
	Health.ProviderLabel = TEXT("mock");
	Health.ServiceVersion = TEXT("mock-voice/v1");
	Health.ServiceEndpoint = TEXT("in-process://mock");
	Health.Capabilities = {
		TEXT("voiceCatalog"),
		TEXT("offlineNarration"),
		TEXT("wavOutput"),
		TEXT("subtitleSeed"),
		TEXT("localProfileCatalog"),
		TEXT("multiSpeakerNarration"),
		TEXT("multiLingualNarration"),
		TEXT("speakerReferenceConditioning"),
		TEXT("sentenceSplitNarration"),
		TEXT("modelBindingSelection"),
		TEXT("vocoderBindingSelection"),
		TEXT("downloadableVoiceAssetReview"),
		TEXT("voiceModelCardReview"),
		TEXT("downloadableVoiceModelReview"),
		TEXT("modelLicenseSelectionReview"),
		TEXT("termsAcceptanceReview")
	};

	for (const FHyperTwistVoiceProfileSummary& Profile : MakeSampleVoiceProfiles())
	{
		Health.SupportedVoiceProfileIds.Add(Profile.VoiceProfileId);
	}

	Health.VoiceAssetReviewProfileId = TEXT("downloadable-voice-asset-review-v1");
	Health.VoiceAssetReviewProfileDefinition = MakeSampleVoiceAssetReviewProfile();
	for (const FHyperTwistVoiceAssetDescriptor& VoiceAsset : MakeSampleLocalVoiceAssetDescriptors())
	{
		Health.SupportedVoiceAssetIds.Add(VoiceAsset.VoiceAssetId);
		Health.SupportedVoiceAssets.Add(VoiceAsset);
	}
	Health.VoiceModelReviewProfileId = TEXT("downloadable-voice-model-review-v1");
	Health.VoiceModelReviewProfileDefinition = MakeSampleVoiceModelReviewProfile();
	for (const FHyperTwistVoiceModelReviewDescriptor& Review :
		MakeSampleAdvancedVoiceModelReviewDescriptors())
	{
		Health.SupportedVoiceModelReviewIds.Add(Review.VoiceModelReviewId);
		Health.SupportedVoiceModelReviews.Add(Review);
	}

	Health.SupportedOrchestrationProfiles = {
		TEXT("local-basic-narration-v1"),
		TEXT("python-multispeaker-narration-v1")
	};
	Health.SupportedModelBindingIds = {
		TEXT("voice-model/local-offline-medium-v1"),
		TEXT("voice-model/multilingual-premium-v1")
	};
	Health.SupportedVocoderBindingIds = {
		TEXT("vocoder/default-mono-v1"),
		TEXT("vocoder/high-fidelity-v1")
	};

	Health.bReady = true;
	return Health;
}

FHyperTwistContentPack UHyperTwistContractLibrary::MakeSampleAlgTrainerContentPack()
{
	return UHyperTwistTrainingCatalogLibrary::MakeAlgTrainerStarterContentPack();
}

FHyperTwistContentPack UHyperTwistContractLibrary::MakeSampleCrossTrainerContentPack()
{
	return UHyperTwistTrainingCatalogLibrary::MakeCrossTrainerStarterContentPack();
}

FHyperTwistContentPack UHyperTwistContractLibrary::MakeSampleFiveStyleContentPack()
{
	return UHyperTwistTrainingCatalogLibrary::MakeFiveStyleStarterContentPack();
}

FHyperTwistTrainingCatalogImportLoadReport UHyperTwistContractLibrary::MakeBundledCatalogMaterializationLoadReport()
{
	FHyperTwistTrainingCatalogMaterializedBundle MaterializedBundle;
	FHyperTwistTrainingCatalogImportLoadReport LoadReport;
	UHyperTwistTrainingCatalogLibrary::LoadBundledCatalogMaterializationBundle(
		MaterializedBundle,
		LoadReport
	);
	return LoadReport;
}

FHyperTwistTrainingRunState UHyperTwistContractLibrary::MakeSampleTrainingRunState()
{
	const FHyperTwistContentPack ContentPack = MakeSampleAlgTrainerContentPack();
	FHyperTwistTrainingDeck DefaultDeck;
	if (!UHyperTwistTrainingCatalogLibrary::TryGetDefaultDeckFromContentPack(ContentPack, DefaultDeck))
	{
		return FHyperTwistTrainingRunState();
	}

	return UHyperTwistTrainingLibrary::StartTrainingRun(
		DefaultDeck,
		TEXT("local-user"),
		TEXT("training_session_01"),
		EHyperTwistTrainingDeliveryMode::Timer
	);
}

FHyperTwistTrainingMethodDrillDefinition UHyperTwistContractLibrary::MakeSampleMethodDrillDefinition()
{
	FHyperTwistTrainingMethodDrillDefinition DrillDefinition =
		UHyperTwistTrainingLibrary::BuildMethodDrillDefinitionFromDeck(
			HyperTwistContractLibraryInternal::MakeSampleMethodDrillDeck(),
			EHyperTwistTrainingDrillModeKind::Recognition,
			EHyperTwistTrainingDrillVisibilityPolicy::MaskedState,
			true,
			EHyperTwistTrainingDrillEntrySource::Catalog
		);
	DrillDefinition.Title = TEXT("Roux First Block Recognition Drill");
	DrillDefinition.StageId = TEXT("first-block");
	DrillDefinition.StageLabel = TEXT("First Block");
	return DrillDefinition;
}

FHyperTwistTrainingMethodDrillRunState UHyperTwistContractLibrary::MakeSampleMethodDrillRunState()
{
	const FHyperTwistTrainingMethodDrillDefinition DrillDefinition = MakeSampleMethodDrillDefinition();
	if (!DrillDefinition.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillRunState();
	}

	const FHyperTwistTrainingMethodDrillRunState ReadyRun = UHyperTwistTrainingLibrary::StartMethodDrillRun(
		DrillDefinition,
		TEXT("local-user"),
		TEXT("method_drill_run_01")
	);

	FHyperTwistTrainingMethodDrillRunState ActiveRun = UHyperTwistTrainingLibrary::StartNextMethodDrillCase(ReadyRun);
	if (!ActiveRun.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillRunState();
	}

	ActiveRun.StartedAtUtc = TEXT("2026-04-25T12:12:00Z");
	ActiveRun.LastUpdatedAtUtc = TEXT("2026-04-25T12:12:05Z");
	return ActiveRun;
}

FHyperTwistTrainingMethodDrillSummary UHyperTwistContractLibrary::MakeSampleMethodDrillSummary()
{
	return UHyperTwistTrainingLibrary::DeriveMethodDrillSummary(MakeSampleMethodDrillRunState());
}

FHyperTwistTrainingMethodDrillFavoriteEntry UHyperTwistContractLibrary::MakeSampleMethodDrillFavoriteEntry()
{
	return UHyperTwistTrainingRepositoryLibrary::MakeMethodDrillFavoriteEntry(
		MakeSampleMethodDrillDefinition(),
		TEXT("local-user"),
		TEXT("roux-block-case-01"),
		TEXT("2026-04-25T12:11:00Z")
	);
}

FHyperTwistTrainingMethodDrillBatch UHyperTwistContractLibrary::MakeSampleMethodDrillBatch()
{
	FHyperTwistTrainingMethodDrillRunState RunState = MakeSampleMethodDrillRunState();
	if (!RunState.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillBatch();
	}

	RunState = UHyperTwistTrainingLibrary::RevealMethodDrillCase(RunState);

	FHyperTwistTrainingMethodDrillResponseRecord ResponseRecord;
	ResponseRecord.ResponseId = TEXT("method_drill_response_01");
	ResponseRecord.DrillRunId = RunState.RunId;
	ResponseRecord.CaseId = RunState.CurrentCase.CaseId;
	ResponseRecord.PresentedAtUtc = RunState.StartedAtUtc;
	ResponseRecord.RespondedAtUtc = TEXT("2026-04-25T12:13:00Z");
	ResponseRecord.DrillMode = RunState.DrillDefinition.DrillMode;
	ResponseRecord.VisibilityPolicy = RunState.DrillDefinition.VisibilityPolicy;
	ResponseRecord.bAnswerWasRevealed = true;
	ResponseRecord.bMarkedCorrect = true;
	ResponseRecord.bWasRepeat = false;
	ResponseRecord.ElapsedMs = 1850;
	ResponseRecord.ResponseText = TEXT("identified left block anchor and follow-up pair");
	RunState.Responses.Add(ResponseRecord);
	RunState.LastUpdatedAtUtc = ResponseRecord.RespondedAtUtc;

	return UHyperTwistTrainingLibrary::BuildMethodDrillBatch(
		RunState,
		TEXT("method_drill_batch_01"),
		TEXT("Pinned Roux Recognition Queue"),
		true
	);
}

FHyperTwistTrainingMethodDrillDefinition UHyperTwistContractLibrary::MakeSampleFavoriteFirstMethodDrillDefinition()
{
	const FHyperTwistTrainingMethodDrillDefinition BaseDefinition = MakeSampleMethodDrillDefinition();
	if (!BaseDefinition.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillDefinition();
	}

	TArray<FHyperTwistTrainingMethodDrillFavoriteEntry> Favorites;
	FHyperTwistTrainingMethodDrillFavoriteEntry FavoriteEntry = MakeSampleMethodDrillFavoriteEntry();
	FavoriteEntry.CaseId = TEXT("roux-block-case-02");
	Favorites.Add(FavoriteEntry);
	return UHyperTwistTrainingRepositoryLibrary::BuildDrillDefinitionFavoriteFirst(
		BaseDefinition,
		Favorites,
		1
	);
}

FHyperTwistTrainingMethodDrillBatchReadiness UHyperTwistContractLibrary::MakeSampleMethodDrillBatchReadiness()
{
	return UHyperTwistTrainingRepositoryLibrary::DeriveDrillBatchReadiness(
		MakeSampleMethodDrillBatch(),
		MakeSampleMethodDrillDefinition()
	);
}

FHyperTwistTrainingDrillCaseModeCompatibility UHyperTwistContractLibrary::MakeSampleMethodDrillCaseModeCompatibility()
{
	const FHyperTwistTrainingMethodDrillDefinition DrillDefinition = MakeSampleMethodDrillDefinition();
	if (!DrillDefinition.IsStructurallyValid() || DrillDefinition.SourceDeck.Cases.Num() == 0)
	{
		return FHyperTwistTrainingDrillCaseModeCompatibility();
	}

	return UHyperTwistTrainingLibrary::DeriveDrillCaseModeCompatibility(
		DrillDefinition.SourceDeck.Cases[0],
		DrillDefinition.DrillMode,
		DrillDefinition.VisibilityPolicy
	);
}

FHyperTwistTrainingMethodDrillDiagnosticPacket UHyperTwistContractLibrary::MakeSampleMethodDrillDiagnosticPacket()
{
	const FHyperTwistTrainingMethodDrillDefinition DrillDefinition = MakeSampleMethodDrillDefinition();
	if (!DrillDefinition.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillDiagnosticPacket();
	}

	FHyperTwistTrainingMethodDrillRunState RunState = UHyperTwistTrainingLibrary::StartMethodDrillRun(
		DrillDefinition,
		TEXT("local-user"),
		TEXT("method_drill_run_diagnostics_01")
	);
	if (!RunState.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillDiagnosticPacket();
	}

	RunState.StartedAtUtc = TEXT("2026-04-29T09:00:00Z");
	RunState.LastUpdatedAtUtc = RunState.StartedAtUtc;
	RunState = UHyperTwistTrainingLibrary::StartNextMethodDrillCase(RunState);
	if (!RunState.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillDiagnosticPacket();
	}

	RunState = UHyperTwistTrainingLibrary::RevealMethodDrillCase(RunState);

	FHyperTwistTrainingMethodDrillResponseRecord AssistedResponse;
	AssistedResponse.ResponseId = TEXT("method_drill_diag_response_01");
	AssistedResponse.DrillRunId = RunState.RunId;
	AssistedResponse.CaseId = RunState.CurrentCase.CaseId;
	AssistedResponse.PresentedAtUtc = TEXT("2026-04-29T09:00:05Z");
	AssistedResponse.RespondedAtUtc = TEXT("2026-04-29T09:00:17Z");
	AssistedResponse.DrillMode = RunState.DrillDefinition.DrillMode;
	AssistedResponse.VisibilityPolicy = RunState.DrillDefinition.VisibilityPolicy;
	AssistedResponse.bAnswerWasRevealed = true;
	AssistedResponse.bMarkedCorrect = true;
	AssistedResponse.bWasRepeat = false;
	AssistedResponse.ElapsedMs = 1700;
	AssistedResponse.ResponseText = TEXT("recognized left block after reveal");
	RunState.Responses.Add(AssistedResponse);
	RunState.LastUpdatedAtUtc = AssistedResponse.RespondedAtUtc;
	RunState = UHyperTwistTrainingLibrary::AdvanceMethodDrillCase(RunState);
	RunState = UHyperTwistTrainingLibrary::StartNextMethodDrillCase(RunState);
	if (!RunState.IsStructurallyValid())
	{
		return FHyperTwistTrainingMethodDrillDiagnosticPacket();
	}

	FHyperTwistTrainingMethodDrillResponseRecord RepeatResponseA;
	RepeatResponseA.ResponseId = TEXT("method_drill_diag_response_02");
	RepeatResponseA.DrillRunId = RunState.RunId;
	RepeatResponseA.CaseId = RunState.CurrentCase.CaseId;
	RepeatResponseA.PresentedAtUtc = TEXT("2026-04-29T09:00:20Z");
	RepeatResponseA.RespondedAtUtc = TEXT("2026-04-29T09:00:31Z");
	RepeatResponseA.DrillMode = RunState.DrillDefinition.DrillMode;
	RepeatResponseA.VisibilityPolicy = RunState.DrillDefinition.VisibilityPolicy;
	RepeatResponseA.bAnswerWasRevealed = false;
	RepeatResponseA.bMarkedCorrect = false;
	RepeatResponseA.bWasRepeat = false;
	RepeatResponseA.ElapsedMs = 2400;
	RepeatResponseA.ResponseText = TEXT("missed block anchor on first pass");
	RunState.Responses.Add(RepeatResponseA);
	RunState.LastUpdatedAtUtc = RepeatResponseA.RespondedAtUtc;
	RunState = UHyperTwistTrainingLibrary::RepeatMethodDrillCase(RunState);

	FHyperTwistTrainingMethodDrillResponseRecord RepeatResponseB;
	RepeatResponseB.ResponseId = TEXT("method_drill_diag_response_03");
	RepeatResponseB.DrillRunId = RunState.RunId;
	RepeatResponseB.CaseId = RunState.CurrentCase.CaseId;
	RepeatResponseB.PresentedAtUtc = TEXT("2026-04-29T09:00:35Z");
	RepeatResponseB.RespondedAtUtc = TEXT("2026-04-29T09:00:42Z");
	RepeatResponseB.DrillMode = RunState.DrillDefinition.DrillMode;
	RepeatResponseB.VisibilityPolicy = RunState.DrillDefinition.VisibilityPolicy;
	RepeatResponseB.bAnswerWasRevealed = false;
	RepeatResponseB.bMarkedCorrect = true;
	RepeatResponseB.bWasRepeat = true;
	RepeatResponseB.ElapsedMs = 1900;
	RepeatResponseB.ResponseText = TEXT("corrected block anchor after repeat");
	RunState.Responses.Add(RepeatResponseB);
	RunState.LastUpdatedAtUtc = RepeatResponseB.RespondedAtUtc;

	return UHyperTwistTrainingLibrary::DeriveMethodDrillDiagnosticPacket(RunState);
}

FHyperTwistTrainingSessionTemplate UHyperTwistContractLibrary::MakeSampleMethodDrillFollowUpTemplate()
{
	return UHyperTwistTrainingRepositoryLibrary::BuildMethodDrillFollowUpTemplate(
		MakeSampleMethodDrillDiagnosticPacket(),
		TEXT("method_drill_follow_up_template_01")
	);
}

FHyperTwistTrainingRunStepResult UHyperTwistContractLibrary::MakeSampleTrainingRunStepResult()
{
	const FHyperTwistTrainingRunState RunState = MakeSampleTrainingRunState();
	if (!RunState.IsStructurallyValid())
	{
		return FHyperTwistTrainingRunStepResult();
	}

	FHyperTwistTrainingAttempt Attempt;
	Attempt.AttemptId = TEXT("attempt_01");
	Attempt.TrainingSessionId = RunState.Session.TrainingSessionId;
	Attempt.CaseId = RunState.Session.CurrentCaseId;
	Attempt.Result = EHyperTwistTrainingAttemptResult::Success;
	Attempt.RecognitionTimeMs = 0;
	Attempt.Mistakes = 0;
	Attempt.ReplayId = RunState.ReplayPacket.ReplayId;
	Attempt.CompletedAtUtc = TEXT("2026-04-25T12:02:14Z");
	Attempt.TimingBreakdown = MakeSampleTrainingTimingBreakdown();

	return UHyperTwistTrainingLibrary::ResolveTrainingRunAttempt(RunState, Attempt, 0);
}

FHyperTwistTrainingSessionSummary UHyperTwistContractLibrary::MakeSampleTrainingRunSummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	return StepResult.SessionSummary;
}

FHyperTwistTrainingTimingPolicy UHyperTwistContractLibrary::MakeSampleTrainingTimingPolicy()
{
	FHyperTwistTrainingTimingPolicy TimingPolicy;
	TimingPolicy.bInspectionEnabled = true;
	TimingPolicy.InspectionDurationMs = 15000;
	TimingPolicy.bInspectionPenaltiesEnabled = true;
	TimingPolicy.bAllowManualPenalty = true;
	TimingPolicy.bHideRunningTime = false;

	FHyperTwistTrainingSplitPhaseDefinition RecognitionPhase;
	RecognitionPhase.PhaseId = TEXT("recognition");
	RecognitionPhase.Label = TEXT("Recognition");
	RecognitionPhase.Order = 0;

	FHyperTwistTrainingSplitPhaseDefinition ExecutionPhase;
	ExecutionPhase.PhaseId = TEXT("execution");
	ExecutionPhase.Label = TEXT("Execution");
	ExecutionPhase.Order = 1;

	TimingPolicy.SplitPhases = {RecognitionPhase, ExecutionPhase};
	return TimingPolicy;
}

FHyperTwistTrainingTimingBreakdown UHyperTwistContractLibrary::MakeSampleTrainingTimingBreakdown()
{
	FHyperTwistTrainingTimingBreakdown TimingBreakdown;
	TimingBreakdown.InspectionElapsedMs = 14750;
	TimingBreakdown.RawSolveTimeMs = 2214;
	TimingBreakdown.ManualPenalty = EHyperTwistTrainingPenalty::None;
	TimingBreakdown.InspectionPenalty = EHyperTwistTrainingPenalty::None;
	TimingBreakdown.AppliedPenalty = EHyperTwistTrainingPenalty::None;
	TimingBreakdown.PenaltyOffsetMs = 0;
	TimingBreakdown.FinalTimeMs = 2214;
	TimingBreakdown.bDidNotFinish = false;

	FHyperTwistTrainingSplitCapture RecognitionCapture;
	RecognitionCapture.PhaseId = TEXT("recognition");
	RecognitionCapture.Label = TEXT("Recognition");
	RecognitionCapture.TimestampMs = 620;

	TimingBreakdown.SplitCaptures = {RecognitionCapture};
	return TimingBreakdown;
}

FHyperTwistTrainingRepositoryState UHyperTwistContractLibrary::MakeSampleTrainingRepositoryState()
{
	FHyperTwistTrainingRepositoryState RepositoryState =
		HyperTwistContractLibraryInternal::BuildSampleTrainingRepositoryStateBase();

	const FHyperTwistTrainingReviewPlanState ReviewPlanState = MakeSampleTrainingReviewPlanState();
	if (ReviewPlanState.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertReviewPlan(
			RepositoryState,
			ReviewPlanState
		);
	}

	return RepositoryState;
}

FHyperTwistMemoryLedgerState UHyperTwistContractLibrary::MakeSampleTrainingMemoryLedgerState()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);

	const FString UserId =
		HyperTwistContractLibraryInternal::ResolveSampleRepositoryUserId(RepositoryState);

	if (UserId.IsEmpty())
	{
		return FHyperTwistMemoryLedgerState();
	}

	return UHyperTwistMemoryCoreLibrary::DeriveMemoryLedgerState(
		RepositoryState,
		UserId,
		TEXT("2026-04-28T12:40:00Z")
	);
}

FHyperTwistMemoryChronicleContinuityState
	UHyperTwistContractLibrary::MakeSampleTrainingMemoryChronicleContinuityState()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);

	const FString UserId =
		HyperTwistContractLibraryInternal::ResolveSampleRepositoryUserId(RepositoryState);
	if (UserId.IsEmpty())
	{
		return FHyperTwistMemoryChronicleContinuityState();
	}

	return UHyperTwistMemoryCoreLibrary::DeriveMemoryChronicleContinuityState(
		RepositoryState,
		UserId,
		TEXT("2026-04-28T12:40:00Z")
	);
}

FHyperTwistMemoryRecallSharedContextState
	UHyperTwistContractLibrary::MakeSampleTrainingMemoryRecallSharedContextState()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);

	const FString UserId =
		HyperTwistContractLibraryInternal::ResolveSampleRepositoryUserId(RepositoryState);
	if (UserId.IsEmpty())
	{
		return FHyperTwistMemoryRecallSharedContextState();
	}

	return UHyperTwistMemoryCoreLibrary::DeriveMemoryRecallSharedContextState(
		RepositoryState,
		UserId,
		TEXT("2026-04-28T12:40:00Z"),
		TEXT("resume review coach history")
	);
}

FHyperTwistMemoryCognitiveConsolidationState
	UHyperTwistContractLibrary::MakeSampleTrainingMemoryCognitiveConsolidationState()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);

	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
	}

	const FString UserId =
		HyperTwistContractLibraryInternal::ResolveSampleRepositoryUserId(RepositoryState);
	if (UserId.IsEmpty())
	{
		return FHyperTwistMemoryCognitiveConsolidationState();
	}

	return UHyperTwistMemoryCoreLibrary::DeriveMemoryCognitiveConsolidationState(
		RepositoryState,
		UserId,
		TEXT("2026-04-28T12:40:00Z")
	);
}

FHyperTwistMemoryKnowledgeNotesState
	UHyperTwistContractLibrary::MakeSampleTrainingMemoryKnowledgeNotesState()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);

	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
	}

	const FString UserId =
		HyperTwistContractLibraryInternal::ResolveSampleRepositoryUserId(RepositoryState);
	if (UserId.IsEmpty())
	{
		return FHyperTwistMemoryKnowledgeNotesState();
	}

	return UHyperTwistMemoryCoreLibrary::DeriveMemoryKnowledgeNotesState(
		RepositoryState,
		UserId,
		TEXT("2026-04-28T12:40:00Z")
	);
}

FHyperTwistMemoryDerivedAdjunctState
	UHyperTwistContractLibrary::MakeSampleTrainingMemoryDerivedAdjunctState()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);

	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
	}

	const FString UserId =
		HyperTwistContractLibraryInternal::ResolveSampleRepositoryUserId(RepositoryState);
	if (UserId.IsEmpty())
	{
		return FHyperTwistMemoryDerivedAdjunctState();
	}

	return UHyperTwistMemoryCoreLibrary::DeriveMemoryDerivedAdjunctState(
		RepositoryState,
		UserId,
		TEXT("2026-04-28T12:40:00Z"),
		EHyperTwistMemoryContextAssemblyProfile::MaxRetentionMode
	);
}

FHyperTwistSkillRegistryState UHyperTwistContractLibrary::MakeSampleSkillRegistryState()
{
	return UHyperTwistSkillCoreLibrary::DeriveSkillRegistryState();
}

FHyperTwistSkillControlState UHyperTwistContractLibrary::MakeSampleSkillControlState()
{
	return UHyperTwistSkillCoreLibrary::DeriveSkillControlState(
		MakeSampleSkillRegistryState(),
		HyperTwistContractLibraryInternal::MakeSampleSkillControlProfile(true)
	);
}

FHyperTwistSkillControlState UHyperTwistContractLibrary::MakeAllSkillsOffSkillControlState()
{
	return UHyperTwistSkillCoreLibrary::DeriveSkillControlState(
		MakeSampleSkillRegistryState(),
		HyperTwistContractLibraryInternal::MakeSampleSkillControlProfile(false)
	);
}

FHyperTwistSkillAuditLedgerState UHyperTwistContractLibrary::MakeSampleSkillAuditLedgerState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	return UHyperTwistSkillCoreLibrary::DeriveSkillAuditLedgerState(
		RegistryState,
		UHyperTwistSkillCoreLibrary::DeriveSkillControlState(
			RegistryState,
			HyperTwistContractLibraryInternal::MakeSampleSkillAuditControlProfile()
		)
	);
}

FHyperTwistSkillAuthoringHarnessState UHyperTwistContractLibrary::MakeSampleSkillAuthoringHarnessState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState =
		UHyperTwistSkillCoreLibrary::DeriveSkillControlState(
			RegistryState,
			HyperTwistContractLibraryInternal::MakeSampleSkillAuditControlProfile()
		);
	const FHyperTwistSkillAuditLedgerState AuditLedgerState =
		UHyperTwistSkillCoreLibrary::DeriveSkillAuditLedgerState(
			RegistryState,
			ControlState
		);

	return UHyperTwistSkillCoreLibrary::DeriveSkillAuthoringHarnessState(
		RegistryState,
		ControlState,
		AuditLedgerState
	);
}

FHyperTwistSkillAnalyzerWrapperState UHyperTwistContractLibrary::MakeSampleSkillAnalyzerWrapperState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillAnalyzerWrapperState(
		RegistryState,
		ControlState,
		AuthoringHarnessState
	);
}

FHyperTwistSkillCleanRoomCommandContractState
UHyperTwistContractLibrary::MakeSampleSkillCleanRoomCommandContractState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillCleanRoomCommandContractState(
		RegistryState,
		ControlState,
		AuthoringHarnessState
	);
}

FHyperTwistSkillCleanRoomSkillSpecState
UHyperTwistContractLibrary::MakeSampleSkillCleanRoomSkillSpecState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillCleanRoomCommandContractState CommandContractState =
		MakeSampleSkillCleanRoomCommandContractState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillCleanRoomSkillSpecState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		CommandContractState
	);
}

FHyperTwistSkillContinuityResumeState
UHyperTwistContractLibrary::MakeSampleSkillContinuityResumeState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillContinuityResumeState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		MakeSampleTrainingMemoryChronicleContinuityState(),
		MakeSampleTrainingMemoryRecallSharedContextState(),
		MakeSampleTrainingMemoryKnowledgeNotesState()
	);
}

FHyperTwistSkillRecallCompactViewState
UHyperTwistContractLibrary::MakeSampleSkillRecallCompactViewState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillRecallCompactViewState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		MakeSampleTrainingMemoryRecallSharedContextState(),
		MakeSampleTrainingMemoryDerivedAdjunctState()
	);
}

FHyperTwistSkillWorkflowMemoryCaptureState
UHyperTwistContractLibrary::MakeSampleSkillWorkflowMemoryCaptureState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillWorkflowMemoryCaptureState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		MakeSampleTrainingMemoryLedgerState(),
		MakeSampleTrainingMemoryChronicleContinuityState()
	);
}

FHyperTwistSkillExtractionState
UHyperTwistContractLibrary::MakeSampleSkillExtractionState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillExtractionState(
		RegistryState,
		ControlState,
		AuthoringHarnessState
	);
}

FHyperTwistSkillBrowserDiagnosticsState
UHyperTwistContractLibrary::MakeSampleSkillBrowserDiagnosticsState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillExtractionState ExtractionState =
		MakeSampleSkillExtractionState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillBrowserDiagnosticsState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		ExtractionState
	);
}

FHyperTwistSkillDesignShellState
UHyperTwistContractLibrary::MakeSampleSkillDesignShellState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillExtractionState ExtractionState =
		MakeSampleSkillExtractionState();
	const FHyperTwistSkillBrowserDiagnosticsState BrowserDiagnosticsState =
		MakeSampleSkillBrowserDiagnosticsState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillDesignShellState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		ExtractionState,
		BrowserDiagnosticsState
	);
}

FHyperTwistSkillWorkflowReviewState
UHyperTwistContractLibrary::MakeSampleSkillWorkflowReviewState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillExtractionState ExtractionState =
		MakeSampleSkillExtractionState();
	const FHyperTwistSkillWorkflowMemoryCaptureState WorkflowMemoryCaptureState =
		MakeSampleSkillWorkflowMemoryCaptureState();
	const FHyperTwistSkillDesignShellState DesignShellState =
		MakeSampleSkillDesignShellState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillWorkflowReviewState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		ExtractionState,
		WorkflowMemoryCaptureState,
		DesignShellState
	);
}

FHyperTwistSkillImplementationDelegationState
UHyperTwistContractLibrary::MakeSampleSkillImplementationDelegationState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillWorkflowReviewState WorkflowReviewState =
		MakeSampleSkillWorkflowReviewState();
	const FHyperTwistSkillDesignShellState DesignShellState =
		MakeSampleSkillDesignShellState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillImplementationDelegationState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		WorkflowReviewState,
		DesignShellState
	);
}

FHyperTwistSkillPlanOrchestrationState
UHyperTwistContractLibrary::MakeSampleSkillPlanOrchestrationState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillImplementationDelegationState
		ImplementationDelegationState =
			MakeSampleSkillImplementationDelegationState();
	const FHyperTwistSkillWorkflowMemoryCaptureState WorkflowMemoryCaptureState =
		MakeSampleSkillWorkflowMemoryCaptureState();
	const FHyperTwistSkillWorkflowReviewState WorkflowReviewState =
		MakeSampleSkillWorkflowReviewState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillPlanOrchestrationState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		ImplementationDelegationState,
		WorkflowMemoryCaptureState,
		WorkflowReviewState
	);
}

FHyperTwistSkillProviderProfileRoutingState
UHyperTwistContractLibrary::MakeSampleSkillProviderProfileRoutingState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillAnalyzerWrapperState AnalyzerWrapperState =
		MakeSampleSkillAnalyzerWrapperState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillProviderProfileRoutingState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		AnalyzerWrapperState,
		MakeSampleSpeechSessionConfig(),
		MakeMockSpeechServiceHealth()
	);
}

FHyperTwistSkillProviderUsageOperationsAuditState
UHyperTwistContractLibrary::MakeSampleSkillProviderUsageOperationsAuditState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillProviderProfileRoutingState
		ProviderProfileRoutingState = MakeSampleSkillProviderProfileRoutingState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillProviderUsageOperationsAuditState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		ProviderProfileRoutingState,
		MakeSampleSpeechSessionConfig(),
		MakeMockSpeechServiceHealth()
	);
}

FHyperTwistSkillDomainPackFrameworkState
UHyperTwistContractLibrary::MakeSampleSkillDomainPackFrameworkState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillPlanOrchestrationState PlanOrchestrationState =
		MakeSampleSkillPlanOrchestrationState();
	const FHyperTwistSkillProviderUsageOperationsAuditState
		ProviderUsageOperationsAuditState =
			MakeSampleSkillProviderUsageOperationsAuditState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillDomainPackFrameworkState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		PlanOrchestrationState,
		ProviderUsageOperationsAuditState
	);
}

FHyperTwistSkillRetainedDomainPackState
UHyperTwistContractLibrary::MakeSampleSkillRetainedDomainPackState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillDomainPackFrameworkState DomainPackFrameworkState =
		MakeSampleSkillDomainPackFrameworkState();
	const TArray<FHyperTwistContentPack> RetainedContentPacks = {
		MakeSampleAlgTrainerContentPack(),
		MakeSampleCrossTrainerContentPack(),
		MakeSampleFiveStyleContentPack()
	};

	return UHyperTwistSkillCoreLibrary::DeriveSkillRetainedDomainPackState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		DomainPackFrameworkState,
		MakeSampleTrainingRepositoryIntegrityReport(),
		MakeSampleTrainingDeckHistorySummary(),
		MakeSampleTrainingTimingTrendSummary(),
		MakeSampleTrainingPersonalBestSummary(),
		MakeSampleReplayReviewAnalytics(),
		RetainedContentPacks,
		MakeSampleTrainingTimerExportPacket(),
		UHyperTwistTrainingMediaExportLibrary::BuildBundledMediaExportReferenceBundle()
	);
}

FHyperTwistSkillCreativeMediaPackState
UHyperTwistContractLibrary::MakeSampleSkillCreativeMediaPackState()
{
	const FHyperTwistSkillRegistryState RegistryState = MakeSampleSkillRegistryState();
	const FHyperTwistSkillControlState ControlState = MakeSampleSkillControlState();
	const FHyperTwistSkillAuthoringHarnessState AuthoringHarnessState =
		MakeSampleSkillAuthoringHarnessState();
	const FHyperTwistSkillRetainedDomainPackState RetainedDomainPackState =
		MakeSampleSkillRetainedDomainPackState();

	return UHyperTwistSkillCoreLibrary::DeriveSkillCreativeMediaPackState(
		RegistryState,
		ControlState,
		AuthoringHarnessState,
		RetainedDomainPackState,
		MakeSampleReplayReviewAnalytics(),
		MakeSampleTrainingTimerExportPacket(),
		UHyperTwistTrainingMediaExportLibrary::BuildBundledMediaExportReferenceBundle(),
		UHyperTwistTrainingSharedAssetLibrary::BuildBundledSharedAssetReferenceBundle()
	);
}

FHyperTwistTrainingRepositoryIntegrityReport UHyperTwistContractLibrary::MakeSampleTrainingRepositoryIntegrityReport()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	if (RepositoryState.RunRecords.Num() > 0)
	{
		RepositoryState.RunRecords.Add(RepositoryState.RunRecords[0]);
	}
	RepositoryState.RunRecords.Add(FHyperTwistTrainingRunRecord());

	if (RepositoryState.LearnerStates.Num() > 0)
	{
		RepositoryState.LearnerStates.Add(RepositoryState.LearnerStates[0]);
	}
	RepositoryState.LearnerStates.Add(FHyperTwistTrainingCaseLearnerState());

	const FHyperTwistTrainingReviewPlanState ReviewPlanState = MakeSampleTrainingReviewPlanState();
	if (ReviewPlanState.IsStructurallyValid())
	{
		RepositoryState.ReviewPlans.Add(ReviewPlanState);
		RepositoryState.ReviewPlans.Add(ReviewPlanState);
	}
	RepositoryState.ReviewPlans.Add(FHyperTwistTrainingReviewPlanState());

	const TArray<FHyperTwistTrainingSessionTemplate> SessionTemplates = MakeSampleTrainingSessionTemplates();
	if (SessionTemplates.Num() > 0)
	{
		RepositoryState.StoredSessionTemplates.Add(SessionTemplates[0]);
		RepositoryState.StoredSessionTemplates.Add(SessionTemplates[0]);
	}
	RepositoryState.StoredSessionTemplates.Add(FHyperTwistTrainingSessionTemplate());

	const FHyperTwistTrainingMethodDrillFavoriteEntry FavoriteEntry = MakeSampleMethodDrillFavoriteEntry();
	if (FavoriteEntry.IsStructurallyValid())
	{
		RepositoryState.StoredMethodDrillFavorites.Add(FavoriteEntry);
		RepositoryState.StoredMethodDrillFavorites.Add(FavoriteEntry);
	}
	RepositoryState.StoredMethodDrillFavorites.Add(FHyperTwistTrainingMethodDrillFavoriteEntry());

	const FHyperTwistTrainingMethodDrillBatch DrillBatch = MakeSampleMethodDrillBatch();
	if (DrillBatch.IsStructurallyValid())
	{
		RepositoryState.StoredMethodDrillBatches.Add(DrillBatch);
		RepositoryState.StoredMethodDrillBatches.Add(DrillBatch);
	}
	RepositoryState.StoredMethodDrillBatches.Add(FHyperTwistTrainingMethodDrillBatch());

	const FHyperTwistTrainingCoachActionPlan CoachActionPlan = MakeSampleTrainingCoachActionPlan();
	if (CoachActionPlan.IsStructurallyValid())
	{
		RepositoryState.StoredCoachActionPlans.Add(CoachActionPlan);
		RepositoryState.StoredCoachActionPlans.Add(CoachActionPlan);

		FHyperTwistTrainingCoachActionPlan BrokenLineagePlan = CoachActionPlan;
		BrokenLineagePlan.PlanId = TEXT("coach_plan_broken_lineage");
		BrokenLineagePlan.ParentPlanId = TEXT("missing_parent_plan");
		BrokenLineagePlan.RootPlanId = TEXT("missing_root_plan");
		BrokenLineagePlan.SourceSessionId = TEXT("missing_training_session");
		BrokenLineagePlan.SourceReviewPlanId = TEXT("missing_review_plan");
		BrokenLineagePlan.FollowUpDepth = 3;
		RepositoryState.StoredCoachActionPlans.Add(BrokenLineagePlan);

		FHyperTwistTrainingCoachActionPlan CyclicPlan = CoachActionPlan;
		CyclicPlan.PlanId = TEXT("coach_plan_cycle");
		CyclicPlan.ParentPlanId = TEXT("coach_plan_cycle");
		CyclicPlan.RootPlanId = TEXT("coach_plan_cycle");
		CyclicPlan.FollowUpDepth = 2;
		RepositoryState.StoredCoachActionPlans.Add(CyclicPlan);
	}
	RepositoryState.StoredCoachActionPlans.Add(FHyperTwistTrainingCoachActionPlan());

	const FHyperTwistTrainingCoachSessionQueueState CoachSessionQueueState =
		MakeSampleTrainingCoachSessionQueueState();
	if (CoachSessionQueueState.IsStructurallyValid())
	{
		RepositoryState.StoredCoachSessionQueues.Add(CoachSessionQueueState);
		RepositoryState.StoredCoachSessionQueues.Add(CoachSessionQueueState);

		FHyperTwistTrainingCoachSessionQueueState BrokenQueueState = CoachSessionQueueState;
		BrokenQueueState.QueueId = TEXT("coach_queue_broken");
		BrokenQueueState.ActiveEntryId = TEXT("missing_active_entry");
		BrokenQueueState.ActiveTrainingSessionId = TEXT("missing_training_session");
		if (BrokenQueueState.Entries.Num() > 0)
		{
			BrokenQueueState.Entries[0].EntryState = EHyperTwistTrainingCoachSessionQueueEntryState::InProgress;
			BrokenQueueState.Entries[0].SourceTrainingSessionId = TEXT("missing_training_session");
			BrokenQueueState.Entries[0].StartedAtUtc = TEXT("2026-04-28T12:15:00Z");
		}
		RepositoryState.StoredCoachSessionQueues.Add(BrokenQueueState);

		FHyperTwistTrainingCoachSessionQueueHistoryEntry BrokenHistoryEntry;
		BrokenHistoryEntry.HistoryEntryId = TEXT("history_missing_training_session");
		BrokenHistoryEntry.QueueId = BrokenQueueState.QueueId;
		BrokenHistoryEntry.UserId = BrokenQueueState.UserId;
		BrokenHistoryEntry.EntryId = BrokenQueueState.Entries.Num() > 0
			? BrokenQueueState.Entries[0].EntryId
			: TEXT("missing_entry");
		BrokenHistoryEntry.SourceLabel = BrokenQueueState.Entries.Num() > 0
			? BrokenQueueState.Entries[0].SourceLabel
			: TEXT("coach_queue_primary");
		BrokenHistoryEntry.WorkFingerprint = BrokenQueueState.Entries.Num() > 0
			? BrokenQueueState.Entries[0].WorkFingerprint
			: TEXT("broken_history_work");
		BrokenHistoryEntry.EventKind = EHyperTwistTrainingCoachSessionQueueEventKind::Started;
		BrokenHistoryEntry.EventAtUtc = TEXT("2026-04-28T12:15:00Z");
		BrokenHistoryEntry.PreviousEntryState = EHyperTwistTrainingCoachSessionQueueEntryState::Ready;
		BrokenHistoryEntry.NewEntryState = EHyperTwistTrainingCoachSessionQueueEntryState::InProgress;
		BrokenHistoryEntry.SourceTrainingSessionId = TEXT("missing_training_session");
		BrokenHistoryEntry.FocusDeckId = BrokenQueueState.FocusDeckId;
		BrokenHistoryEntry.FocusMethodSegmentId = BrokenQueueState.FocusMethodSegmentId;
		if (BrokenQueueState.Entries.Num() > 0)
		{
			BrokenHistoryEntry.FocusCaseIds = BrokenQueueState.Entries[0].FocusCaseIds;
		}
		RepositoryState.StoredCoachSessionQueueHistory.Add(BrokenHistoryEntry);

		FHyperTwistTrainingCoachSessionQueueHistoryEntry OrphanedQueueHistoryEntry = BrokenHistoryEntry;
		OrphanedQueueHistoryEntry.HistoryEntryId = TEXT("history_missing_queue");
		OrphanedQueueHistoryEntry.QueueId = TEXT("missing_queue");
		RepositoryState.StoredCoachSessionQueueHistory.Add(OrphanedQueueHistoryEntry);

		FHyperTwistTrainingCoachSessionQueueHistoryEntry OrphanedEntryHistoryEntry = BrokenHistoryEntry;
		OrphanedEntryHistoryEntry.HistoryEntryId = TEXT("history_missing_entry_link");
		OrphanedEntryHistoryEntry.QueueId = CoachSessionQueueState.QueueId;
		OrphanedEntryHistoryEntry.EntryId = TEXT("missing_entry_link");
		RepositoryState.StoredCoachSessionQueueHistory.Add(OrphanedEntryHistoryEntry);
	}
	RepositoryState.StoredCoachSessionQueues.Add(FHyperTwistTrainingCoachSessionQueueState());

	return UHyperTwistTrainingRepositoryLibrary::DeriveRepositoryIntegrityReport(RepositoryState);
}

FHyperTwistTrainingDeckHistorySummary UHyperTwistContractLibrary::MakeSampleTrainingDeckHistorySummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingDeckHistorySummary();
	}

	const FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	return UHyperTwistTrainingRepositoryLibrary::DeriveDeckHistorySummary(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId
	);
}

FHyperTwistTrainingTimingTrendSummary UHyperTwistContractLibrary::MakeSampleTrainingTimingTrendSummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingTimingTrendSummary();
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveTimingTrendSummary(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingPersonalBestSummary UHyperTwistContractLibrary::MakeSampleTrainingPersonalBestSummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingPersonalBestSummary();
	}

	return UHyperTwistTrainingRepositoryLibrary::DerivePersonalBestSummary(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingTimerExportPacket UHyperTwistContractLibrary::MakeSampleTrainingTimerExportPacket()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingTimerExportPacket();
	}

	return UHyperTwistTrainingRepositoryLibrary::ExportTimerResultsForDeck(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingTimerExportIntegrityReport UHyperTwistContractLibrary::MakeSampleTrainingTimerExportIntegrityReport()
{
	FHyperTwistTrainingTimerExportPacket TimerExportPacket = MakeSampleTrainingTimerExportPacket();
	TimerExportPacket.FormatVersion.Reset();
	TimerExportPacket.ExportedAtUtc.Reset();
	if (TimerExportPacket.Entries.Num() > 0)
	{
		TimerExportPacket.Entries.Add(TimerExportPacket.Entries[0]);

		FHyperTwistTrainingTimerExportEntry MismatchedEntry = TimerExportPacket.Entries[0];
		MismatchedEntry.AttemptId += TEXT("-mismatch");
		MismatchedEntry.UserId = TEXT("other-user");
		TimerExportPacket.Entries.Add(MismatchedEntry);
	}
	TimerExportPacket.Entries.Add(FHyperTwistTrainingTimerExportEntry());

	return UHyperTwistTrainingRepositoryLibrary::DeriveTimerExportIntegrityReport(TimerExportPacket);
}

FHyperTwistTrainingCaseScopedStats UHyperTwistContractLibrary::MakeSampleTrainingCaseScopedStats()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingCaseScopedStats();
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveCaseScopedStats(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId,
		StepResult.AttemptResolution.UpdatedProgressionMemory.CaseId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingDeckScopedStats UHyperTwistContractLibrary::MakeSampleTrainingDeckScopedStats()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingDeckScopedStats();
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveDeckScopedStats(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingCaseLearnerState UHyperTwistContractLibrary::MakeSampleTrainingCaseLearnerState()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid() || !StepResult.AttemptResolution.NextCaseSelection.IsStructurallyValid())
	{
		return FHyperTwistTrainingCaseLearnerState();
	}

	const FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	FHyperTwistTrainingCaseLearnerState LearnerState;
	if (UHyperTwistTrainingRepositoryLibrary::TryGetLearnerState(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId,
		StepResult.AttemptResolution.UpdatedProgressionMemory.CaseId,
		LearnerState
	))
	{
		return LearnerState;
	}

	return FHyperTwistTrainingCaseLearnerState();
}

FHyperTwistTrainingLearnerDeckStateSummary UHyperTwistContractLibrary::MakeSampleTrainingLearnerDeckStateSummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingLearnerDeckStateSummary();
	}

	const FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	return UHyperTwistTrainingRepositoryLibrary::DeriveLearnerDeckStateSummary(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		StepResult.UpdatedRunState.Session.DeckId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingLearnerProfile UHyperTwistContractLibrary::MakeSampleTrainingLearnerProfile()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingLearnerProfile();
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveLearnerProfile(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingCoachMemorySnapshot UHyperTwistContractLibrary::MakeSampleTrainingCoachMemorySnapshot()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingCoachMemorySnapshot();
	}

	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	FHyperTwistCoachSessionQueueSummary QueueSummary;
	QueueSummary.UserId = StepResult.UpdatedRunState.Session.UserId;
	QueueSummary.ReferenceUtc = TEXT("2026-04-28T12:12:00Z");
	QueueSummary.FocusDeckId = StepResult.UpdatedRunState.Session.DeckId;
	QueueSummary.FocusMethodSegmentId = TEXT("cfop-cross");
	QueueSummary.PrimaryQueueLabel = TEXT("primary-brief");
	QueueSummary.NextQueueLabel = TEXT("follow-up-brief");
	QueueSummary.bHasImmediateQueue = true;
	QueueSummary.bNeedsArchiveAwareSequencing = true;

	FHyperTwistCoachSessionQueueEntry PrimaryEntry;
	PrimaryEntry.EntryId = TEXT("coach_queue_primary");
	PrimaryEntry.SourceLabel = TEXT("primary-brief");
	PrimaryEntry.Priority = EHyperTwistCoachPriority::Elevated;
	PrimaryEntry.PriorityScore = 78.0f;
	PrimaryEntry.Headline = TEXT("Primary coach review block");
	PrimaryEntry.SuggestedMode = EHyperTwistTrainingDeliveryMode::CoachReviewed;
	PrimaryEntry.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
	PrimaryEntry.FocusDeckId = QueueSummary.FocusDeckId;
	PrimaryEntry.FocusMethodSegmentId = QueueSummary.FocusMethodSegmentId;
	PrimaryEntry.FocusCaseIds = { TEXT("cross_case_1"), TEXT("cross_case_2") };
	QueueSummary.Entries.Add(PrimaryEntry);

	FHyperTwistCoachSessionQueueEntry FollowUpEntry;
	FollowUpEntry.EntryId = TEXT("coach_queue_follow_up");
	FollowUpEntry.SourceLabel = TEXT("follow-up-brief");
	FollowUpEntry.Priority = EHyperTwistCoachPriority::Advisory;
	FollowUpEntry.PriorityScore = 61.0f;
	FollowUpEntry.Headline = TEXT("Follow-up coaching block");
	FollowUpEntry.SuggestedMode = EHyperTwistTrainingDeliveryMode::VirtualCube;
	FollowUpEntry.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Scripted;
	FollowUpEntry.FocusDeckId = QueueSummary.FocusDeckId;
	FollowUpEntry.FocusMethodSegmentId = QueueSummary.FocusMethodSegmentId;
	FollowUpEntry.FocusCaseIds = { TEXT("cross_case_2"), TEXT("cross_case_3") };
	FollowUpEntry.bRequiresFollowUp = true;
	QueueSummary.Entries.Add(FollowUpEntry);

	FHyperTwistCoachSessionQueueEntry ArchiveEntry;
	ArchiveEntry.EntryId = TEXT("coach_queue_archive");
	ArchiveEntry.SourceLabel = TEXT("archive-policy");
	ArchiveEntry.Priority = EHyperTwistCoachPriority::Advisory;
	ArchiveEntry.PriorityScore = 56.0f;
	ArchiveEntry.Headline = TEXT("Archive retention review block");
	ArchiveEntry.SuggestedMode = EHyperTwistTrainingDeliveryMode::Timer;
	ArchiveEntry.SuggestedSelectionPolicy = EHyperTwistTrainingSelectionPolicy::Weighted;
	ArchiveEntry.FocusDeckId = QueueSummary.FocusDeckId;
	ArchiveEntry.FocusMethodSegmentId = QueueSummary.FocusMethodSegmentId;
	ArchiveEntry.FocusCaseIds = { TEXT("cross_case_4") };
	ArchiveEntry.bRequiresArchiveRetentionTuning = true;
	QueueSummary.Entries.Add(ArchiveEntry);

	FHyperTwistTrainingCoachSessionQueueState QueueState =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachSessionQueueState(
			QueueSummary,
			TEXT("coach_queue_active"),
			TEXT("2026-04-28T12:12:00Z")
		);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::DeferCoachSessionQueueEntry(
		QueueState,
		TEXT("coach_queue_follow_up"),
		TEXT("2026-04-28T18:00:00Z"),
		TEXT("follow-up-held-behind-primary"),
		false,
		TEXT("2026-04-28T12:13:00Z")
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::DeferCoachSessionQueueEntry(
		QueueState,
		TEXT("coach_queue_follow_up"),
		TEXT("2026-04-28T21:00:00Z"),
		TEXT("manual-reschedule"),
		true,
		TEXT("2026-04-28T12:18:00Z")
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::DeferCoachSessionQueueEntry(
		QueueState,
		TEXT("coach_queue_archive"),
		TEXT("2026-04-29T09:00:00Z"),
		TEXT("archive-retention-window"),
		true,
		TEXT("2026-04-28T12:20:00Z")
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::StartCoachSessionQueueEntryBySourceLabel(
		QueueState,
		TEXT("primary-brief"),
		TEXT("coach_training_session_queued_01"),
		TEXT("2026-04-28T12:22:00Z"),
		FString()
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::FinalizeCoachSessionQueueEntry(
		QueueState,
		TEXT("coach_training_session_queued_01"),
		TEXT("2026-04-28T12:35:00Z"),
		false
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);

	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachMemorySnapshot(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:40:00Z")
	);
}

TArray<FHyperTwistTrainingMethodSegment> UHyperTwistContractLibrary::MakeSampleTrainingMethodSegments()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return TArray<FHyperTwistTrainingMethodSegment>();
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveLearnerMethodSegments(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

TArray<FHyperTwistTrainingLearnerPreset> UHyperTwistContractLibrary::MakeSampleTrainingLearnerPresets()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return TArray<FHyperTwistTrainingLearnerPreset>();
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveLearnerPresets(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

TArray<FHyperTwistTrainingSessionTemplate> UHyperTwistContractLibrary::MakeSampleTrainingSessionTemplates()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return TArray<FHyperTwistTrainingSessionTemplate>();
	}

	const FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	const TArray<FHyperTwistTrainingSessionTemplate> DerivedTemplates =
		UHyperTwistTrainingRepositoryLibrary::DeriveTrainingSessionTemplates(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:05:00Z")
	);
	return UHyperTwistTrainingRepositoryLibrary::MergeTrainingSessionTemplates(
		DerivedTemplates,
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId
	);
}

FHyperTwistTrainingSessionTemplate UHyperTwistContractLibrary::MakeSampleCustomizedTrainingSessionTemplate()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingSessionTemplate();
	}

	const TArray<FHyperTwistTrainingSessionTemplate> StoredTemplates =
		UHyperTwistTrainingRepositoryLibrary::ListStoredTrainingSessionTemplates(
			MakeSampleTrainingRepositoryState(),
			StepResult.UpdatedRunState.Session.UserId
		);
	return StoredTemplates.Num() > 0 ? StoredTemplates[0] : FHyperTwistTrainingSessionTemplate();
}

FHyperTwistTrainingDeck UHyperTwistContractLibrary::MakeSampleTrainingSessionTemplateDeck()
{
	const TArray<FHyperTwistTrainingSessionTemplate> Templates = MakeSampleTrainingSessionTemplates();
	if (Templates.Num() == 0)
	{
		return FHyperTwistTrainingDeck();
	}

	return UHyperTwistTrainingCatalogLibrary::MaterializeTrainingSessionTemplateDeck(
		Templates[0],
		UHyperTwistTrainingCatalogLibrary::MakePhase3TrainingCatalog()
	);
}

TArray<FHyperTwistTrainingCaseRecommendation> UHyperTwistContractLibrary::MakeSampleTrainingCaseRecommendations()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return TArray<FHyperTwistTrainingCaseRecommendation>();
	}

	const FHyperTwistTrainingRepositoryState RepositoryState =
		HyperTwistContractLibraryInternal::BuildSampleTrainingRepositoryStateBase();
	return UHyperTwistTrainingRepositoryLibrary::ListCaseRecommendationsForDeck(
		RepositoryState,
		StepResult.UpdatedRunState.ActiveDeck,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:05:00Z"),
		5
	);
}

FHyperTwistTrainingDeck UHyperTwistContractLibrary::MakeSampleTrainingReviewDeck()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingDeck();
	}

	const TArray<FHyperTwistTrainingCaseRecommendation> Recommendations = MakeSampleTrainingCaseRecommendations();
	return UHyperTwistTrainingRepositoryLibrary::BuildReviewDeckFromRecommendations(
		StepResult.UpdatedRunState.ActiveDeck,
		Recommendations,
		2
	);
}

FHyperTwistTrainingReviewPlanState UHyperTwistContractLibrary::MakeSampleTrainingReviewPlanState()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingReviewPlanState();
	}

	const TArray<FHyperTwistTrainingCaseRecommendation> Recommendations = MakeSampleTrainingCaseRecommendations();
	const FHyperTwistTrainingDeck ReviewDeck = MakeSampleTrainingReviewDeck();
	const FHyperTwistTrainingReviewPolicy ReviewPolicy =
		UHyperTwistTrainingRepositoryLibrary::GetDefaultReviewPolicy(EHyperTwistTrainingDeliveryMode::Timer);
	return UHyperTwistTrainingRepositoryLibrary::BuildReviewPlan(
		StepResult.UpdatedRunState.ActiveDeck,
		ReviewDeck,
		StepResult.UpdatedRunState.Session.UserId,
		Recommendations,
		ReviewPolicy,
		TEXT("review_plan_training_session_01"),
		TEXT("2026-04-28T12:05:00Z"),
		EHyperTwistTrainingDeliveryMode::Timer
	);
}

FHyperTwistTrainingReviewFlowStatus UHyperTwistContractLibrary::MakeSampleTrainingReviewFlowStatus()
{
	return UHyperTwistTrainingRepositoryLibrary::DeriveReviewFlowStatus(
		MakeSampleTrainingReviewPlanState()
	);
}

FHyperTwistTrainingReviewProgramSummary UHyperTwistContractLibrary::MakeSampleTrainingReviewProgramSummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingReviewProgramSummary();
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveReviewProgramSummary(
		MakeSampleTrainingRepositoryState(),
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistReplayReviewAnalytics UHyperTwistContractLibrary::MakeSampleReplayReviewAnalytics()
{
	return UHyperTwistReplayReviewLibrary::DeriveReplayReviewAnalytics(
		MakeSampleRuntimeReplayPacket()
	);
}

FHyperTwistRecognitionReplaySummary UHyperTwistContractLibrary::MakeSampleRecognitionReplaySummary()
{
	return UHyperTwistRecognitionReplayLibrary::DeriveRecognitionReplaySummary(
		MakeSampleRecognitionReplayPacket()
	);
}

TArray<FHyperTwistCoachSignal> UHyperTwistContractLibrary::MakeSampleTrainingCoachSignals()
{
	return UHyperTwistTrainingCoachLibrary::DeriveCoachSignals(
		MakeSampleTrainingRunSummary(),
		MakeSampleTrainingDeckScopedStats(),
		MakeSampleTrainingLearnerDeckStateSummary(),
		MakeSampleTrainingLearnerProfile(),
		MakeSampleTrainingCoachMemorySnapshot(),
		MakeSampleTrainingReviewProgramSummary(),
		MakeSampleReplayReviewAnalytics(),
		MakeSampleRecognitionReplaySummary()
	);
}

FHyperTwistCoachBrief UHyperTwistContractLibrary::MakeSampleTrainingCoachBrief()
{
	return UHyperTwistTrainingCoachLibrary::DeriveCoachBrief(
		MakeSampleTrainingRunSummary(),
		MakeSampleTrainingDeckScopedStats(),
		MakeSampleTrainingLearnerDeckStateSummary(),
		MakeSampleTrainingLearnerProfile(),
		MakeSampleTrainingCoachMemorySnapshot(),
		MakeSampleTrainingReviewProgramSummary(),
		MakeSampleReplayReviewAnalytics(),
		MakeSampleRecognitionReplaySummary()
	);
}

FHyperTwistTrainingCoachActionPlan UHyperTwistContractLibrary::MakeSampleTrainingCoachActionPlan()
{
	return UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
		MakeSampleTrainingCoachBrief(),
		MakeSampleTrainingCoachMemorySnapshot(),
		TEXT("coach_plan_training_session_01"),
		TEXT("2026-04-28T12:05:00Z"),
		0,
		0,
		FString(),
		MakeSampleTrainingCoachBrief().FocusCaseIds
	);
}

FHyperTwistTrainingCoachActionPlanSummary UHyperTwistContractLibrary::MakeSampleTrainingCoachActionPlanSummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingCoachActionPlanSummary();
	}

	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);
	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachActionPlanSummary(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:05:00Z")
	);
}

FHyperTwistTrainingCoachActionPlanOutcomeSummary UHyperTwistContractLibrary::MakeSampleTrainingCoachActionPlanOutcomeSummary()
{
	const FHyperTwistTrainingRepositoryState RepositoryState =
		HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(
			MakeSampleTrainingRepositoryState()
		);
	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachActionPlanOutcomeSummary(
		RepositoryState,
		MakeSampleTrainingCoachActionPlan(),
		TEXT("2026-04-28T12:12:00Z")
	);
}

FHyperTwistTrainingCoachActionSequenceSummary UHyperTwistContractLibrary::MakeSampleTrainingCoachActionSequenceSummary()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);
	const FHyperTwistTrainingCoachActionPlan RootPlan = MakeSampleTrainingCoachActionPlan();
	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
		return UHyperTwistTrainingRepositoryLibrary::DeriveCoachActionSequenceSummary(
			RepositoryState,
			FollowUpPlan,
			TEXT("2026-04-28T12:20:00Z")
		);
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachActionSequenceSummary(
		RepositoryState,
		RootPlan,
		TEXT("2026-04-28T12:20:00Z")
	);
}

FHyperTwistTrainingCoachActionClosureSummary UHyperTwistContractLibrary::MakeSampleTrainingCoachActionClosureSummary()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);
	const FHyperTwistTrainingCoachActionPlan RootPlan = MakeSampleTrainingCoachActionPlan();
	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
		return UHyperTwistTrainingRepositoryLibrary::DeriveCoachActionClosureSummary(
			RepositoryState,
			FollowUpPlan,
			TEXT("2026-04-28T12:20:00Z")
		);
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachActionClosureSummary(
		RepositoryState,
		RootPlan,
		TEXT("2026-04-28T12:20:00Z")
	);
}

FHyperTwistTrainingCoachClosureMemorySummary UHyperTwistContractLibrary::MakeSampleTrainingCoachClosureMemorySummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingCoachClosureMemorySummary();
	}

	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);
	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachClosureMemorySummary(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:20:00Z")
	);
}

FHyperTwistTrainingCoachRecommendationHistorySummary UHyperTwistContractLibrary::MakeSampleTrainingCoachRecommendationHistorySummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingCoachRecommendationHistorySummary();
	}

	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);
	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachRecommendationHistorySummary(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:20:00Z")
	);
}

FHyperTwistTrainingCoachCarryForwardPolicySummary UHyperTwistContractLibrary::MakeSampleTrainingCoachCarryForwardPolicySummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingCoachCarryForwardPolicySummary();
	}

	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);
	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachCarryForwardPolicySummary(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:20:00Z")
	);
}

FHyperTwistTrainingCoachArchivePolicySummary UHyperTwistContractLibrary::MakeSampleTrainingCoachArchivePolicySummary()
{
	const FHyperTwistTrainingRunStepResult StepResult = MakeSampleTrainingRunStepResult();
	if (!StepResult.IsStructurallyValid())
	{
		return FHyperTwistTrainingCoachArchivePolicySummary();
	}

	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState);
	const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief();
	const FHyperTwistTrainingCoachActionPlan FollowUpPlan =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan(
			FollowUpBrief,
			MakeSampleTrainingCoachMemorySnapshot(),
			TEXT("coach_follow_up_training_session_02"),
			TEXT("2026-04-28T12:20:00Z"),
			0,
			0,
			FString(),
			FollowUpBrief.FocusCaseIds
		);
	if (FollowUpPlan.IsStructurallyValid())
	{
		RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan(
			RepositoryState,
			FollowUpPlan
		);
	}

	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachArchivePolicySummary(
		RepositoryState,
		StepResult.UpdatedRunState.Session.UserId,
		TEXT("2026-04-28T12:20:00Z")
	);
}

FHyperTwistCoachBrief UHyperTwistContractLibrary::MakeSampleTrainingCoachFollowUpBrief()
{
	return UHyperTwistTrainingCoachLibrary::DeriveCoachFollowUpBrief(
		MakeSampleTrainingCoachBrief(),
		MakeSampleTrainingCoachActionPlan(),
		MakeSampleTrainingCoachActionPlanOutcomeSummary()
	);
}

FHyperTwistCoachSessionQueueSummary UHyperTwistContractLibrary::MakeSampleTrainingCoachSessionQueueSummary()
{
	return HyperTwistContractLibraryInternal::MakeSampleCoachSessionQueueSummaryManual();
}

FHyperTwistTrainingCoachSessionQueueState UHyperTwistContractLibrary::MakeSampleTrainingCoachSessionQueueState()
{
	return HyperTwistContractLibraryInternal::MakeSampleCoachSessionQueueStateManual();
}

FHyperTwistCoachScheduleHorizonSummary UHyperTwistContractLibrary::MakeSampleTrainingCoachScheduleHorizonSummary()
{
	return UHyperTwistTrainingCoachLibrary::DeriveCoachScheduleHorizonSummary(
		MakeSampleTrainingCoachSessionQueueState(),
		MakeSampleTrainingCoachArchivePolicySummary(),
		TEXT("2026-04-28T12:12:00Z")
	);
}

FHyperTwistCoachSchedulePolicySummary UHyperTwistContractLibrary::MakeSampleTrainingCoachSchedulePolicySummary()
{
	return UHyperTwistTrainingCoachLibrary::DeriveCoachSchedulePolicySummary(
		MakeSampleTrainingCoachSessionQueueState(),
		MakeSampleTrainingCoachScheduleHorizonSummary(),
		MakeSampleTrainingCoachActionClosureSummary(),
		UHyperTwistTrainingRepositoryLibrary::DeriveCoachMemorySnapshot(
			MakeSampleTrainingRepositoryState(),
			TEXT("local-user"),
			TEXT("2026-04-28T12:30:00Z")
		),
		MakeSampleTrainingCoachArchivePolicySummary(),
		TEXT("2026-04-28T12:30:00Z")
	);
}

FHyperTwistTrainingCoachSessionQueueExecutionSummary UHyperTwistContractLibrary::MakeSampleTrainingCoachSessionQueueExecutionSummary()
{
	FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState();
	FHyperTwistTrainingCoachSessionQueueState QueueState =
		UHyperTwistTrainingRepositoryLibrary::BuildCoachSessionQueueState(
			MakeSampleTrainingCoachSessionQueueSummary(),
			TEXT("coach_queue_active"),
			TEXT("2026-04-28T12:12:00Z")
		);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::DeferCoachSessionQueueEntry(
		QueueState,
		TEXT("coach_queue_follow_up"),
		TEXT("2026-04-28T18:00:00Z"),
		TEXT("follow-up-held-behind-primary"),
		false,
		TEXT("2026-04-28T12:13:00Z")
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::DeferCoachSessionQueueEntry(
		QueueState,
		TEXT("coach_queue_archive"),
		TEXT("2026-04-29T09:00:00Z"),
		TEXT("archive-retention-window"),
		true,
		TEXT("2026-04-28T12:14:00Z")
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::StartCoachSessionQueueEntryBySourceLabel(
		QueueState,
		TEXT("primary-brief"),
		TEXT("coach_training_session_queued_01"),
		TEXT("2026-04-28T12:20:00Z"),
		FString()
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);
	QueueState = UHyperTwistTrainingRepositoryLibrary::FinalizeCoachSessionQueueEntry(
		QueueState,
		TEXT("coach_training_session_queued_01"),
		TEXT("2026-04-28T12:34:00Z"),
		false
	);
	RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachSessionQueueState(
		RepositoryState,
		QueueState
	);

	return UHyperTwistTrainingRepositoryLibrary::DeriveCoachSessionQueueExecutionSummary(
		RepositoryState,
		TEXT("local-user"),
		TEXT("coach_queue_active"),
		TEXT("2026-04-28T12:40:00Z")
	);
}

bool UHyperTwistContractLibrary::IsPuzzleStateStructurallyValid(const FHyperTwistPuzzleState& State)
{
	return State.IsStructurallyValid();
}

bool UHyperTwistContractLibrary::IsReplayPacketStructurallyValid(const FHyperTwistReplayPacket& Packet)
{
	return Packet.IsStructurallyValid();
}

FString UHyperTwistContractLibrary::SerializePuzzleStateToJson(const FHyperTwistPuzzleState& State)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(State);
}

FString UHyperTwistContractLibrary::SerializeReplayPacketToJson(const FHyperTwistReplayPacket& Packet)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(Packet);
}

FString UHyperTwistContractLibrary::SerializeContentPackToJson(const FHyperTwistContentPack& ContentPack)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(ContentPack);
}

FString UHyperTwistContractLibrary::SerializeMethodDrillDefinitionToJson(
	const FHyperTwistTrainingMethodDrillDefinition& DrillDefinition
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(DrillDefinition);
}

FString UHyperTwistContractLibrary::SerializeMethodDrillRunStateToJson(
	const FHyperTwistTrainingMethodDrillRunState& RunState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(RunState);
}

FString UHyperTwistContractLibrary::SerializeMethodDrillFavoriteEntryToJson(
	const FHyperTwistTrainingMethodDrillFavoriteEntry& FavoriteEntry
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(FavoriteEntry);
}

FString UHyperTwistContractLibrary::SerializeMethodDrillBatchToJson(
	const FHyperTwistTrainingMethodDrillBatch& DrillBatch
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(DrillBatch);
}

FString UHyperTwistContractLibrary::SerializeTrainingRepositoryStateToJson(const FHyperTwistTrainingRepositoryState& RepositoryState)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(RepositoryState);
}

FString UHyperTwistContractLibrary::SerializeMemoryLedgerStateToJson(
	const FHyperTwistMemoryLedgerState& MemoryLedgerState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(MemoryLedgerState);
}

FString UHyperTwistContractLibrary::SerializeMemoryChronicleContinuityStateToJson(
	const FHyperTwistMemoryChronicleContinuityState& ChronicleContinuityState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(ChronicleContinuityState);
}

FString UHyperTwistContractLibrary::SerializeMemoryRecallSharedContextStateToJson(
	const FHyperTwistMemoryRecallSharedContextState& RecallSharedContextState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		RecallSharedContextState
	);
}

FString UHyperTwistContractLibrary::SerializeMemoryCognitiveConsolidationStateToJson(
	const FHyperTwistMemoryCognitiveConsolidationState& CognitiveConsolidationState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		CognitiveConsolidationState
	);
}

FString UHyperTwistContractLibrary::SerializeMemoryKnowledgeNotesStateToJson(
	const FHyperTwistMemoryKnowledgeNotesState& KnowledgeNotesState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		KnowledgeNotesState
	);
}

FString UHyperTwistContractLibrary::SerializeMemoryDerivedAdjunctStateToJson(
	const FHyperTwistMemoryDerivedAdjunctState& DerivedAdjunctState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		DerivedAdjunctState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillRegistryStateToJson(
	const FHyperTwistSkillRegistryState& SkillRegistryState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillRegistryState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillControlStateToJson(
	const FHyperTwistSkillControlState& SkillControlState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillControlState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillAuditLedgerStateToJson(
	const FHyperTwistSkillAuditLedgerState& SkillAuditLedgerState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillAuditLedgerState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillAuthoringHarnessStateToJson(
	const FHyperTwistSkillAuthoringHarnessState& SkillAuthoringHarnessState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillAuthoringHarnessState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillAnalyzerWrapperStateToJson(
	const FHyperTwistSkillAnalyzerWrapperState& SkillAnalyzerWrapperState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillAnalyzerWrapperState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillCleanRoomCommandContractStateToJson(
	const FHyperTwistSkillCleanRoomCommandContractState& SkillCleanRoomCommandContractState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillCleanRoomCommandContractState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillCleanRoomSkillSpecStateToJson(
	const FHyperTwistSkillCleanRoomSkillSpecState& SkillCleanRoomSkillSpecState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillCleanRoomSkillSpecState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillContinuityResumeStateToJson(
	const FHyperTwistSkillContinuityResumeState& SkillContinuityResumeState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillContinuityResumeState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillRecallCompactViewStateToJson(
	const FHyperTwistSkillRecallCompactViewState& SkillRecallCompactViewState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillRecallCompactViewState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillWorkflowMemoryCaptureStateToJson(
	const FHyperTwistSkillWorkflowMemoryCaptureState& SkillWorkflowMemoryCaptureState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillWorkflowMemoryCaptureState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillExtractionStateToJson(
	const FHyperTwistSkillExtractionState& SkillExtractionState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillExtractionState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillBrowserDiagnosticsStateToJson(
	const FHyperTwistSkillBrowserDiagnosticsState& SkillBrowserDiagnosticsState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillBrowserDiagnosticsState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillDesignShellStateToJson(
	const FHyperTwistSkillDesignShellState& SkillDesignShellState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillDesignShellState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillWorkflowReviewStateToJson(
	const FHyperTwistSkillWorkflowReviewState& SkillWorkflowReviewState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillWorkflowReviewState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillImplementationDelegationStateToJson(
	const FHyperTwistSkillImplementationDelegationState& SkillImplementationDelegationState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillImplementationDelegationState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillPlanOrchestrationStateToJson(
	const FHyperTwistSkillPlanOrchestrationState& SkillPlanOrchestrationState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillPlanOrchestrationState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillProviderProfileRoutingStateToJson(
	const FHyperTwistSkillProviderProfileRoutingState&
		SkillProviderProfileRoutingState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillProviderProfileRoutingState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillProviderUsageOperationsAuditStateToJson(
	const FHyperTwistSkillProviderUsageOperationsAuditState&
		SkillProviderUsageOperationsAuditState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillProviderUsageOperationsAuditState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillDomainPackFrameworkStateToJson(
	const FHyperTwistSkillDomainPackFrameworkState&
		SkillDomainPackFrameworkState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillDomainPackFrameworkState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillRetainedDomainPackStateToJson(
	const FHyperTwistSkillRetainedDomainPackState& SkillRetainedDomainPackState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillRetainedDomainPackState
	);
}

FString UHyperTwistContractLibrary::SerializeSkillCreativeMediaPackStateToJson(
	const FHyperTwistSkillCreativeMediaPackState& SkillCreativeMediaPackState
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(
		SkillCreativeMediaPackState
	);
}

FString UHyperTwistContractLibrary::SerializeTrainingTimerExportPacketToJson(
	const FHyperTwistTrainingTimerExportPacket& TimerExportPacket
)
{
	return HyperTwistContractLibraryInternal::SerializeStructToJson(TimerExportPacket);
}

bool UHyperTwistContractLibrary::DeserializePuzzleStateFromJson(const FString& Json, FHyperTwistPuzzleState& OutState)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutState);
}

bool UHyperTwistContractLibrary::DeserializeReplayPacketFromJson(const FString& Json, FHyperTwistReplayPacket& OutPacket)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutPacket);
}

bool UHyperTwistContractLibrary::DeserializeContentPackFromJson(const FString& Json, FHyperTwistContentPack& OutContentPack)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutContentPack);
}

bool UHyperTwistContractLibrary::DeserializeMethodDrillDefinitionFromJson(
	const FString& Json,
	FHyperTwistTrainingMethodDrillDefinition& OutDrillDefinition
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutDrillDefinition);
}

bool UHyperTwistContractLibrary::DeserializeMethodDrillRunStateFromJson(
	const FString& Json,
	FHyperTwistTrainingMethodDrillRunState& OutRunState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutRunState);
}

bool UHyperTwistContractLibrary::DeserializeMethodDrillFavoriteEntryFromJson(
	const FString& Json,
	FHyperTwistTrainingMethodDrillFavoriteEntry& OutFavoriteEntry
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutFavoriteEntry);
}

bool UHyperTwistContractLibrary::DeserializeMethodDrillBatchFromJson(
	const FString& Json,
	FHyperTwistTrainingMethodDrillBatch& OutDrillBatch
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutDrillBatch);
}

bool UHyperTwistContractLibrary::DeserializeTrainingRepositoryStateFromJson(const FString& Json, FHyperTwistTrainingRepositoryState& OutRepositoryState)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutRepositoryState);
}

bool UHyperTwistContractLibrary::DeserializeMemoryLedgerStateFromJson(
	const FString& Json,
	FHyperTwistMemoryLedgerState& OutMemoryLedgerState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutMemoryLedgerState);
}

bool UHyperTwistContractLibrary::DeserializeMemoryChronicleContinuityStateFromJson(
	const FString& Json,
	FHyperTwistMemoryChronicleContinuityState& OutChronicleContinuityState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutChronicleContinuityState
	);
}

bool UHyperTwistContractLibrary::DeserializeMemoryRecallSharedContextStateFromJson(
	const FString& Json,
	FHyperTwistMemoryRecallSharedContextState& OutRecallSharedContextState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutRecallSharedContextState
	);
}

bool UHyperTwistContractLibrary::DeserializeMemoryCognitiveConsolidationStateFromJson(
	const FString& Json,
	FHyperTwistMemoryCognitiveConsolidationState& OutCognitiveConsolidationState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutCognitiveConsolidationState
	);
}

bool UHyperTwistContractLibrary::DeserializeMemoryKnowledgeNotesStateFromJson(
	const FString& Json,
	FHyperTwistMemoryKnowledgeNotesState& OutKnowledgeNotesState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutKnowledgeNotesState
	);
}

bool UHyperTwistContractLibrary::DeserializeMemoryDerivedAdjunctStateFromJson(
	const FString& Json,
	FHyperTwistMemoryDerivedAdjunctState& OutDerivedAdjunctState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutDerivedAdjunctState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillRegistryStateFromJson(
	const FString& Json,
	FHyperTwistSkillRegistryState& OutSkillRegistryState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillRegistryState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillControlStateFromJson(
	const FString& Json,
	FHyperTwistSkillControlState& OutSkillControlState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillControlState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillAuditLedgerStateFromJson(
	const FString& Json,
	FHyperTwistSkillAuditLedgerState& OutSkillAuditLedgerState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillAuditLedgerState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillAuthoringHarnessStateFromJson(
	const FString& Json,
	FHyperTwistSkillAuthoringHarnessState& OutSkillAuthoringHarnessState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillAuthoringHarnessState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillAnalyzerWrapperStateFromJson(
	const FString& Json,
	FHyperTwistSkillAnalyzerWrapperState& OutSkillAnalyzerWrapperState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillAnalyzerWrapperState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillCleanRoomCommandContractStateFromJson(
	const FString& Json,
	FHyperTwistSkillCleanRoomCommandContractState& OutSkillCleanRoomCommandContractState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillCleanRoomCommandContractState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillCleanRoomSkillSpecStateFromJson(
	const FString& Json,
	FHyperTwistSkillCleanRoomSkillSpecState& OutSkillCleanRoomSkillSpecState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillCleanRoomSkillSpecState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillContinuityResumeStateFromJson(
	const FString& Json,
	FHyperTwistSkillContinuityResumeState& OutSkillContinuityResumeState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillContinuityResumeState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillRecallCompactViewStateFromJson(
	const FString& Json,
	FHyperTwistSkillRecallCompactViewState& OutSkillRecallCompactViewState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillRecallCompactViewState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillWorkflowMemoryCaptureStateFromJson(
	const FString& Json,
	FHyperTwistSkillWorkflowMemoryCaptureState& OutSkillWorkflowMemoryCaptureState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillWorkflowMemoryCaptureState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillExtractionStateFromJson(
	const FString& Json,
	FHyperTwistSkillExtractionState& OutSkillExtractionState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillExtractionState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillBrowserDiagnosticsStateFromJson(
	const FString& Json,
	FHyperTwistSkillBrowserDiagnosticsState& OutSkillBrowserDiagnosticsState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillBrowserDiagnosticsState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillDesignShellStateFromJson(
	const FString& Json,
	FHyperTwistSkillDesignShellState& OutSkillDesignShellState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillDesignShellState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillWorkflowReviewStateFromJson(
	const FString& Json,
	FHyperTwistSkillWorkflowReviewState& OutSkillWorkflowReviewState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillWorkflowReviewState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillImplementationDelegationStateFromJson(
	const FString& Json,
	FHyperTwistSkillImplementationDelegationState& OutSkillImplementationDelegationState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillImplementationDelegationState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillPlanOrchestrationStateFromJson(
	const FString& Json,
	FHyperTwistSkillPlanOrchestrationState& OutSkillPlanOrchestrationState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillPlanOrchestrationState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillProviderProfileRoutingStateFromJson(
	const FString& Json,
	FHyperTwistSkillProviderProfileRoutingState&
		OutSkillProviderProfileRoutingState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillProviderProfileRoutingState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillProviderUsageOperationsAuditStateFromJson(
	const FString& Json,
	FHyperTwistSkillProviderUsageOperationsAuditState&
		OutSkillProviderUsageOperationsAuditState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillProviderUsageOperationsAuditState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillDomainPackFrameworkStateFromJson(
	const FString& Json,
	FHyperTwistSkillDomainPackFrameworkState&
		OutSkillDomainPackFrameworkState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillDomainPackFrameworkState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillRetainedDomainPackStateFromJson(
	const FString& Json,
	FHyperTwistSkillRetainedDomainPackState& OutSkillRetainedDomainPackState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillRetainedDomainPackState
	);
}

bool UHyperTwistContractLibrary::DeserializeSkillCreativeMediaPackStateFromJson(
	const FString& Json,
	FHyperTwistSkillCreativeMediaPackState& OutSkillCreativeMediaPackState
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(
		Json,
		OutSkillCreativeMediaPackState
	);
}

bool UHyperTwistContractLibrary::DeserializeTrainingTimerExportPacketFromJson(
	const FString& Json,
	FHyperTwistTrainingTimerExportPacket& OutTimerExportPacket
)
{
	return HyperTwistContractLibraryInternal::DeserializeStructFromJson(Json, OutTimerExportPacket);
}
