#include "HyperTwistSkills/HyperTwistSkillCoreLibrary.h"

namespace HyperTwistSkillCoreLibraryInternal
{
	FHyperTwistSkillCommandBindingDeclaration MakeCommandBinding(
		const TCHAR* CommandSurfaceId,
		const TCHAR* ServiceBindingId,
		const TCHAR* BoundFeatureId,
		const TCHAR* InvocationPattern,
		const bool bRequiresImplementedService,
		const TCHAR* Summary
	)
	{
		FHyperTwistSkillCommandBindingDeclaration Binding;
		Binding.CommandSurfaceId = CommandSurfaceId;
		Binding.ServiceBindingId = ServiceBindingId;
		Binding.BoundFeatureId = BoundFeatureId;
		Binding.InvocationPattern = InvocationPattern;
		Binding.bRequiresImplementedService = bRequiresImplementedService;
		Binding.Summary = Summary;
		return Binding;
	}

	FHyperTwistSkillPermissionScopeDeclaration MakePermissionScope(
		const TCHAR* ScopeId,
		const TCHAR* DisplayLabel,
		const bool bReadsTrainingState,
		const bool bReadsRecognitionState,
		const bool bReadsReplayState,
		const bool bReadsMemoryState,
		const bool bReadsProviderState,
		const bool bMayToggleOptionalAssistiveState,
		const bool bMayEmitDerivedAssistiveOutput,
		const TCHAR* Summary
	)
	{
		FHyperTwistSkillPermissionScopeDeclaration Scope;
		Scope.ScopeId = ScopeId;
		Scope.DisplayLabel = DisplayLabel;
		Scope.bReadsTrainingState = bReadsTrainingState;
		Scope.bReadsRecognitionState = bReadsRecognitionState;
		Scope.bReadsReplayState = bReadsReplayState;
		Scope.bReadsMemoryState = bReadsMemoryState;
		Scope.bReadsProviderState = bReadsProviderState;
		Scope.bMayToggleOptionalAssistiveState = bMayToggleOptionalAssistiveState;
		Scope.bMayEmitDerivedAssistiveOutput = bMayEmitDerivedAssistiveOutput;
		Scope.Summary = Summary;
		return Scope;
	}

	FHyperTwistSkillProvenanceDeclaration MakeProvenanceDeclaration(
		const EHyperTwistSkillLogPolicy LogPolicy,
		const TArray<FString>& ProducedArtifactKinds,
		const bool bRequiresInvocationLoggingWhenEnabled,
		const TCHAR* Summary
	)
	{
		FHyperTwistSkillProvenanceDeclaration Provenance;
		Provenance.LogPolicy = LogPolicy;
		Provenance.ProducedArtifactKinds = ProducedArtifactKinds;
		Provenance.bRequiresCommandProvenanceDeclaration = true;
		Provenance.bRequiresInvocationLoggingWhenEnabled = bRequiresInvocationLoggingWhenEnabled;
		Provenance.Summary = Summary;
		return Provenance;
	}

	FHyperTwistSkillManifestEntry MakeSkillEntry(
		const TCHAR* SkillId,
		const TCHAR* DisplayLabel,
		const TCHAR* OwnerLaneId,
		const TCHAR* OwnerFeatureId,
		const EHyperTwistSkillFamily Family,
		const EHyperTwistSkillStatus Status,
		const bool bEnabledByDefault,
		const bool bVisibleByDefault,
		const TArray<FHyperTwistSkillCommandBindingDeclaration>& CommandBindings,
		const TArray<FHyperTwistSkillPermissionScopeDeclaration>& PermissionScopes,
		const FHyperTwistSkillProvenanceDeclaration& Provenance,
		const TCHAR* Summary
	)
	{
		FHyperTwistSkillManifestEntry Entry;
		Entry.SkillId = SkillId;
		Entry.Version = TEXT("s1a-v1");
		Entry.DisplayLabel = DisplayLabel;
		Entry.OwnerLaneId = OwnerLaneId;
		Entry.OwnerFeatureId = OwnerFeatureId;
		Entry.Family = Family;
		Entry.Status = Status;
		Entry.bOptionalAssistive = true;
		Entry.bEnabledByDefault = bEnabledByDefault;
		Entry.bVisibleByDefault = bVisibleByDefault;
		Entry.bInstalledWhenDisabled = true;
		Entry.bInertWhenDisabled = true;
		Entry.CommandBindings = CommandBindings;
		Entry.PermissionScopes = PermissionScopes;
		Entry.Provenance = Provenance;
		Entry.Summary = Summary;
		return Entry;
	}

	FHyperTwistSkillStatusCount MakeStatusCount(
		const EHyperTwistSkillStatus Status,
		const int32 Count
	)
	{
		FHyperTwistSkillStatusCount StatusCount;
		StatusCount.Status = Status;
		StatusCount.Count = Count;
		return StatusCount;
	}

	FHyperTwistSkillFamilyCount MakeFamilyCount(
		const EHyperTwistSkillFamily Family,
		const int32 Count
	)
	{
		FHyperTwistSkillFamilyCount FamilyCount;
		FamilyCount.Family = Family;
		FamilyCount.Count = Count;
		return FamilyCount;
	}

	FString MakeSkillSettingsSlug(const FString& SkillId)
	{
		FString Slug = SkillId;
		Slug.ReplaceInline(TEXT("/"), TEXT("."));
		Slug.ReplaceInline(TEXT("-"), TEXT("."));
		return Slug;
	}

	FString MakeEnableSettingsKey(const FString& SkillId)
	{
		return TEXT("skills.enabled.") + MakeSkillSettingsSlug(SkillId);
	}

	FString MakeVisibilitySettingsKey(const FString& SkillId)
	{
		return TEXT("skills.visible.") + MakeSkillSettingsSlug(SkillId);
	}

	FString MakeVisibilityGroupId(const EHyperTwistSkillFamily Family)
	{
		switch (Family)
		{
		case EHyperTwistSkillFamily::SubstrateGovernance:
			return TEXT("skill-group/substrate-governance");
		case EHyperTwistSkillFamily::AnalysisReview:
			return TEXT("skill-group/analysis-review");
		case EHyperTwistSkillFamily::MemoryContinuity:
			return TEXT("skill-group/memory-continuity");
		case EHyperTwistSkillFamily::ProviderOperations:
			return TEXT("skill-group/provider-operations");
		case EHyperTwistSkillFamily::TrainingCoaching:
			return TEXT("skill-group/training-coaching");
		case EHyperTwistSkillFamily::BrowserDocsDesign:
			return TEXT("skill-group/browser-docs-design");
		case EHyperTwistSkillFamily::DomainCreative:
			return TEXT("skill-group/domain-creative");
		default:
			return FString();
		}
	}

	FString MakeVisibilityGroupLabel(const EHyperTwistSkillFamily Family)
	{
		switch (Family)
		{
		case EHyperTwistSkillFamily::SubstrateGovernance:
			return TEXT("Substrate Governance");
		case EHyperTwistSkillFamily::AnalysisReview:
			return TEXT("Analysis And Review");
		case EHyperTwistSkillFamily::MemoryContinuity:
			return TEXT("Memory And Continuity");
		case EHyperTwistSkillFamily::ProviderOperations:
			return TEXT("Provider And Operations");
		case EHyperTwistSkillFamily::TrainingCoaching:
			return TEXT("Training And Coaching");
		case EHyperTwistSkillFamily::BrowserDocsDesign:
			return TEXT("Browser, Docs, And Design");
		case EHyperTwistSkillFamily::DomainCreative:
			return TEXT("Domain And Creative");
		default:
			return FString();
		}
	}

	FString MakeVisibilityGroupSettingsKey(const EHyperTwistSkillFamily Family)
	{
		return TEXT("skills.group.visible.")
			+ MakeSkillSettingsSlug(MakeVisibilityGroupId(Family));
	}

	const FHyperTwistSkillControlOverride* FindControlOverride(
		const FHyperTwistSkillControlProfile& ControlProfile,
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillControlOverride& Override : ControlProfile.Overrides)
		{
			if (Override.SkillId == SkillId)
			{
				return &Override;
			}
		}

		return nullptr;
	}

	FHyperTwistSkillMasterSwitchState MakeMasterSwitchState(
		const FHyperTwistSkillControlProfile& ControlProfile
	)
	{
		FHyperTwistSkillMasterSwitchState MasterSwitch;
		MasterSwitch.SettingsKey = TEXT("skills.master.enabled");
		MasterSwitch.DisplayLabel = TEXT("Enable Skills");
		MasterSwitch.bEnabled = ControlProfile.bMasterEnabled;
		MasterSwitch.bDurableSettingExposed = ControlProfile.bDurableSettingsExposed;
		MasterSwitch.bImmediateMenuControlExposed = ControlProfile.bImmediateMenuControlExposed;
		MasterSwitch.bAllSkillsOffSafe = true;
		MasterSwitch.Summary =
			TEXT("Global master gate for optional assistive skills.");
		return MasterSwitch;
	}

	FHyperTwistSkillControlStateEntry MakeControlStateEntry(
		const FHyperTwistSkillManifestEntry& Entry,
		const FHyperTwistSkillControlProfile& ControlProfile
	)
	{
		const FHyperTwistSkillControlOverride* Override =
			FindControlOverride(ControlProfile, Entry.SkillId);
		const bool bRequestedEnabled =
			(Override != nullptr && Override->bHasEnabledOverride)
				? Override->bEnabled
				: Entry.bEnabledByDefault;
		const bool bRequestedVisible =
			(Override != nullptr && Override->bHasVisibilityOverride)
				? Override->bVisible
				: Entry.bVisibleByDefault;

		FHyperTwistSkillControlStateEntry SkillState;
		SkillState.SkillId = Entry.SkillId;
		SkillState.DisplayLabel = Entry.DisplayLabel;
		SkillState.EnableSettingsKey = MakeEnableSettingsKey(Entry.SkillId);
		SkillState.VisibilitySettingsKey = MakeVisibilitySettingsKey(Entry.SkillId);
		SkillState.VisibilityGroupId = MakeVisibilityGroupId(Entry.Family);
		SkillState.Family = Entry.Family;
		SkillState.Status = Entry.Status;
		SkillState.bInstalled = Entry.bInstalledWhenDisabled;
		SkillState.bOptionalAssistive = Entry.bOptionalAssistive;
		SkillState.bRequestedEnabled = bRequestedEnabled;
		SkillState.bEffectiveEnabled = ControlProfile.bMasterEnabled && bRequestedEnabled;
		SkillState.bRequestedVisible = bRequestedVisible;
		SkillState.bEffectiveVisible = bRequestedVisible;
		SkillState.bInertWhenDisabled = Entry.bInertWhenDisabled;
		SkillState.bDurableSettingExposed = ControlProfile.bDurableSettingsExposed;
		SkillState.bImmediateMenuControlExposed = ControlProfile.bImmediateMenuControlExposed;
		SkillState.Summary = Entry.Summary;
		return SkillState;
	}

	void AddOrUpdateVisibilityGroup(
		FHyperTwistSkillControlState& ControlState,
		const FHyperTwistSkillControlStateEntry& SkillState
	)
	{
		FHyperTwistSkillVisibilityGroupState* Group = ControlState.VisibilityGroups.FindByPredicate(
			[&SkillState](const FHyperTwistSkillVisibilityGroupState& ExistingGroup)
			{
				return ExistingGroup.GroupId == SkillState.VisibilityGroupId;
			}
		);

		if (Group == nullptr)
		{
			FHyperTwistSkillVisibilityGroupState NewGroup;
			NewGroup.GroupId = SkillState.VisibilityGroupId;
			NewGroup.DisplayLabel = MakeVisibilityGroupLabel(SkillState.Family);
			NewGroup.VisibilitySettingsKey = MakeVisibilityGroupSettingsKey(SkillState.Family);
			NewGroup.Family = SkillState.Family;
			NewGroup.bGroupVisibleByDefault = SkillState.bRequestedVisible;
			NewGroup.bDurableVisibilityControlExposed = SkillState.bDurableSettingExposed;
			NewGroup.Summary = TEXT("Family-based visibility grouping for optional skills.");
			ControlState.VisibilityGroups.Add(NewGroup);
			Group = &ControlState.VisibilityGroups.Last();
		}

		Group->SkillIds.Add(SkillState.SkillId);
		Group->VisibleSkillCount += SkillState.bEffectiveVisible ? 1 : 0;
		Group->HiddenSkillCount += SkillState.bEffectiveVisible ? 0 : 1;
		Group->bGroupVisibleByDefault |= SkillState.bRequestedVisible;
	}

	FHyperTwistSkillControlProfile MakeDefaultControlProfile()
	{
		FHyperTwistSkillControlProfile ControlProfile;
		ControlProfile.ProfileId = TEXT("skill-controls/default");
		ControlProfile.DisplayLabel = TEXT("Default Skill Controls");
		ControlProfile.bMasterEnabled = true;
		ControlProfile.bDurableSettingsExposed = true;
		ControlProfile.bImmediateMenuControlExposed = true;
		ControlProfile.Summary =
			TEXT("Default first-party skill control profile.");
		return ControlProfile;
	}

	FHyperTwistSkillControlProfile MakeAllSkillsOffControlProfile()
	{
		FHyperTwistSkillControlProfile ControlProfile = MakeDefaultControlProfile();
		ControlProfile.ProfileId = TEXT("skill-controls/all-skills-off");
		ControlProfile.DisplayLabel = TEXT("All Skills Off");
		ControlProfile.bMasterEnabled = false;
		ControlProfile.Summary =
			TEXT("Control profile proving the core product remains valid with all skills off.");
		return ControlProfile;
	}

	const FHyperTwistSkillManifestEntry* FindManifestEntryById(
		const FHyperTwistSkillRegistryState& RegistryState,
		const FString& SkillId
	)
	{
		return RegistryState.Entries.FindByPredicate(
			[&SkillId](const FHyperTwistSkillManifestEntry& Entry)
			{
				return Entry.SkillId == SkillId;
			}
		);
	}

	const FHyperTwistSkillControlStateEntry* FindControlStateEntryById(
		const FHyperTwistSkillControlState& ControlState,
		const FString& SkillId
	)
	{
		return ControlState.SkillStates.FindByPredicate(
			[&SkillId](const FHyperTwistSkillControlStateEntry& Entry)
			{
				return Entry.SkillId == SkillId;
			}
		);
	}

	const FHyperTwistSkillAuthoringExampleState* FindAuthoringExampleBySkillId(
		const FHyperTwistSkillAuthoringHarnessState& HarnessState,
		const FString& SkillId
	)
	{
		return HarnessState.Examples.FindByPredicate(
			[&SkillId](const FHyperTwistSkillAuthoringExampleState& Entry)
			{
				return Entry.SkillId == SkillId;
			}
		);
	}

	bool HasEvalValidationCaseWithMode(
		const FHyperTwistSkillAuthoringHarnessState& HarnessState,
		const FString& SkillId,
		const EHyperTwistSkillValidationExecutionMode ExecutionMode
	);

	TArray<FString> MakeRequiredAuthoringSectionIds();

	bool HasLiveEvalValidationCase(
		const FHyperTwistSkillAuthoringHarnessState& HarnessState,
		const FString& SkillId
	)
	{
		return HasEvalValidationCaseWithMode(
			HarnessState,
			SkillId,
			EHyperTwistSkillValidationExecutionMode::LiveContract
		);
	}

	bool HasEvalValidationCaseWithMode(
		const FHyperTwistSkillAuthoringHarnessState& HarnessState,
		const FString& SkillId,
		const EHyperTwistSkillValidationExecutionMode ExecutionMode
	)
	{
		const FHyperTwistSkillValidationContractCase* ValidationCase =
			HarnessState.ValidationCases.FindByPredicate(
				[&SkillId, ExecutionMode](const FHyperTwistSkillValidationContractCase& Entry)
				{
					return Entry.SkillId == SkillId
						&& Entry.Kind == EHyperTwistSkillValidationContractKind::Eval
						&& Entry.ExecutionMode == ExecutionMode;
				}
			);

		return ValidationCase != nullptr && ValidationCase->IsStructurallyValid();
	}

	FString MakeInvocationSlug(const FString& SkillId)
	{
		FString Slug = MakeSkillSettingsSlug(SkillId);
		Slug.ReplaceInline(TEXT("."), TEXT("-"));
		return Slug;
	}

	FString MakeSkillCustodyClass(const FHyperTwistSkillManifestEntry& Entry)
	{
		return Entry.Status == EHyperTwistSkillStatus::ImplementedNow
			? TEXT("custody/first-party-authoritative")
			: TEXT("custody/first-party-derived-assistive");
	}

	TArray<FString> MakePermissionScopeIds(const FHyperTwistSkillManifestEntry& Entry)
	{
		TArray<FString> ScopeIds;
		for (const FHyperTwistSkillPermissionScopeDeclaration& Scope : Entry.PermissionScopes)
		{
			ScopeIds.Add(Scope.ScopeId);
		}

		return ScopeIds;
	}

	bool IsPermissiveAnalyzerWrapperSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/review-architecture")
			|| SkillId == TEXT("skill/memory-resume-briefing")
			|| SkillId == TEXT("skill/provider-routing-inspector");
	}

	bool IsCleanRoomCommandContractSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/roux-session-review");
	}

	bool IsCleanRoomSkillSpecSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/roux-session-review");
	}

	bool IsContinuityResumeSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/resume-session")
			|| SkillId == TEXT("skill/search-history")
			|| SkillId == TEXT("skill/capture-note");
	}

	bool IsRecallCompactViewSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/recall-memory")
			|| SkillId == TEXT("skill/generate-compact-view");
	}

	bool IsWorkflowMemoryCaptureSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/capture-session-template")
			|| SkillId == TEXT("skill/capture-follow-up-routine");
	}

	bool IsExtractionSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/extract-docs")
			|| SkillId == TEXT("skill/extract-design-spec");
	}

	bool IsBrowserDiagnosticsSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/capture-browser-trace")
			|| SkillId == TEXT("skill/discover-browser-api");
	}

	bool IsDesignShellSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/translate-design-shell")
			|| SkillId == TEXT("skill/translate-design-interaction");
	}

	bool IsWorkflowReviewSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/review-proposal")
			|| SkillId == TEXT("skill/review-diff")
			|| SkillId == TEXT("skill/wrap-bounded-workflow");
	}

	bool IsImplementationDelegationSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/review-implementation")
			|| SkillId == TEXT("skill/specify-bounded-delegation");
	}

	bool IsPlanOrchestrationSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/synthesize-plan")
			|| SkillId == TEXT("skill/chain-bounded-workflow");
	}

	bool IsProviderProfileRoutingSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/inspect-provider-profile")
			|| SkillId == TEXT("skill/setup-byok-profile")
			|| SkillId == TEXT("skill/diagnose-provider-routing");
	}

	bool IsProviderUsageOperationsAuditSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/audit-provider-usage")
			|| SkillId == TEXT("skill/inspect-provider-topology")
			|| SkillId == TEXT("skill/diagnose-route-service");
	}

	bool IsDomainPackFrameworkSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/specify-domain-packaging")
			|| SkillId == TEXT("skill/specify-domain-pack-grouping");
	}

	bool IsRetainedDomainPackSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/review-training-replay-pack")
			|| SkillId == TEXT("skill/curate-curriculum-content-pack")
			|| SkillId == TEXT("skill/prepare-media-export-pack");
	}

	bool IsCreativeMediaPackSkill(const FString& SkillId)
	{
		return SkillId == TEXT("skill/compose-replay-explainer-pack")
			|| SkillId == TEXT("skill/prepare-media-parser-pack")
			|| SkillId == TEXT("skill/curate-shared-fixture-pack");
	}

	bool HasAtLeastCleanRoomCommandContractStatus(const EHyperTwistSkillStatus Status)
	{
		return Status == EHyperTwistSkillStatus::CleanRoomCommandContractSpecified
			|| Status == EHyperTwistSkillStatus::CleanRoomSkillSpecSpecified;
	}

	FString MakeAnalyzerWrapperOutputKindId(const FString& ArtifactKind)
	{
		if (ArtifactKind == TEXT("artifact/architecture-scan"))
		{
			return TEXT("wrapper-output/architecture-scan");
		}

		if (ArtifactKind == TEXT("artifact/policy-scan"))
		{
			return TEXT("wrapper-output/policy-scan");
		}

		if (ArtifactKind == TEXT("artifact/route-inspection-packet"))
		{
			return TEXT("wrapper-output/route-inspection");
		}

		if (ArtifactKind == TEXT("artifact/watch-and-recheck-brief"))
		{
			return TEXT("wrapper-output/watch-and-recheck");
		}

		return FString();
	}

	FString MakeAnalyzerWrapperOutputDisplayLabel(
		const FHyperTwistSkillManifestEntry& Entry,
		const FString& OutputKindId
	)
	{
		if (OutputKindId == TEXT("wrapper-output/architecture-scan"))
		{
			return Entry.DisplayLabel + TEXT(" - Architecture Scan");
		}

		if (OutputKindId == TEXT("wrapper-output/policy-scan"))
		{
			return Entry.DisplayLabel + TEXT(" - Policy Scan");
		}

		if (OutputKindId == TEXT("wrapper-output/route-inspection"))
		{
			return Entry.DisplayLabel + TEXT(" - Route Inspection");
		}

		return Entry.DisplayLabel + TEXT(" - Watch And Recheck");
	}

	FHyperTwistSkillAnalyzerWrapperOutput MakeAnalyzerWrapperOutput(
		const FHyperTwistSkillManifestEntry& Entry,
		const FString& ArtifactKind
	)
	{
		const FString OutputKindId = MakeAnalyzerWrapperOutputKindId(ArtifactKind);

		FHyperTwistSkillAnalyzerWrapperOutput Output;
		Output.WrapperOutputId =
			TEXT("wrapper-output/")
			+ MakeInvocationSlug(Entry.SkillId)
			+ TEXT("/")
			+ MakeSkillSettingsSlug(OutputKindId);
		Output.SkillId = Entry.SkillId;
		Output.DisplayLabel = MakeAnalyzerWrapperOutputDisplayLabel(Entry, OutputKindId);
		Output.OutputKindId = OutputKindId;
		Output.CommandSurfaceId = Entry.CommandBindings[0].CommandSurfaceId;
		Output.ServiceBindingId = Entry.CommandBindings[0].ServiceBindingId;
		Output.OwnerLaneId = Entry.OwnerLaneId;
		Output.OwnerFeatureId = Entry.OwnerFeatureId;
		Output.ArtifactKind = ArtifactKind;
		Output.PermissionScopeIds = MakePermissionScopeIds(Entry);
		Output.bLiveWrapper = Entry.Status == EHyperTwistSkillStatus::ImplementedNow;
		Output.bStableInvocationPattern = true;
		Output.bStructuredOutput = true;
		Output.bDerivedAssistiveOnly = Entry.bOptionalAssistive;
		Output.Summary =
			TEXT("Structured first-party permissive wrapper output over a landed HyperTwist seam.");
		return Output;
	}

	FHyperTwistSkillCleanRoomCommandContractSpec MakeCleanRoomCommandContractSpec(
		const FHyperTwistSkillManifestEntry& Entry
	)
	{
		FHyperTwistSkillCleanRoomCommandContractSpec Spec;
		Spec.SpecId = TEXT("clean-room-command-spec/") + MakeInvocationSlug(Entry.SkillId);
		Spec.SkillId = Entry.SkillId;
		Spec.DisplayLabel = Entry.DisplayLabel + TEXT(" Command Contract");
		Spec.CommandSurfaceId = Entry.CommandBindings[0].CommandSurfaceId;
		Spec.ServiceBindingId = Entry.CommandBindings[0].ServiceBindingId;
		Spec.OwnerLaneId = Entry.OwnerLaneId;
		Spec.OwnerFeatureId = Entry.OwnerFeatureId;
		Spec.InvocationPattern = Entry.CommandBindings[0].InvocationPattern;
		Spec.ArtifactKind = Entry.Provenance.ProducedArtifactKinds[0];
		Spec.PermissionScopeIds = MakePermissionScopeIds(Entry);
		Spec.RequiredTemplateSectionIds = MakeRequiredAuthoringSectionIds();
		Spec.SafetyRuleIds = {
			TEXT("safety/skills/first-party-terms-only"),
			TEXT("safety/skills/optional-assistive-off-state-preserved"),
			TEXT("safety/skills/derived-output-only"),
			TEXT("safety/skills/provenance-ledger-required"),
			TEXT("safety/skills/no-product-truth-mutation")
		};
		Spec.SmokeExecutionMode = EHyperTwistSkillValidationExecutionMode::DeclarationOnly;
		Spec.EvalExecutionMode =
			EHyperTwistSkillValidationExecutionMode::DeferredUntilCleanRoomSkillSpec;
		Spec.bUsesFirstPartyTermsOnly = true;
		Spec.bAvoidsDonorWording = true;
		Spec.bPreservesOptionalAssistiveOffState = true;
		Spec.bDerivedAssistiveOnly = true;
		Spec.bRequiresProvenanceLedger = true;
		Spec.bNoProductTruthMutation = true;
		Spec.bFutureWrapperMayBindWithoutContractRewrite = true;
		Spec.Summary =
			TEXT("First-party clean-room command contract for a bounded Roux session review brief.");
		return Spec;
	}

	FHyperTwistSkillCleanRoomSkillSpec MakeCleanRoomSkillSpec(
		const FHyperTwistSkillManifestEntry& Entry,
		const FHyperTwistSkillCleanRoomCommandContractSpec& CommandContractSpec
	)
	{
		FHyperTwistSkillCleanRoomSkillSpec Spec;
		Spec.SkillSpecId = TEXT("clean-room-skill-spec/") + MakeInvocationSlug(Entry.SkillId);
		Spec.SkillId = Entry.SkillId;
		Spec.DisplayLabel = Entry.DisplayLabel + TEXT(" Skill Spec");
		Spec.CommandContractSpecId = CommandContractSpec.SpecId;
		Spec.CommandSurfaceId = Entry.CommandBindings[0].CommandSurfaceId;
		Spec.ServiceBindingId = Entry.CommandBindings[0].ServiceBindingId;
		Spec.OwnerLaneId = Entry.OwnerLaneId;
		Spec.OwnerFeatureId = Entry.OwnerFeatureId;
		Spec.InputStateKinds = {
			TEXT("input/training-session-state"),
			TEXT("input/replay-review-window"),
			TEXT("input/repository-integrity-guard")
		};
		Spec.OutputArtifactKinds = Entry.Provenance.ProducedArtifactKinds;
		Spec.SpecStepIds = {
			TEXT("step/load-authoritative-review-window"),
			TEXT("step/derive-roux-stage-observations"),
			TEXT("step/emit-provenance-visible-review-brief")
		};
		Spec.SafetyRuleIds = CommandContractSpec.SafetyRuleIds;
		Spec.RequiredTemplateSectionIds = CommandContractSpec.RequiredTemplateSectionIds;
		Spec.SmokeExecutionMode = EHyperTwistSkillValidationExecutionMode::DeclarationOnly;
		Spec.EvalExecutionMode = EHyperTwistSkillValidationExecutionMode::DeclarationOnly;
		Spec.bUsesFirstPartyTermsOnly = true;
		Spec.bAvoidsDonorWording = true;
		Spec.bSpecReadyForFutureImplementation = true;
		Spec.bNotLiveImplementationYet = true;
		Spec.bPreservesOptionalAssistiveOffState = true;
		Spec.bDerivedAssistiveOnly = true;
		Spec.bRequiresProvenanceLedger = true;
		Spec.bNoProductTruthMutation = true;
		Spec.Summary =
			TEXT("First-party clean-room-ready skill spec for bounded Roux session review output.");
		return Spec;
	}

	FHyperTwistSkillCommandProvenanceState MakeCommandProvenanceState(
		const FHyperTwistSkillManifestEntry& Entry
	)
	{
		const FHyperTwistSkillCommandBindingDeclaration& Binding = Entry.CommandBindings[0];

		FHyperTwistSkillCommandProvenanceState ProvenanceState;
		ProvenanceState.SkillId = Entry.SkillId;
		ProvenanceState.CommandSurfaceId = Binding.CommandSurfaceId;
		ProvenanceState.ServiceBindingId = Binding.ServiceBindingId;
		ProvenanceState.BoundFeatureId = Binding.BoundFeatureId;
		ProvenanceState.InvocationPattern = Binding.InvocationPattern;
		ProvenanceState.OwnerLaneId = Entry.OwnerLaneId;
		ProvenanceState.OwnerFeatureId = Entry.OwnerFeatureId;
		ProvenanceState.ProducerIdentity = Binding.ServiceBindingId;
		ProvenanceState.CustodyClass = MakeSkillCustodyClass(Entry);
		ProvenanceState.PermissionScopeIds = MakePermissionScopeIds(Entry);
		ProvenanceState.ProducedArtifactKinds = Entry.Provenance.ProducedArtifactKinds;
		ProvenanceState.bCommandBindingDeclared = true;
		ProvenanceState.bServiceBindingVisible = true;
		ProvenanceState.Summary =
			TEXT("First-party command/service provenance for skill invocation tracing.");
		return ProvenanceState;
	}

	EHyperTwistSkillInvocationOutcome DetermineInvocationOutcome(
		const FHyperTwistSkillManifestEntry& Entry
	)
	{
		if (Entry.SkillId == TEXT("skill/skillization-governance"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/review-architecture"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/memory-resume-briefing"))
		{
			return EHyperTwistSkillInvocationOutcome::Cancelled;
		}

		if (Entry.SkillId == TEXT("skill/resume-session")
			|| Entry.SkillId == TEXT("skill/search-history"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/recall-memory")
			|| Entry.SkillId == TEXT("skill/generate-compact-view"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/capture-session-template")
			|| Entry.SkillId == TEXT("skill/capture-follow-up-routine"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/extract-docs")
			|| Entry.SkillId == TEXT("skill/extract-design-spec"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/capture-browser-trace")
			|| Entry.SkillId == TEXT("skill/discover-browser-api"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/translate-design-shell")
			|| Entry.SkillId == TEXT("skill/translate-design-interaction"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/review-proposal")
			|| Entry.SkillId == TEXT("skill/review-diff")
			|| Entry.SkillId == TEXT("skill/wrap-bounded-workflow"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/review-implementation")
			|| Entry.SkillId == TEXT("skill/specify-bounded-delegation"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/synthesize-plan")
			|| Entry.SkillId == TEXT("skill/chain-bounded-workflow"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/inspect-provider-profile")
			|| Entry.SkillId == TEXT("skill/setup-byok-profile")
			|| Entry.SkillId == TEXT("skill/diagnose-provider-routing"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/audit-provider-usage")
			|| Entry.SkillId == TEXT("skill/inspect-provider-topology")
			|| Entry.SkillId == TEXT("skill/diagnose-route-service"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (Entry.SkillId == TEXT("skill/specify-domain-packaging")
			|| Entry.SkillId == TEXT("skill/specify-domain-pack-grouping"))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		if (IsRetainedDomainPackSkill(Entry.SkillId)
			|| IsCreativeMediaPackSkill(Entry.SkillId))
		{
			return EHyperTwistSkillInvocationOutcome::Succeeded;
		}

		return EHyperTwistSkillInvocationOutcome::Failed;
	}

	FString MakeInvocationWarningState(const EHyperTwistSkillInvocationOutcome Outcome)
	{
		switch (Outcome)
		{
		case EHyperTwistSkillInvocationOutcome::Succeeded:
			return TEXT("warning/none");
		case EHyperTwistSkillInvocationOutcome::Failed:
			return TEXT("warning/failure-recorded");
		case EHyperTwistSkillInvocationOutcome::Cancelled:
			return TEXT("warning/cancel-recorded");
		default:
			return TEXT("warning/unresolved");
		}
	}

	FString MakeInvocationFailureReason(const FHyperTwistSkillManifestEntry& Entry)
	{
		if (Entry.SkillId == TEXT("skill/provider-routing-inspector"))
		{
			return TEXT("Route inspection wrapper recorded a bounded failure before any diagnostic packet was emitted.");
		}

		return TEXT("Invocation failed before any product-truth output was emitted.");
	}

	FString MakeInvocationCancelReason(const FHyperTwistSkillManifestEntry& Entry)
	{
		if (Entry.SkillId == TEXT("skill/memory-resume-briefing"))
		{
			return TEXT("User cancelled the bounded watch-and-recheck wrapper before any resume brief was promoted.");
		}

		return TEXT("Invocation cancelled before any product-truth output was emitted.");
	}

	FHyperTwistSkillProducedArtifactState MakeProducedArtifactState(
		const FHyperTwistSkillManifestEntry& Entry,
		const FString& InvocationId,
		const FString& ArtifactKind
	)
	{
		FHyperTwistSkillProducedArtifactState ArtifactState;
		ArtifactState.ArtifactId =
			InvocationId + TEXT("/") + MakeSkillSettingsSlug(ArtifactKind);
		ArtifactState.ArtifactKind = ArtifactKind;
		ArtifactState.ArtifactOriginId = Entry.CommandBindings[0].CommandSurfaceId;
		ArtifactState.EvidenceLinkId = InvocationId + TEXT("/evidence");
		ArtifactState.WarningState = TEXT("warning/none");
		ArtifactState.CustodyClass = MakeSkillCustodyClass(Entry);
		ArtifactState.bReplayLinked = true;
		ArtifactState.bTraceableToInvocation = true;
		ArtifactState.Summary =
			TEXT("Product-truth skill artifact that remains linked back to its invocation and evidence.");
		return ArtifactState;
	}

	FHyperTwistSkillInvocationRecord MakeInvocationRecord(
		const FHyperTwistSkillManifestEntry& Entry,
		const int32 InvocationOrdinal
	)
	{
		const EHyperTwistSkillInvocationOutcome Outcome = DetermineInvocationOutcome(Entry);
		const FString InvocationId = FString::Printf(
			TEXT("skill-invocation/%s/%02d"),
			*MakeInvocationSlug(Entry.SkillId),
			InvocationOrdinal
		);

		FHyperTwistSkillInvocationRecord Record;
		Record.InvocationId = InvocationId;
		Record.SkillId = Entry.SkillId;
		Record.DisplayLabel = Entry.DisplayLabel;
		Record.SessionId = TEXT("skill-session/") + MakeInvocationSlug(Entry.SkillId);
		Record.RunId = TEXT("skill-run/") + MakeInvocationSlug(Entry.SkillId);
		Record.StartedAtUtc = FString::Printf(
			TEXT("2026-05-28T22:%02d:00Z"),
			10 + InvocationOrdinal
		);
		Record.CompletedAtUtc = FString::Printf(
			TEXT("2026-05-28T22:%02d:20Z"),
			10 + InvocationOrdinal
		);
		Record.Outcome = Outcome;
		Record.CommandProvenance = MakeCommandProvenanceState(Entry);
		Record.WarningState = MakeInvocationWarningState(Outcome);
		Record.bInvocationTraceable = true;
		Record.bOutcomeRecorded = true;

		if (Outcome == EHyperTwistSkillInvocationOutcome::Succeeded)
		{
			for (const FString& ArtifactKind : Entry.Provenance.ProducedArtifactKinds)
			{
				Record.ProducedArtifacts.Add(
					MakeProducedArtifactState(Entry, InvocationId, ArtifactKind)
				);
			}
			Record.bOutputBecameProductTruth = true;
			Record.bOutputTraceable = true;
			Record.Summary =
				TEXT("Successful skill invocation with provenance-visible product output.");
		}
		else if (Outcome == EHyperTwistSkillInvocationOutcome::Failed)
		{
			Record.FailureReason = MakeInvocationFailureReason(Entry);
			Record.bOutputBecameProductTruth = false;
			Record.bOutputTraceable = true;
			Record.Summary =
				TEXT("Failed skill invocation recorded before any product-truth output escaped tracing.");
		}
		else if (Outcome == EHyperTwistSkillInvocationOutcome::Cancelled)
		{
			Record.CancelReason = MakeInvocationCancelReason(Entry);
			Record.bOutputBecameProductTruth = false;
			Record.bOutputTraceable = true;
			Record.Summary =
				TEXT("Cancelled skill invocation recorded before any product-truth output escaped tracing.");
		}

		return Record;
	}

	FHyperTwistSkillAuthoringTemplateField MakeAuthoringField(
		const TCHAR* FieldId,
		const TCHAR* DisplayLabel,
		const TCHAR* ExpectedSource,
		const TCHAR* ExampleValue,
		const TCHAR* Summary
	)
	{
		FHyperTwistSkillAuthoringTemplateField Field;
		Field.FieldId = FieldId;
		Field.DisplayLabel = DisplayLabel;
		Field.ExpectedSource = ExpectedSource;
		Field.ExampleValue = ExampleValue;
		Field.bRequired = true;
		Field.Summary = Summary;
		return Field;
	}

	FHyperTwistSkillAuthoringTemplateSection MakeAuthoringSection(
		const TCHAR* SectionId,
		const TCHAR* DisplayLabel,
		const TArray<FHyperTwistSkillAuthoringTemplateField>& Fields,
		const TCHAR* Summary
	)
	{
		FHyperTwistSkillAuthoringTemplateSection Section;
		Section.SectionId = SectionId;
		Section.DisplayLabel = DisplayLabel;
		Section.Fields = Fields;
		Section.bRequiredForAllSkills = true;
		Section.Summary = Summary;
		return Section;
	}

	const FHyperTwistSkillInvocationRecord* FindInvocationRecordBySkillId(
		const FHyperTwistSkillAuditLedgerState& AuditLedgerState,
		const FString& SkillId
	)
	{
		return AuditLedgerState.InvocationRecords.FindByPredicate(
			[&SkillId](const FHyperTwistSkillInvocationRecord& Record)
			{
				return Record.SkillId == SkillId;
			}
		);
	}

	FString MakeAuthoringExampleId(const FString& SkillId)
	{
		return TEXT("skill-authoring-example/") + MakeInvocationSlug(SkillId);
	}

	TArray<FString> MakeRequiredAuthoringSectionIds()
	{
		return {
			TEXT("section/skill-identity-owner"),
			TEXT("section/skill-command-binding"),
			TEXT("section/skill-permission-provenance"),
			TEXT("section/skill-off-state"),
			TEXT("section/skill-invocation-audit"),
			TEXT("section/skill-validation-contract")
		};
	}

	FHyperTwistSkillAuthoringExampleState MakeAuthoringExampleState(
		const FHyperTwistSkillManifestEntry& Entry,
		const FHyperTwistSkillAuditLedgerState& AuditLedgerState
	)
	{
		FHyperTwistSkillAuthoringExampleState ExampleState;
		ExampleState.ExampleId = MakeAuthoringExampleId(Entry.SkillId);
		ExampleState.SkillId = Entry.SkillId;
		ExampleState.ExampleLabel = Entry.DisplayLabel + TEXT(" Example");
		ExampleState.ExampleCommandSurfaceId = Entry.CommandBindings[0].CommandSurfaceId;
		ExampleState.ExampleArtifactKind = Entry.Provenance.ProducedArtifactKinds[0];
		ExampleState.TemplateSectionIds = MakeRequiredAuthoringSectionIds();
		ExampleState.bGroundedInRegistry = true;
		ExampleState.bHasTraceableAuditExample =
			FindInvocationRecordBySkillId(AuditLedgerState, Entry.SkillId) != nullptr;
		ExampleState.Summary =
			TEXT("First-party authoring example grounded in the current skill registry.");
		return ExampleState;
	}

	EHyperTwistSkillValidationExecutionMode DetermineSmokeExecutionMode(
		const EHyperTwistSkillStatus Status
	)
	{
		switch (Status)
		{
		case EHyperTwistSkillStatus::ImplementedNow:
			return EHyperTwistSkillValidationExecutionMode::LiveContract;
		case EHyperTwistSkillStatus::CommandContractPending:
		case EHyperTwistSkillStatus::CleanRoomSpecPending:
		case EHyperTwistSkillStatus::CleanRoomCommandContractSpecified:
		case EHyperTwistSkillStatus::CleanRoomSkillSpecSpecified:
			return EHyperTwistSkillValidationExecutionMode::DeclarationOnly;
		case EHyperTwistSkillStatus::PlaceholderFamily:
			return EHyperTwistSkillValidationExecutionMode::PlaceholderStructureOnly;
		default:
			return EHyperTwistSkillValidationExecutionMode::None;
		}
	}

	EHyperTwistSkillValidationExecutionMode DetermineEvalExecutionMode(
		const EHyperTwistSkillStatus Status
	)
	{
		switch (Status)
		{
		case EHyperTwistSkillStatus::ImplementedNow:
			return EHyperTwistSkillValidationExecutionMode::LiveContract;
		case EHyperTwistSkillStatus::CommandContractPending:
			return EHyperTwistSkillValidationExecutionMode::DeferredUntilWrapper;
		case EHyperTwistSkillStatus::CleanRoomSpecPending:
			return EHyperTwistSkillValidationExecutionMode::DeferredUntilCleanRoomSpec;
		case EHyperTwistSkillStatus::CleanRoomCommandContractSpecified:
			return EHyperTwistSkillValidationExecutionMode::DeferredUntilCleanRoomSkillSpec;
		case EHyperTwistSkillStatus::CleanRoomSkillSpecSpecified:
			return EHyperTwistSkillValidationExecutionMode::DeclarationOnly;
		case EHyperTwistSkillStatus::PlaceholderFamily:
			return EHyperTwistSkillValidationExecutionMode::PlaceholderStructureOnly;
		default:
			return EHyperTwistSkillValidationExecutionMode::None;
		}
	}

	FString MakeValidationCaseId(
		const FString& SkillId,
		const EHyperTwistSkillValidationContractKind Kind
	)
	{
		return FString::Printf(
			TEXT("skill-validation/%s/%s"),
			*MakeInvocationSlug(SkillId),
			Kind == EHyperTwistSkillValidationContractKind::Smoke ? TEXT("smoke") : TEXT("eval")
		);
	}

	FHyperTwistSkillValidationContractCase MakeValidationContractCase(
		const FHyperTwistSkillManifestEntry& Entry,
		const EHyperTwistSkillValidationContractKind Kind,
		const EHyperTwistSkillValidationExecutionMode ExecutionMode,
		const FHyperTwistSkillAuditLedgerState& AuditLedgerState
	)
	{
		FHyperTwistSkillValidationContractCase ValidationCase;
		ValidationCase.CaseId = MakeValidationCaseId(Entry.SkillId, Kind);
		ValidationCase.SkillId = Entry.SkillId;
		ValidationCase.Kind = Kind;
		ValidationCase.ExecutionMode = ExecutionMode;
		ValidationCase.ExpectedCommandSurfaceId = Entry.CommandBindings[0].CommandSurfaceId;
		ValidationCase.ExpectedServiceBindingId = Entry.CommandBindings[0].ServiceBindingId;
		ValidationCase.RequiredTemplateSectionIds = MakeRequiredAuthoringSectionIds();
		ValidationCase.ExpectedArtifactKinds = Entry.Provenance.ProducedArtifactKinds;
		ValidationCase.bUsesAuditLedgerEvidence =
			ExecutionMode == EHyperTwistSkillValidationExecutionMode::LiveContract
			&& FindInvocationRecordBySkillId(AuditLedgerState, Entry.SkillId) != nullptr;
		ValidationCase.Summary =
			Kind == EHyperTwistSkillValidationContractKind::Smoke
				? TEXT("Per-skill smoke validation contract under the current skillization substrate.")
				: TEXT("Per-skill eval validation contract under the current skillization substrate.");
		return ValidationCase;
	}
}

	FHyperTwistSkillRegistryState UHyperTwistSkillCoreLibrary::DeriveSkillRegistryState()
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	FHyperTwistSkillRegistryState RegistryState;
	RegistryState.RegistryId = TEXT("skill-registry/first-party");
	RegistryState.ManifestVersion = TEXT("s4a-v1");
	RegistryState.ReferenceUtc = TEXT("2026-05-29T09:20:00Z");
	RegistryState.CommandSurfaceRootId = TEXT("command-surface/skills");
	RegistryState.Summary =
		TEXT("First-party skill registry and manifest contract with landed permissive analyzer wrappers, landed clean-room command contracts, landed clean-room skill specs, landed continuity/resume skills, landed recall/compact-view skills, landed workflow-memory capture skills, landed browser/docs/design extraction skills, landed browser diagnostics and design-shell skills, and landed workflow/review wrappers.");

	RegistryState.Entries = {
		MakeSkillEntry(
			TEXT("skill/skillization-governance"),
			TEXT("Skillization Governance"),
			TEXT("lane/skillization/substrate"),
			TEXT("feature/skills/registry-governance"),
			EHyperTwistSkillFamily::SubstrateGovernance,
			EHyperTwistSkillStatus::ImplementedNow,
			true,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/inspect-registry"),
					TEXT("service/skills/registry-state"),
					TEXT("feature/skills/registry-governance"),
					TEXT("command-surface/query"),
					true,
					TEXT("Current first-party registry inspection surface.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/governance"),
					TEXT("Skill Governance"),
					false,
					false,
					false,
					false,
					false,
					true,
					false,
					TEXT("Allows inspection and bounded optional-assistive governance.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::DeclarationOnly,
				{TEXT("artifact/skill-registry-state")},
				false,
				TEXT("Registry inspection currently declares provenance before a later invocation ledger lands.")
			),
			TEXT("Landed first-party skill registry and manifest governance substrate.")
		),
		MakeSkillEntry(
			TEXT("skill/review-architecture"),
			TEXT("Architecture Review"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/review-analyzer"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/review-architecture"),
					TEXT("service/skills/review-architecture"),
					TEXT("feature/skills/review-analyzer"),
					TEXT("analyzer/architecture-and-policy-scan"),
					true,
					TEXT("Live first-party architecture and policy scan wrapper over permissive product evidence.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/review-output"),
					TEXT("Review Output"),
					false,
					false,
					false,
					false,
					false,
					false,
					true,
					TEXT("Allows derived assistive review output only.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{
					TEXT("artifact/architecture-scan"),
					TEXT("artifact/policy-scan")
				},
				true,
				TEXT("Live review wrappers emit provenance-visible architecture and policy scan output.")
			),
			TEXT("Landed permissive architecture and policy scan wrapper family.")
		),
		MakeSkillEntry(
			TEXT("skill/memory-resume-briefing"),
			TEXT("Memory Resume Briefing"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/memory-resume"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/memory-resume-briefing"),
					TEXT("service/skills/memory-resume-briefing"),
					TEXT("feature/skills/memory-resume"),
					TEXT("analyzer/watch-and-recheck"),
					true,
					TEXT("Live watch-and-recheck wrapper over the landed first-party memory seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/memory-resume"),
					TEXT("Memory Resume"),
					true,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads training and memory state to emit bounded resume output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/watch-and-recheck-brief")},
				true,
				TEXT("Watch-and-recheck briefs stay provenance-visible under the landed memory wrapper.")
			),
			TEXT("Landed watch-and-recheck wrapper family above the landed memory substrate.")
		),
		MakeSkillEntry(
			TEXT("skill/resume-session"),
			TEXT("Resume Session"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/resume-session"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/resume-session"),
					TEXT("service/skills/resume-session"),
					TEXT("feature/skills/resume-session"),
					TEXT("memory/continuity-resume"),
					true,
					TEXT("Live first-party continuity-resume skill over authoritative resume packs and guards.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/resume-session"),
					TEXT("Resume Session"),
					true,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads authoritative training and memory continuity state to emit derived resume guidance.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/resume-session-brief")},
				true,
				TEXT("Resume-session output must remain provenance-visible and derived-only.")
			),
			TEXT("Landed first-party continuity skill over authoritative session-resume stores.")
		),
		MakeSkillEntry(
			TEXT("skill/search-history"),
			TEXT("Search History"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/search-history"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/search-history"),
					TEXT("service/skills/search-history"),
					TEXT("feature/skills/search-history"),
					TEXT("memory/history-search"),
					true,
					TEXT("Live first-party history-search skill over authoritative memory evidence and recall lineage.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/search-history"),
					TEXT("Search History"),
					true,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads authoritative training and memory state to emit bounded history-search output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/history-search-brief")},
				true,
				TEXT("History-search output must remain provenance-visible and linked to authoritative recall lineage.")
			),
			TEXT("Landed first-party history-search skill over authoritative memory evidence.")
		),
		MakeSkillEntry(
			TEXT("skill/capture-note"),
			TEXT("Capture Note"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/capture-note"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::CommandContractPending,
			false,
			false,
			{
				MakeCommandBinding(
					TEXT("command/skills/capture-note"),
					TEXT("service/deferred/capture-note"),
					TEXT("feature/skills/capture-note"),
					TEXT("pending-owner-activation"),
					false,
					TEXT("Declared note-capture skill remains pending until the user-notes owner lane is explicitly active.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/capture-note"),
					TEXT("Capture Note"),
					false,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads first-party note-lane posture only and emits bounded readiness guidance.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/note-capture-readiness")},
				true,
				TEXT("Deferred note-capture readiness must remain provenance-visible and must not imply active note ownership.")
			),
			TEXT("Declared first-party note-capture skill remains pending until user-authored note ownership is separately justified.")
		),
		MakeSkillEntry(
			TEXT("skill/recall-memory"),
			TEXT("Recall Memory"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/recall-memory"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/recall-memory"),
					TEXT("service/skills/recall-memory"),
					TEXT("feature/skills/recall-memory"),
					TEXT("memory/explicit-recall"),
					true,
					TEXT("Live first-party recall skill over authoritative memory matches and provenance drill-down.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/recall-memory"),
					TEXT("Recall Memory"),
					true,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads authoritative training and memory recall state to emit bounded recall output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/recall-memory-brief")},
				true,
				TEXT("Recall-memory output must remain provenance-visible and linked to authoritative memory lineage.")
			),
			TEXT("Landed first-party recall skill over authoritative memory matches and drill-down lineage.")
		),
		MakeSkillEntry(
			TEXT("skill/generate-compact-view"),
			TEXT("Generate Compact View"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/generate-compact-view"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/generate-compact-view"),
					TEXT("service/skills/generate-compact-view"),
					TEXT("feature/skills/generate-compact-view"),
					TEXT("memory/compact-view"),
					true,
					TEXT("Live first-party optional compact-view skill over derived memory adjunct surfaces linked back to authoritative sources.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/generate-compact-view"),
					TEXT("Generate Compact View"),
					true,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads authoritative and derived memory state to emit bounded optional compact-view output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/compact-view-brief")},
				true,
				TEXT("Compact-view output must remain optional, provenance-visible, and linked to authoritative sources.")
			),
			TEXT("Landed first-party optional compact-view skill over derived memory adjunct surfaces.")
		),
		MakeSkillEntry(
			TEXT("skill/capture-session-template"),
			TEXT("Capture Session Template"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/capture-session-template"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/capture-session-template"),
					TEXT("service/skills/capture-session-template"),
					TEXT("feature/skills/capture-session-template"),
					TEXT("memory/workflow-template-capture"),
					true,
					TEXT("Live first-party workflow capture skill over authoritative session-template and drill-workflow entities.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/capture-session-template"),
					TEXT("Capture Session Template"),
					true,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads authoritative training and workflow memory state to emit bounded session-template capture output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/workflow-template-capture-brief")},
				true,
				TEXT("Workflow-template capture output must remain provenance-visible, derived-only, and separate from user-authored notes.")
			),
			TEXT("Landed first-party workflow capture skill over authoritative session-template and drill-workflow entities.")
		),
		MakeSkillEntry(
			TEXT("skill/capture-follow-up-routine"),
			TEXT("Capture Follow-Up Routine"),
			TEXT("lane/skillization/memory-continuity"),
			TEXT("feature/skills/capture-follow-up-routine"),
			EHyperTwistSkillFamily::MemoryContinuity,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/capture-follow-up-routine"),
					TEXT("service/skills/capture-follow-up-routine"),
					TEXT("feature/skills/capture-follow-up-routine"),
					TEXT("memory/workflow-follow-up-capture"),
					true,
					TEXT("Live first-party workflow capture skill over authoritative review-plan, coach-action-plan, and queue follow-up entities.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/capture-follow-up-routine"),
					TEXT("Capture Follow-Up Routine"),
					true,
					false,
					false,
					true,
					false,
					false,
					true,
					TEXT("Reads authoritative training and workflow memory state to emit bounded follow-up routine capture output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/follow-up-routine-capture-brief")},
				true,
				TEXT("Follow-up routine capture output must remain provenance-visible, derived-only, and avoid opaque summary collapse.")
			),
			TEXT("Landed first-party workflow capture skill over authoritative review-plan and follow-up routine entities.")
		),
		MakeSkillEntry(
			TEXT("skill/extract-docs"),
			TEXT("Extract Docs"),
			TEXT("lane/skillization/browser-docs-design"),
			TEXT("feature/skills/extract-docs"),
			EHyperTwistSkillFamily::BrowserDocsDesign,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/extract-docs"),
					TEXT("service/skills/extract-docs"),
					TEXT("feature/skills/extract-docs"),
					TEXT("docs/structured-extraction"),
					true,
					TEXT("Live first-party structured docs-extraction skill over authoritative HyperTwist canon surfaces.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/extract-docs"),
					TEXT("Extract Docs"),
					false,
					false,
					false,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party documentation source surfaces and emits bounded structured extraction output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/docs-extraction-brief")},
				true,
				TEXT("Docs-extraction output must remain provenance-visible, derived-only, and bounded to structured extraction.")
			),
			TEXT("Landed first-party structured docs-extraction skill over authoritative HyperTwist canon surfaces.")
		),
		MakeSkillEntry(
			TEXT("skill/extract-design-spec"),
			TEXT("Extract Design Spec"),
			TEXT("lane/skillization/browser-docs-design"),
			TEXT("feature/skills/extract-design-spec"),
			EHyperTwistSkillFamily::BrowserDocsDesign,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/extract-design-spec"),
					TEXT("service/skills/extract-design-spec"),
					TEXT("feature/skills/extract-design-spec"),
					TEXT("design/structured-spec-extraction"),
					true,
					TEXT("Live first-party structured design-spec extraction skill over authoritative HyperTwist design and packet surfaces.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/extract-design-spec"),
					TEXT("Extract Design Spec"),
					false,
					false,
					false,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party design and packet source surfaces to emit bounded structured design-spec extraction output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/design-spec-extraction-brief")},
				true,
				TEXT("Design-spec extraction output must remain provenance-visible, derived-only, and must not widen into design translation.")
			),
			TEXT("Landed first-party structured design-spec extraction skill over authoritative HyperTwist design and packet surfaces.")
		),
		MakeSkillEntry(
			TEXT("skill/capture-browser-trace"),
			TEXT("Capture Browser Trace"),
			TEXT("lane/skillization/browser-docs-design"),
			TEXT("feature/skills/capture-browser-trace"),
			EHyperTwistSkillFamily::BrowserDocsDesign,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/capture-browser-trace"),
					TEXT("service/skills/capture-browser-trace"),
					TEXT("feature/skills/capture-browser-trace"),
					TEXT("browser/trace-capture"),
					true,
					TEXT("Live first-party bounded browser trace-capture skill above the landed docs/design extraction seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/browser-diagnostics"),
					TEXT("Browser Diagnostics"),
					false,
					false,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads first-party browser, service, and packet surfaces to emit bounded browser trace diagnostics.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/browser-trace-capture-brief")},
				true,
				TEXT("Browser trace output must remain provenance-visible, derived-only, and bounded to diagnostics.")
			),
			TEXT("Landed first-party bounded browser trace-capture skill above the extraction seam.")
		),
		MakeSkillEntry(
			TEXT("skill/discover-browser-api"),
			TEXT("Discover Browser API"),
			TEXT("lane/skillization/browser-docs-design"),
			TEXT("feature/skills/discover-browser-api"),
			EHyperTwistSkillFamily::BrowserDocsDesign,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/discover-browser-api"),
					TEXT("service/skills/discover-browser-api"),
					TEXT("feature/skills/discover-browser-api"),
					TEXT("browser/api-discovery"),
					true,
					TEXT("Live first-party bounded browser/API discovery skill above the landed docs/design extraction seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/browser-diagnostics"),
					TEXT("Browser Diagnostics"),
					false,
					false,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads first-party browser, service, and packet surfaces to emit bounded browser/API discovery output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/browser-api-discovery-brief")},
				true,
				TEXT("Browser/API discovery output must remain provenance-visible, derived-only, and separate from design translation.")
			),
			TEXT("Landed first-party bounded browser/API discovery skill above the extraction seam.")
		),
		MakeSkillEntry(
			TEXT("skill/translate-design-shell"),
			TEXT("Translate Design Shell"),
			TEXT("lane/skillization/browser-docs-design"),
			TEXT("feature/skills/translate-design-shell"),
			EHyperTwistSkillFamily::BrowserDocsDesign,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/translate-design-shell"),
					TEXT("service/skills/translate-design-shell"),
					TEXT("feature/skills/translate-design-shell"),
					TEXT("design/native-shell-translation"),
					true,
					TEXT("Live first-party bounded design-shell translation skill above the landed extraction and browser diagnostics seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/design-shell"),
					TEXT("Design Shell"),
					false,
					false,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads first-party docs, design, browser, and packet surfaces to emit bounded native design-shell translation output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/native-design-shell-translation-brief")},
				true,
				TEXT("Design-shell translation output must remain provenance-visible, derived-only, bounded to design-shell translation, and separate from generic browser shell orchestration.")
			),
			TEXT("Landed first-party bounded design-shell translation skill above the extraction and browser diagnostics seams.")
		),
		MakeSkillEntry(
			TEXT("skill/translate-design-interaction"),
			TEXT("Translate Design Interaction"),
			TEXT("lane/skillization/browser-docs-design"),
			TEXT("feature/skills/translate-design-interaction"),
			EHyperTwistSkillFamily::BrowserDocsDesign,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/translate-design-interaction"),
					TEXT("service/skills/translate-design-interaction"),
					TEXT("feature/skills/translate-design-interaction"),
					TEXT("design/native-interaction-translation"),
					true,
					TEXT("Live first-party bounded design-interaction translation skill above the landed extraction and browser diagnostics seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/design-shell"),
					TEXT("Design Shell"),
					false,
					false,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads first-party docs, design, browser, and packet surfaces to emit bounded native interaction-translation output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/native-interaction-translation-brief")},
				true,
				TEXT("Design-interaction translation output must remain provenance-visible, derived-only, bounded to design-shell translation, and separate from generic browser shell orchestration.")
			),
			TEXT("Landed first-party bounded design-interaction translation skill above the extraction and browser diagnostics seams.")
		),
		MakeSkillEntry(
			TEXT("skill/review-proposal"),
			TEXT("Review Proposal"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/review-proposal"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/review-proposal"),
					TEXT("service/skills/review-proposal"),
					TEXT("feature/skills/review-proposal"),
					TEXT("workflow/review-proposal"),
					true,
					TEXT("Live first-party bounded proposal-review wrapper over the landed extraction, workflow-memory, and design-shell seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/workflow-review"),
					TEXT("Workflow Review"),
					false,
					false,
					false,
					true,
					true,
					false,
					true,
					TEXT("Reads first-party workflow, browser, and packet surfaces to emit bounded proposal-review output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/proposal-review-brief")},
				true,
				TEXT("Proposal-review output must remain provenance-visible, derived-only, and bounded to first-party workflow review.")
			),
			TEXT("Landed first-party bounded proposal-review wrapper above the extraction, workflow-memory, and design-shell seams.")
		),
		MakeSkillEntry(
			TEXT("skill/review-diff"),
			TEXT("Review Diff"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/review-diff"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/review-diff"),
					TEXT("service/skills/review-diff"),
					TEXT("feature/skills/review-diff"),
					TEXT("workflow/review-diff"),
					true,
					TEXT("Live first-party bounded diff-review wrapper over the landed extraction, workflow-memory, and design-shell seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/workflow-review"),
					TEXT("Workflow Review"),
					false,
					false,
					false,
					true,
					true,
					false,
					true,
					TEXT("Reads first-party workflow, browser, and packet surfaces to emit bounded diff-review output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/diff-review-brief")},
				true,
				TEXT("Diff-review output must remain provenance-visible, derived-only, and bounded to first-party workflow review.")
			),
			TEXT("Landed first-party bounded diff-review wrapper above the extraction, workflow-memory, and design-shell seams.")
		),
		MakeSkillEntry(
			TEXT("skill/wrap-bounded-workflow"),
			TEXT("Wrap Bounded Workflow"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/wrap-bounded-workflow"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/wrap-bounded-workflow"),
					TEXT("service/skills/wrap-bounded-workflow"),
					TEXT("feature/skills/wrap-bounded-workflow"),
					TEXT("workflow/wrap-bounded-sequence"),
					true,
					TEXT("Live first-party bounded workflow-wrapper skill over the landed extraction, workflow-memory, and design-shell seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/workflow-review"),
					TEXT("Workflow Review"),
					false,
					false,
					false,
					true,
					true,
					false,
					true,
					TEXT("Reads first-party workflow, browser, and packet surfaces to emit bounded workflow-wrapper output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/bounded-workflow-wrapper-brief")},
				true,
				TEXT("Bounded workflow-wrapper output must remain provenance-visible, derived-only, and must not widen into delegation or plan synthesis.")
			),
			TEXT("Landed first-party bounded workflow-wrapper skill above the extraction, workflow-memory, and design-shell seams.")
		),
		MakeSkillEntry(
			TEXT("skill/review-implementation"),
			TEXT("Review Implementation"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/review-implementation"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/review-implementation"),
					TEXT("service/specs/review-implementation"),
					TEXT("feature/skills/review-implementation"),
					TEXT("spec/implementation-review"),
					true,
					TEXT("Live first-party bounded implementation-review spec over the landed workflow/review and design-shell seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/workflow-review"),
					TEXT("Workflow Review"),
					false,
					false,
					false,
					true,
					true,
					false,
					true,
					TEXT("Reads first-party workflow, browser, and packet surfaces to emit bounded implementation-review spec output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/implementation-review-brief")},
				true,
				TEXT("Implementation-review output must remain provenance-visible, derived-only, and bounded to first-party implementation review.")
			),
			TEXT("Landed first-party bounded implementation-review spec above the workflow/review and design-shell seams.")
		),
		MakeSkillEntry(
			TEXT("skill/specify-bounded-delegation"),
			TEXT("Specify Bounded Delegation"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/specify-bounded-delegation"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/specify-bounded-delegation"),
					TEXT("service/specs/specify-bounded-delegation"),
					TEXT("feature/skills/specify-bounded-delegation"),
					TEXT("spec/bounded-delegation"),
					true,
					TEXT("Live first-party bounded delegation-spec surface over the landed workflow/review and design-shell seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/workflow-review"),
					TEXT("Workflow Review"),
					false,
					false,
					false,
					true,
					true,
					false,
					true,
					TEXT("Reads first-party workflow, browser, and packet surfaces to emit bounded delegation-spec output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/bounded-delegation-spec-brief")},
				true,
				TEXT("Bounded delegation output must remain provenance-visible, derived-only, and must not widen into plan synthesis or autonomous execution.")
			),
			TEXT("Landed first-party bounded delegation-spec surface above the workflow/review and design-shell seams.")
		),
		MakeSkillEntry(
			TEXT("skill/synthesize-plan"),
			TEXT("Synthesize Plan"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/synthesize-plan"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/synthesize-plan"),
					TEXT("service/skills/synthesize-plan"),
					TEXT("feature/skills/synthesize-plan"),
					TEXT("workflow/plan-synthesis"),
					true,
					TEXT("Live first-party bounded plan-synthesis surface over the landed implementation/delegation and workflow-memory seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/plan-orchestration"),
					TEXT("Plan Orchestration"),
					false,
					false,
					false,
					true,
					true,
					false,
					true,
					TEXT("Reads first-party workflow, implementation, memory, and packet surfaces to emit bounded plan-synthesis output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/bounded-plan-synthesis-brief")},
				true,
				TEXT("Plan-synthesis output must remain provenance-visible, derived-only, and bounded to first-party orchestration glue.")
			),
			TEXT("Landed first-party bounded plan-synthesis surface above the implementation/delegation, workflow-memory, and workflow/review seams.")
		),
		MakeSkillEntry(
			TEXT("skill/chain-bounded-workflow"),
			TEXT("Chain Bounded Workflow"),
			TEXT("lane/skillization/analysis-review"),
			TEXT("feature/skills/chain-bounded-workflow"),
			EHyperTwistSkillFamily::AnalysisReview,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/chain-bounded-workflow"),
					TEXT("service/skills/chain-bounded-workflow"),
					TEXT("feature/skills/chain-bounded-workflow"),
					TEXT("workflow/chain-bounded-sequence"),
					true,
					TEXT("Live first-party bounded workflow-chaining surface over the landed implementation/delegation and workflow-memory seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/plan-orchestration"),
					TEXT("Plan Orchestration"),
					false,
					false,
					false,
					true,
					true,
					false,
					true,
					TEXT("Reads first-party workflow, implementation, memory, and packet surfaces to emit bounded workflow-chaining output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/bounded-workflow-chain-brief")},
				true,
				TEXT("Workflow-chaining output must remain provenance-visible, derived-only, and must not widen into provider or domain orchestration.")
			),
			TEXT("Landed first-party bounded workflow-chaining surface above the implementation/delegation, workflow-memory, and workflow/review seams.")
		),
		MakeSkillEntry(
			TEXT("skill/provider-routing-inspector"),
			TEXT("Provider Routing Inspector"),
			TEXT("lane/skillization/provider-ops"),
			TEXT("feature/skills/provider-routing-inspector"),
			EHyperTwistSkillFamily::ProviderOperations,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/provider-routing-inspector"),
					TEXT("service/skills/provider-routing-inspector"),
					TEXT("feature/skills/provider-routing-inspector"),
					TEXT("analyzer/route-inspection"),
					true,
					TEXT("Live route-inspection wrapper over landed provider-neutral speech/provider contracts.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/provider-routing"),
					TEXT("Provider Routing"),
					false,
					true,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads recognition/provider state to emit bounded operator diagnostics.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/route-inspection-packet")},
				true,
				TEXT("Route-inspection output must stay provenance-visible under the landed provider wrapper.")
			),
			TEXT("Landed route-inspection wrapper family above the landed speech/provider seams.")
		),
		MakeSkillEntry(
			TEXT("skill/inspect-provider-profile"),
			TEXT("Inspect Provider Profile"),
			TEXT("lane/skillization/provider-ops"),
			TEXT("feature/skills/inspect-provider-profile"),
			EHyperTwistSkillFamily::ProviderOperations,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/inspect-provider-profile"),
					TEXT("service/skills/inspect-provider-profile"),
					TEXT("feature/skills/inspect-provider-profile"),
					TEXT("workflow/provider-profile-inspection"),
					true,
					TEXT("Live first-party provider-profile inspection surface over the landed provider-neutral speech/provider seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/provider-profile"),
					TEXT("Provider Profile"),
					false,
					true,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads provider-neutral recognition/provider state to emit bounded provider-profile inspection output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/provider-profile-inspection-brief")},
				true,
				TEXT("Provider-profile inspection output must remain provenance-visible and bounded to first-party provider-neutral state.")
			),
			TEXT("Landed first-party provider-profile inspection surface above the landed provider-neutral speech/provider seams.")
		),
		MakeSkillEntry(
			TEXT("skill/setup-byok-profile"),
			TEXT("Setup BYOK Profile"),
			TEXT("lane/skillization/provider-ops"),
			TEXT("feature/skills/setup-byok-profile"),
			EHyperTwistSkillFamily::ProviderOperations,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/setup-byok-profile"),
					TEXT("service/skills/setup-byok-profile"),
					TEXT("feature/skills/setup-byok-profile"),
					TEXT("workflow/provider-byok-setup"),
					true,
					TEXT("Live first-party BYOK profile-setup surface over the landed provider-neutral custody and routing seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/provider-byok"),
					TEXT("Provider BYOK"),
					false,
					true,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads provider-neutral recognition/provider state to emit bounded BYOK-profile setup output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/provider-byok-setup-brief")},
				true,
				TEXT("BYOK profile-setup output must remain provenance-visible and bounded to first-party provider-neutral custody state.")
			),
			TEXT("Landed first-party BYOK profile-setup surface above the landed provider-neutral speech/provider seams.")
		),
		MakeSkillEntry(
			TEXT("skill/diagnose-provider-routing"),
			TEXT("Diagnose Provider Routing"),
			TEXT("lane/skillization/provider-ops"),
			TEXT("feature/skills/diagnose-provider-routing"),
			EHyperTwistSkillFamily::ProviderOperations,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/diagnose-provider-routing"),
					TEXT("service/skills/diagnose-provider-routing"),
					TEXT("feature/skills/diagnose-provider-routing"),
					TEXT("workflow/provider-routing-diagnostic"),
					true,
					TEXT("Live first-party provider-routing diagnostic surface over the landed provider-neutral routing and route-health seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/provider-routing-diagnostics"),
					TEXT("Provider Routing Diagnostics"),
					false,
					true,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads provider-neutral recognition/provider state to emit bounded provider-routing diagnostic output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/provider-routing-diagnostic-brief")},
				true,
				TEXT("Provider-routing diagnostic output must remain provenance-visible and bounded to first-party provider-neutral routing state.")
			),
			TEXT("Landed first-party provider-routing diagnostic surface above the landed provider-neutral speech/provider seams.")
		),
		MakeSkillEntry(
			TEXT("skill/audit-provider-usage"),
			TEXT("Audit Provider Usage"),
			TEXT("lane/skillization/provider-ops"),
			TEXT("feature/skills/audit-provider-usage"),
			EHyperTwistSkillFamily::ProviderOperations,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/audit-provider-usage"),
					TEXT("service/skills/audit-provider-usage"),
					TEXT("feature/skills/audit-provider-usage"),
					TEXT("workflow/provider-usage-audit"),
					true,
					TEXT("Live first-party provider-usage audit surface over the landed normalized usage/cost and quota seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/provider-usage-audit"),
					TEXT("Provider Usage Audit"),
					false,
					true,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads normalized provider-neutral usage, cost, quota, and operator-shell state to emit bounded provider-usage audit output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/provider-usage-audit-brief")},
				true,
				TEXT("Provider-usage audit output must remain provenance-visible and bounded to normalized first-party accounting state.")
			),
			TEXT("Landed first-party provider-usage audit surface above the landed normalized usage/cost, quota, and operator-shell seams.")
		),
		MakeSkillEntry(
			TEXT("skill/inspect-provider-topology"),
			TEXT("Inspect Provider Topology"),
			TEXT("lane/skillization/provider-ops"),
			TEXT("feature/skills/inspect-provider-topology"),
			EHyperTwistSkillFamily::ProviderOperations,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/inspect-provider-topology"),
					TEXT("service/skills/inspect-provider-topology"),
					TEXT("feature/skills/inspect-provider-topology"),
					TEXT("workflow/provider-topology-inspection"),
					true,
					TEXT("Live first-party provider-topology inspection surface over the landed provider-neutral session, routing, and operator-shell seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/provider-topology"),
					TEXT("Provider Topology"),
					false,
					true,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads normalized provider-neutral session, routing, and operator-shell state to emit bounded provider-topology inspection output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/provider-topology-inspection-brief")},
				true,
				TEXT("Provider-topology inspection output must remain provenance-visible and bounded to first-party provider/session topology state.")
			),
			TEXT("Landed first-party provider-topology inspection surface above the landed provider-neutral session, routing, and operator-shell seams.")
		),
		MakeSkillEntry(
			TEXT("skill/diagnose-route-service"),
			TEXT("Diagnose Route Service"),
			TEXT("lane/skillization/provider-ops"),
			TEXT("feature/skills/diagnose-route-service"),
			EHyperTwistSkillFamily::ProviderOperations,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/diagnose-route-service"),
					TEXT("service/skills/diagnose-route-service"),
					TEXT("feature/skills/diagnose-route-service"),
					TEXT("workflow/provider-route-service-diagnostic"),
					true,
					TEXT("Live first-party route/service diagnostic surface over the landed provider-neutral routing, quota, and service-health seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/provider-route-service"),
					TEXT("Provider Route Service"),
					false,
					true,
					false,
					false,
					true,
					false,
					true,
					TEXT("Reads normalized provider-neutral routing, quota, and service-health state to emit bounded route/service diagnostics.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/provider-route-service-diagnostic-brief")},
				true,
				TEXT("Route/service diagnostic output must remain provenance-visible and bounded to normalized first-party routing and service-health state.")
			),
			TEXT("Landed first-party route/service diagnostic surface above the landed provider-neutral routing, usage/cost, and service-health seams.")
		),
		MakeSkillEntry(
			TEXT("skill/specify-domain-packaging"),
			TEXT("Specify Domain Packaging"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/specify-domain-packaging"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/specify-domain-packaging"),
					TEXT("service/skills/specify-domain-packaging"),
					TEXT("feature/skills/specify-domain-packaging"),
					TEXT("contract/domain-packaging-rules-brief"),
					true,
					TEXT("Landed first-party domain-pack packaging-rules surface above the landed plan/orchestration and provider usage/ops audit seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party skill and framework state to emit derived domain-pack packaging output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/domain-packaging-rules-brief")},
				true,
				TEXT("Domain-pack framework output must remain provenance-visible and bounded before any retained pack widening.")
			),
			TEXT("Landed first-party domain-pack packaging-rules framework above the landed plan/orchestration and provider usage/ops audit seams.")
		),
		MakeSkillEntry(
			TEXT("skill/specify-domain-pack-grouping"),
			TEXT("Specify Domain Pack Grouping"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/specify-domain-pack-grouping"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/specify-domain-pack-grouping"),
					TEXT("service/skills/specify-domain-pack-grouping"),
					TEXT("feature/skills/specify-domain-pack-grouping"),
					TEXT("contract/domain-pack-grouping-brief"),
					true,
					TEXT("Landed first-party domain-pack enable/disable-grouping surface above the landed plan/orchestration and provider usage/ops audit seams.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party skill and framework state to emit derived domain-pack grouping output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/domain-pack-enablement-grouping-brief")},
				true,
				TEXT("Domain-pack grouping output must remain provenance-visible and bounded before any retained pack widening.")
			),
			TEXT("Landed first-party domain-pack enable/disable-grouping framework above the landed plan/orchestration and provider usage/ops audit seams.")
		),
		MakeSkillEntry(
			TEXT("skill/review-training-replay-pack"),
			TEXT("Review Training Replay Pack"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/review-training-replay-pack"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/review-training-replay-pack"),
					TEXT("service/skills/review-training-replay-pack"),
					TEXT("feature/skills/review-training-replay-pack"),
					TEXT("contract/training-replay-review-pack-brief"),
					true,
					TEXT("Landed first-party retained training/replay review pack above the landed domain-pack framework seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party training, replay, and framework state to emit derived retained training/replay pack output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/training-replay-review-pack-brief")},
				true,
				TEXT("Retained training/replay pack output must stay provenance-visible and grounded in first-party training and replay surfaces.")
			),
			TEXT("Landed first-party retained training/replay review pack above the landed domain-pack framework seam.")
		),
		MakeSkillEntry(
			TEXT("skill/curate-curriculum-content-pack"),
			TEXT("Curate Curriculum Content Pack"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/curate-curriculum-content-pack"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/curate-curriculum-content-pack"),
					TEXT("service/skills/curate-curriculum-content-pack"),
					TEXT("feature/skills/curate-curriculum-content-pack"),
					TEXT("contract/curriculum-content-pack-brief"),
					true,
					TEXT("Landed first-party retained curriculum/content pack above the landed domain-pack framework seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party catalog and content-pack state to emit derived retained curriculum/content pack output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/curriculum-content-pack-brief")},
				true,
				TEXT("Retained curriculum/content pack output must stay provenance-visible and grounded in first-party catalog and content surfaces.")
			),
			TEXT("Landed first-party retained curriculum/content pack above the landed domain-pack framework seam.")
		),
		MakeSkillEntry(
			TEXT("skill/prepare-media-export-pack"),
			TEXT("Prepare Media Export Pack"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/prepare-media-export-pack"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/prepare-media-export-pack"),
					TEXT("service/skills/prepare-media-export-pack"),
					TEXT("feature/skills/prepare-media-export-pack"),
					TEXT("contract/media-export-pack-brief"),
					true,
					TEXT("Landed first-party retained media/export pack above the landed domain-pack framework seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party timer-export and media-export reference state to emit derived retained media/export pack output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/media-export-pack-brief")},
				true,
				TEXT("Retained media/export pack output must stay provenance-visible and grounded in first-party export and reference surfaces.")
			),
			TEXT("Landed first-party retained media/export pack above the landed domain-pack framework seam.")
		),
		MakeSkillEntry(
			TEXT("skill/compose-replay-explainer-pack"),
			TEXT("Compose Replay Explainer Pack"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/compose-replay-explainer-pack"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/compose-replay-explainer-pack"),
					TEXT("service/skills/compose-replay-explainer-pack"),
					TEXT("feature/skills/compose-replay-explainer-pack"),
					TEXT("contract/replay-explainer-pack-brief"),
					true,
					TEXT("Landed first-party optional replay-explainer pack above the retained domain-pack seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party replay, timer-export, retained-pack, and explainer/media contracts to emit a bounded replay-explainer pack brief.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/replay-explainer-pack-brief")},
				true,
				TEXT("Replay-explainer pack output must stay provenance-visible and avoid broad authoring-shell promotion.")
			),
			TEXT("Landed first-party optional replay-explainer pack above the retained domain-pack seam.")
		),
		MakeSkillEntry(
			TEXT("skill/prepare-media-parser-pack"),
			TEXT("Prepare Media Parser Pack"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/prepare-media-parser-pack"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/prepare-media-parser-pack"),
					TEXT("service/skills/prepare-media-parser-pack"),
					TEXT("feature/skills/prepare-media-parser-pack"),
					TEXT("contract/media-parser-pack-brief"),
					true,
					TEXT("Landed first-party optional media-parser pack above the retained domain-pack seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party timer-export, retained-pack, and parser/compliance contracts to emit a bounded media-parser pack brief.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/media-parser-pack-brief")},
				true,
				TEXT("Media-parser pack output must stay provenance-visible and preserve bounded parser and compliance posture.")
			),
			TEXT("Landed first-party optional media-parser pack above the retained domain-pack seam.")
		),
		MakeSkillEntry(
			TEXT("skill/curate-shared-fixture-pack"),
			TEXT("Curate Shared Fixture Pack"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/curate-shared-fixture-pack"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::ImplementedNow,
			false,
			true,
			{
				MakeCommandBinding(
					TEXT("command/skills/curate-shared-fixture-pack"),
					TEXT("service/skills/curate-shared-fixture-pack"),
					TEXT("feature/skills/curate-shared-fixture-pack"),
					TEXT("contract/shared-fixture-pack-brief"),
					true,
					TEXT("Landed first-party optional shared-fixture pack above the retained domain-pack seam.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					false,
					false,
					false,
					false,
					true,
					TEXT("Reads first-party retained-pack and shared-fixture allowlist, provenance, and refresh state to emit a bounded shared-fixture pack brief.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/shared-fixture-pack-brief")},
				true,
				TEXT("Shared-fixture pack output must stay provenance-visible and keep mixed-terms fixture boundaries explicit.")
			),
			TEXT("Landed first-party optional shared-fixture pack above the retained domain-pack seam.")
		),
		MakeSkillEntry(
			TEXT("skill/roux-session-review"),
			TEXT("Roux Session Review"),
			TEXT("lane/skillization/training-clean-room"),
			TEXT("feature/skills/roux-session-review"),
			EHyperTwistSkillFamily::TrainingCoaching,
			EHyperTwistSkillStatus::CleanRoomSkillSpecSpecified,
			false,
			false,
			{
				MakeCommandBinding(
					TEXT("command/skills/roux-session-review"),
					TEXT("service/specs/training-review/roux-session-review"),
					TEXT("feature/skills/roux-session-review"),
					TEXT("contract/training-review-brief"),
					false,
					TEXT("First-party clean-room command contract for a bounded Roux session review brief.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/training-review"),
					TEXT("Training Review"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Reads training and replay state to emit derived assistive coaching output.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/training-review-brief")},
				true,
				TEXT("Restrictive skill outputs must stay provenance-visible under any later clean-room wrapper.")
			),
			TEXT("Declared clean-room skill-spec-specified training/coaching skill family.")
		),
		MakeSkillEntry(
			TEXT("skill/curriculum-draft-pack"),
			TEXT("Curriculum Draft Pack"),
			TEXT("lane/skillization/domain-creative"),
			TEXT("feature/skills/curriculum-draft-pack"),
			EHyperTwistSkillFamily::DomainCreative,
			EHyperTwistSkillStatus::PlaceholderFamily,
			false,
			false,
			{
				MakeCommandBinding(
					TEXT("command/skills/curriculum-draft-pack"),
					TEXT("service/deferred/curriculum-draft-pack"),
					TEXT("feature/skills/curriculum-draft-pack"),
					TEXT("placeholder-family"),
					false,
					TEXT("Placeholder domain pack stays declared only until source-grounded.")
				)
			},
			{
				MakePermissionScope(
					TEXT("scope/skills/domain-creative"),
					TEXT("Domain Creative"),
					true,
					false,
					true,
					false,
					false,
					false,
					true,
					TEXT("Would emit derived curriculum artifacts only after later source-grounding.")
				)
			},
			MakeProvenanceDeclaration(
				EHyperTwistSkillLogPolicy::InvocationLedgerRequired,
				{TEXT("artifact/curriculum-draft-pack")},
				true,
				TEXT("Placeholder domain packs must still declare future provenance obligations.")
			),
			TEXT("Declared placeholder domain/creative family only.")
		)
	};

	RegistryState.SkillCount = RegistryState.Entries.Num();
	for (const FHyperTwistSkillManifestEntry& Entry : RegistryState.Entries)
	{
		RegistryState.EnabledByDefaultCount += Entry.bEnabledByDefault ? 1 : 0;
	}
	RegistryState.DisabledByDefaultCount =
		RegistryState.SkillCount - RegistryState.EnabledByDefaultCount;
	RegistryState.bAllSkillsOptionalAssistive = true;
	RegistryState.bDisabledSkillsRemainInstalled = true;
	RegistryState.bDisabledSkillsAreInert = true;
	RegistryState.bNoAdHocMetadataRequired = true;

	RegistryState.StatusCounts = {
		MakeStatusCount(EHyperTwistSkillStatus::ImplementedNow, 37),
		MakeStatusCount(EHyperTwistSkillStatus::CommandContractPending, 1),
		MakeStatusCount(EHyperTwistSkillStatus::CleanRoomSkillSpecSpecified, 1),
		MakeStatusCount(EHyperTwistSkillStatus::PlaceholderFamily, 1)
	};

	RegistryState.FamilyCounts = {
		MakeFamilyCount(EHyperTwistSkillFamily::SubstrateGovernance, 1),
		MakeFamilyCount(EHyperTwistSkillFamily::AnalysisReview, 8),
		MakeFamilyCount(EHyperTwistSkillFamily::MemoryContinuity, 8),
		MakeFamilyCount(EHyperTwistSkillFamily::ProviderOperations, 7),
		MakeFamilyCount(EHyperTwistSkillFamily::TrainingCoaching, 1),
		MakeFamilyCount(EHyperTwistSkillFamily::BrowserDocsDesign, 6),
		MakeFamilyCount(EHyperTwistSkillFamily::DomainCreative, 9)
	};

	return RegistryState;
}

FHyperTwistSkillControlState UHyperTwistSkillCoreLibrary::DeriveSkillControlState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlProfile& ControlProfile
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid() || !ControlProfile.IsStructurallyValid())
	{
		return FHyperTwistSkillControlState();
	}

	FHyperTwistSkillControlState ControlState;
	ControlState.RegistryId = RegistryState.RegistryId;
	ControlState.ManifestVersion = TEXT("s1b-v1");
	ControlState.ReferenceUtc = TEXT("2026-05-28T21:15:00Z");
	ControlState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	ControlState.ControlProfileId = ControlProfile.ProfileId;
	ControlState.MasterSwitch = MakeMasterSwitchState(ControlProfile);
	ControlState.Summary =
		TEXT("First-party skill settings, menu, and off-state control contract.");

	for (const FHyperTwistSkillManifestEntry& Entry : RegistryState.Entries)
	{
		const FHyperTwistSkillControlStateEntry SkillState =
			MakeControlStateEntry(Entry, ControlProfile);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillControlState();
		}

		ControlState.SkillStates.Add(SkillState);
		ControlState.EffectiveEnabledSkillCount += SkillState.bEffectiveEnabled ? 1 : 0;
		ControlState.VisibleSkillCount += SkillState.bEffectiveVisible ? 1 : 0;
		AddOrUpdateVisibilityGroup(ControlState, SkillState);
	}

	ControlState.SkillCount = ControlState.SkillStates.Num();
	ControlState.EffectiveDisabledSkillCount =
		ControlState.SkillCount - ControlState.EffectiveEnabledSkillCount;
	ControlState.HiddenSkillCount =
		ControlState.SkillCount - ControlState.VisibleSkillCount;
	ControlState.bCoreProductWorksWithAllSkillsOff = true;
	ControlState.bNoPromptBabysittingToDisable = true;
	ControlState.bAllInstalledSkillsRemainReenableable = true;

	return ControlState;
}

FHyperTwistSkillAuditLedgerState UHyperTwistSkillCoreLibrary::DeriveSkillAuditLedgerState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillAuditLedgerState();
	}

	FHyperTwistSkillAuditLedgerState AuditLedgerState;
	AuditLedgerState.RegistryId = RegistryState.RegistryId;
	AuditLedgerState.ManifestVersion = TEXT("s1c-v1");
	AuditLedgerState.ReferenceUtc = TEXT("2026-05-28T22:30:00Z");
	AuditLedgerState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	AuditLedgerState.ControlProfileId = ControlState.ControlProfileId;
	AuditLedgerState.LedgerId = TEXT("skill-audit-ledger/first-party");
	AuditLedgerState.EnabledSkillCount = ControlState.EffectiveEnabledSkillCount;
	AuditLedgerState.bNoUntraceableProductTruth = true;
	AuditLedgerState.bFailureRecordingSupported = true;
	AuditLedgerState.bCancelRecordingSupported = true;
	AuditLedgerState.bCommandServiceProvenanceVisible = true;
	AuditLedgerState.Summary =
		TEXT("First-party invocation, provenance, and audit ledger for optional skill outputs.");

	int32 InvocationOrdinal = 0;
	for (const FHyperTwistSkillControlStateEntry& SkillState : ControlState.SkillStates)
	{
		if (!SkillState.bEffectiveEnabled)
		{
			continue;
		}

		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillState.SkillId);
		if (Entry == nullptr || !Entry->IsStructurallyValid())
		{
			return FHyperTwistSkillAuditLedgerState();
		}

		const FHyperTwistSkillInvocationRecord Record =
			MakeInvocationRecord(*Entry, InvocationOrdinal);
		if (!Record.IsStructurallyValid())
		{
			return FHyperTwistSkillAuditLedgerState();
		}

		AuditLedgerState.InvocationRecords.Add(Record);
		AuditLedgerState.TraceableInvocationCount += Record.bInvocationTraceable ? 1 : 0;
		AuditLedgerState.ProductTruthOutputCount += Record.bOutputBecameProductTruth ? 1 : 0;
		AuditLedgerState.TraceableProductTruthOutputCount +=
			(Record.bOutputBecameProductTruth && Record.bOutputTraceable) ? 1 : 0;

		switch (Record.Outcome)
		{
		case EHyperTwistSkillInvocationOutcome::Succeeded:
			AuditLedgerState.SuccessfulInvocationCount += 1;
			break;

		case EHyperTwistSkillInvocationOutcome::Failed:
			AuditLedgerState.FailedInvocationCount += 1;
			break;

		case EHyperTwistSkillInvocationOutcome::Cancelled:
			AuditLedgerState.CancelledInvocationCount += 1;
			break;

		default:
			return FHyperTwistSkillAuditLedgerState();
		}

		InvocationOrdinal += 1;
	}

	AuditLedgerState.InvocationCount = AuditLedgerState.InvocationRecords.Num();
	AuditLedgerState.bNoUntraceableProductTruth =
		AuditLedgerState.ProductTruthOutputCount
			== AuditLedgerState.TraceableProductTruthOutputCount;

	return AuditLedgerState;
}

FHyperTwistSkillAuthoringHarnessState UHyperTwistSkillCoreLibrary::DeriveSkillAuthoringHarnessState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuditLedgerState& AuditLedgerState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuditLedgerState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuditLedgerState.RegistryId)
	{
		return FHyperTwistSkillAuthoringHarnessState();
	}

	FHyperTwistSkillAuthoringHarnessState HarnessState;
	HarnessState.RegistryId = RegistryState.RegistryId;
	HarnessState.ManifestVersion = TEXT("s1d-v1");
	HarnessState.ReferenceUtc = TEXT("2026-05-28T23:20:00Z");
	HarnessState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	HarnessState.AuditLedgerId = AuditLedgerState.LedgerId;
	HarnessState.TemplateVersion = TEXT("skill-authoring-template-v1");
	HarnessState.SkillCount = RegistryState.SkillCount;
	HarnessState.bNewSkillsCanBeAddedWithoutInventingStructure = true;
	HarnessState.bEverySkillHasSmokeContract = true;
	HarnessState.bEverySkillHasEvalContract = true;
	HarnessState.bExamplesGroundedInFirstPartyRegistry = true;
	HarnessState.bValidationHarnessUsesAuditLedgerWhenLive = true;
	HarnessState.Summary =
		TEXT("First-party skill authoring template, examples, and validation-harness contract.");

	HarnessState.TemplateSections = {
		MakeAuthoringSection(
			TEXT("section/skill-identity-owner"),
			TEXT("Identity And Ownership"),
			{
				MakeAuthoringField(
					TEXT("field/skill-id"),
					TEXT("Skill Id"),
					TEXT("registry/manifest"),
					TEXT("skill/skillization-governance"),
					TEXT("Stable first-party identifier for the skill.")
				),
				MakeAuthoringField(
					TEXT("field/owner-lane-feature"),
					TEXT("Owner Lane And Feature"),
					TEXT("registry/manifest"),
					TEXT("lane/skillization/substrate -> feature/skills/registry-governance"),
					TEXT("Links the skill back to its owning product lane and feature.")
				)
			},
			TEXT("Required identity and ownership fields for every first-party skill.")
		),
		MakeAuthoringSection(
			TEXT("section/skill-command-binding"),
			TEXT("Command And Service Binding"),
			{
				MakeAuthoringField(
					TEXT("field/command-surface-id"),
					TEXT("Command Surface Id"),
					TEXT("registry/manifest"),
					TEXT("command/skills/inspect-registry"),
					TEXT("Stable product-owned command surface for the skill.")
				),
				MakeAuthoringField(
					TEXT("field/service-binding-id"),
					TEXT("Service Binding Id"),
					TEXT("registry/manifest"),
					TEXT("service/skills/registry-state"),
					TEXT("First-party service or deferred wrapper binding declared for the skill.")
				)
			},
			TEXT("Required command and service binding fields for every first-party skill.")
		),
		MakeAuthoringSection(
			TEXT("section/skill-permission-provenance"),
			TEXT("Permission And Provenance"),
			{
				MakeAuthoringField(
					TEXT("field/permission-scope"),
					TEXT("Permission Scope"),
					TEXT("registry/manifest"),
					TEXT("scope/skills/governance"),
					TEXT("Declared state access and assistive permissions.")
				),
				MakeAuthoringField(
					TEXT("field/artifact-kind"),
					TEXT("Produced Artifact Kind"),
					TEXT("registry/manifest"),
					TEXT("artifact/skill-registry-state"),
					TEXT("Declared provenance-visible output kind for the skill.")
				)
			},
			TEXT("Required permission and provenance fields for every first-party skill.")
		),
		MakeAuthoringSection(
			TEXT("section/skill-off-state"),
			TEXT("Off-State And Visibility"),
			{
				MakeAuthoringField(
					TEXT("field/enable-settings-key"),
					TEXT("Enable Settings Key"),
					TEXT("control-state"),
					TEXT("skills.enabled.skill.skillization.governance"),
					TEXT("Durable enable/disable control key for the skill.")
				),
				MakeAuthoringField(
					TEXT("field/visibility-group"),
					TEXT("Visibility Group"),
					TEXT("control-state"),
					TEXT("skill-group/substrate-governance"),
					TEXT("Family visibility grouping and off-state exposure contract.")
				)
			},
			TEXT("Required off-state and visibility fields for every first-party skill.")
		),
		MakeAuthoringSection(
			TEXT("section/skill-invocation-audit"),
			TEXT("Invocation And Audit"),
			{
				MakeAuthoringField(
					TEXT("field/invocation-id"),
					TEXT("Invocation Id"),
					TEXT("audit-ledger"),
					TEXT("skill-invocation/skill-skillization-governance/00"),
					TEXT("Traceable invocation identity for live skill output.")
				),
				MakeAuthoringField(
					TEXT("field/outcome-recording"),
					TEXT("Outcome Recording"),
					TEXT("audit-ledger"),
					TEXT("Succeeded / Failed / Cancelled"),
					TEXT("Outcome recording contract required for traceability.")
				)
			},
			TEXT("Required invocation and audit fields for every first-party skill.")
		),
		MakeAuthoringSection(
			TEXT("section/skill-validation-contract"),
			TEXT("Validation Contract"),
			{
				MakeAuthoringField(
					TEXT("field/smoke-contract"),
					TEXT("Smoke Contract"),
					TEXT("validation-harness"),
					TEXT("LiveContract / DeclarationOnly / PlaceholderStructureOnly"),
					TEXT("Per-skill smoke validation mode.")
				),
				MakeAuthoringField(
					TEXT("field/eval-contract"),
					TEXT("Eval Contract"),
					TEXT("validation-harness"),
					TEXT("LiveContract / DeferredUntilWrapper / DeferredUntilCleanRoomSpec / DeferredUntilCleanRoomSkillSpec"),
					TEXT("Per-skill eval validation mode.")
				)
			},
			TEXT("Required validation-harness fields for every first-party skill.")
		)
	};

	for (const FHyperTwistSkillManifestEntry& Entry : RegistryState.Entries)
	{
		const FHyperTwistSkillAuthoringExampleState ExampleState =
			MakeAuthoringExampleState(Entry, AuditLedgerState);
		if (!ExampleState.IsStructurallyValid())
		{
			return FHyperTwistSkillAuthoringHarnessState();
		}

		const FHyperTwistSkillValidationContractCase SmokeCase =
			MakeValidationContractCase(
				Entry,
				EHyperTwistSkillValidationContractKind::Smoke,
				DetermineSmokeExecutionMode(Entry.Status),
				AuditLedgerState
			);
		const FHyperTwistSkillValidationContractCase EvalCase =
			MakeValidationContractCase(
				Entry,
				EHyperTwistSkillValidationContractKind::Eval,
				DetermineEvalExecutionMode(Entry.Status),
				AuditLedgerState
			);
		if (!SmokeCase.IsStructurallyValid() || !EvalCase.IsStructurallyValid())
		{
			return FHyperTwistSkillAuthoringHarnessState();
		}

		HarnessState.Examples.Add(ExampleState);
		HarnessState.ValidationCases.Add(SmokeCase);
		HarnessState.ValidationCases.Add(EvalCase);
		HarnessState.SkillsWithSmokeContractCount += 1;
		HarnessState.SkillsWithEvalContractCount += 1;
		HarnessState.bExamplesGroundedInFirstPartyRegistry &= ExampleState.bGroundedInRegistry;
		HarnessState.bValidationHarnessUsesAuditLedgerWhenLive &=
			SmokeCase.ExecutionMode != EHyperTwistSkillValidationExecutionMode::LiveContract
			|| SmokeCase.bUsesAuditLedgerEvidence;
		HarnessState.bValidationHarnessUsesAuditLedgerWhenLive &=
			EvalCase.ExecutionMode != EHyperTwistSkillValidationExecutionMode::LiveContract
			|| EvalCase.bUsesAuditLedgerEvidence;
	}

	HarnessState.ExampleCount = HarnessState.Examples.Num();
	HarnessState.ValidationCaseCount = HarnessState.ValidationCases.Num();

	return HarnessState;
}

FHyperTwistSkillAnalyzerWrapperState UHyperTwistSkillCoreLibrary::DeriveSkillAnalyzerWrapperState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillAnalyzerWrapperState();
	}

	FHyperTwistSkillAnalyzerWrapperState WrapperState;
	WrapperState.RegistryId = RegistryState.RegistryId;
	WrapperState.ManifestVersion = TEXT("s2a-v1");
	WrapperState.ReferenceUtc = TEXT("2026-05-28T23:58:00Z");
	WrapperState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	WrapperState.TemplateVersion = AuthoringHarnessState.TemplateVersion;
	WrapperState.bEveryWrapperMapsToStableInvocationPattern = true;
	WrapperState.bEveryWrapperEmitsStructuredOutput = true;
	WrapperState.bOnlyImplementedPermissiveWrappersIncluded = true;
	WrapperState.Summary =
		TEXT("First-party permissive analyzer wrappers over landed HyperTwist seams.");

	for (const FHyperTwistSkillManifestEntry& Entry : RegistryState.Entries)
	{
		if (Entry.Status != EHyperTwistSkillStatus::ImplementedNow
			|| !IsPermissiveAnalyzerWrapperSkill(Entry.SkillId))
		{
			continue;
		}

		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, Entry.SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, Entry.SkillId);
		if (ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, Entry.SkillId))
		{
			return FHyperTwistSkillAnalyzerWrapperState();
		}

		for (const FString& ArtifactKind : Entry.Provenance.ProducedArtifactKinds)
		{
			const FHyperTwistSkillAnalyzerWrapperOutput Output =
				MakeAnalyzerWrapperOutput(Entry, ArtifactKind);
			if (!Output.IsStructurallyValid())
			{
				return FHyperTwistSkillAnalyzerWrapperState();
			}

			WrapperState.Outputs.Add(Output);
			WrapperState.ArchitectureScanCount +=
				Output.OutputKindId == TEXT("wrapper-output/architecture-scan") ? 1 : 0;
			WrapperState.PolicyScanCount +=
				Output.OutputKindId == TEXT("wrapper-output/policy-scan") ? 1 : 0;
			WrapperState.RouteInspectionCount +=
				Output.OutputKindId == TEXT("wrapper-output/route-inspection") ? 1 : 0;
			WrapperState.WatchAndRecheckCount +=
				Output.OutputKindId == TEXT("wrapper-output/watch-and-recheck") ? 1 : 0;
		}
	}

	TArray<FString> ImplementedSkillIds;
	for (const FHyperTwistSkillAnalyzerWrapperOutput& Output : WrapperState.Outputs)
	{
		ImplementedSkillIds.AddUnique(Output.SkillId);
		WrapperState.bEveryWrapperMapsToStableInvocationPattern &= Output.bStableInvocationPattern;
		WrapperState.bEveryWrapperEmitsStructuredOutput &= Output.bStructuredOutput;
		WrapperState.bOnlyImplementedPermissiveWrappersIncluded &=
			IsPermissiveAnalyzerWrapperSkill(Output.SkillId);
	}

	WrapperState.SkillCount = ImplementedSkillIds.Num();
	WrapperState.OutputCount = WrapperState.Outputs.Num();

	return WrapperState;
}

FHyperTwistSkillCleanRoomCommandContractState
UHyperTwistSkillCoreLibrary::DeriveSkillCleanRoomCommandContractState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillCleanRoomCommandContractState();
	}

	FHyperTwistSkillCleanRoomCommandContractState ContractState;
	ContractState.RegistryId = RegistryState.RegistryId;
	ContractState.ManifestVersion = TEXT("s2c-v1");
	ContractState.ReferenceUtc = TEXT("2026-05-29T00:47:00Z");
	ContractState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	ContractState.TemplateVersion = TEXT("skill-clean-room-command-contract-v1");
	ContractState.bEverySpecUsesFirstPartyTerms = true;
	ContractState.bEverySpecAvoidsDonorWording = true;
	ContractState.bEverySpecPreservesOptionalAssistiveOffState = true;
	ContractState.bEverySpecRestrictsToDerivedAssistiveOutput = true;
	ContractState.bEverySpecRequiresProvenanceLedger = true;
	ContractState.bEverySpecAvoidsProductTruthMutation = true;
	ContractState.bEverySpecMayBindFutureWrapperWithoutContractRewrite = true;
	ContractState.bEverySpecHasAuthoringHarnessCoverage = true;
	ContractState.bEverySpecDefersEvalUntilCleanRoomSkillSpec = true;
	ContractState.Summary =
		TEXT("First-party clean-room command-contract state for restrictive skill lanes.");

	for (const FHyperTwistSkillManifestEntry& Entry : RegistryState.Entries)
	{
		if (!HasAtLeastCleanRoomCommandContractStatus(Entry.Status)
			|| !IsCleanRoomCommandContractSkill(Entry.SkillId))
		{
			continue;
		}

		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, Entry.SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, Entry.SkillId);
		if (ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ControlEntry->bEffectiveEnabled
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !(
				HasEvalValidationCaseWithMode(
					AuthoringHarnessState,
					Entry.SkillId,
					EHyperTwistSkillValidationExecutionMode::DeferredUntilCleanRoomSkillSpec
				)
				|| HasEvalValidationCaseWithMode(
					AuthoringHarnessState,
					Entry.SkillId,
					EHyperTwistSkillValidationExecutionMode::DeclarationOnly
				)
			))
		{
			return FHyperTwistSkillCleanRoomCommandContractState();
		}

		const FHyperTwistSkillCleanRoomCommandContractSpec Spec =
			MakeCleanRoomCommandContractSpec(Entry);
		if (!Spec.IsStructurallyValid())
		{
			return FHyperTwistSkillCleanRoomCommandContractState();
		}

		ContractState.Specs.Add(Spec);
	}

	TArray<FString> SkillIds;
	TArray<FString> SafetyRuleIds;
	for (const FHyperTwistSkillCleanRoomCommandContractSpec& Spec : ContractState.Specs)
	{
		SkillIds.AddUnique(Spec.SkillId);
		ContractState.bEverySpecUsesFirstPartyTerms &= Spec.bUsesFirstPartyTermsOnly;
		ContractState.bEverySpecAvoidsDonorWording &= Spec.bAvoidsDonorWording;
		ContractState.bEverySpecPreservesOptionalAssistiveOffState
			&= Spec.bPreservesOptionalAssistiveOffState;
		ContractState.bEverySpecRestrictsToDerivedAssistiveOutput &= Spec.bDerivedAssistiveOnly;
		ContractState.bEverySpecRequiresProvenanceLedger &= Spec.bRequiresProvenanceLedger;
		ContractState.bEverySpecAvoidsProductTruthMutation &= Spec.bNoProductTruthMutation;
		ContractState.bEverySpecMayBindFutureWrapperWithoutContractRewrite
			&= Spec.bFutureWrapperMayBindWithoutContractRewrite;
		ContractState.bEverySpecHasAuthoringHarnessCoverage
			&= Spec.RequiredTemplateSectionIds.Num() > 0;
		ContractState.bEverySpecDefersEvalUntilCleanRoomSkillSpec
			&= Spec.EvalExecutionMode
				== EHyperTwistSkillValidationExecutionMode::DeferredUntilCleanRoomSkillSpec;

		for (const FString& SafetyRuleId : Spec.SafetyRuleIds)
		{
			SafetyRuleIds.AddUnique(SafetyRuleId);
		}
	}

	ContractState.SkillCount = SkillIds.Num();
	ContractState.SpecCount = ContractState.Specs.Num();
	ContractState.SafetyRuleCount = SafetyRuleIds.Num();

	return ContractState;
}

FHyperTwistSkillCleanRoomSkillSpecState
UHyperTwistSkillCoreLibrary::DeriveSkillCleanRoomSkillSpecState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillCleanRoomCommandContractState& CommandContractState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !CommandContractState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != CommandContractState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != CommandContractState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillCleanRoomSkillSpecState();
	}

	FHyperTwistSkillCleanRoomSkillSpecState SkillSpecState;
	SkillSpecState.RegistryId = RegistryState.RegistryId;
	SkillSpecState.ManifestVersion = TEXT("s2c-v1");
	SkillSpecState.ReferenceUtc = TEXT("2026-05-29T01:12:00Z");
	SkillSpecState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	SkillSpecState.TemplateVersion = TEXT("skill-clean-room-spec-v1");
	SkillSpecState.bEverySpecUsesFirstPartyTerms = true;
	SkillSpecState.bEverySpecAvoidsDonorWording = true;
	SkillSpecState.bEverySpecBindsToCommandContractState = true;
	SkillSpecState.bEverySpecReadyForFutureImplementation = true;
	SkillSpecState.bNoSpecClaimsLiveImplementation = true;
	SkillSpecState.bEverySpecPreservesOptionalAssistiveOffState = true;
	SkillSpecState.bEverySpecRestrictsToDerivedAssistiveOutput = true;
	SkillSpecState.bEverySpecRequiresProvenanceLedger = true;
	SkillSpecState.bEverySpecAvoidsProductTruthMutation = true;
	SkillSpecState.bEverySpecHasAuthoringHarnessCoverage = true;
	SkillSpecState.bEverySpecUsesDeclarationOnlyValidation = true;
	SkillSpecState.Summary =
		TEXT("First-party clean-room-ready skill specs for restrictive skill lanes.");

	for (const FHyperTwistSkillManifestEntry& Entry : RegistryState.Entries)
	{
		if (Entry.Status != EHyperTwistSkillStatus::CleanRoomSkillSpecSpecified
			|| !IsCleanRoomSkillSpecSkill(Entry.SkillId))
		{
			continue;
		}

		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, Entry.SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, Entry.SkillId);
		const FHyperTwistSkillCleanRoomCommandContractSpec* CommandContractSpec =
			CommandContractState.Specs.FindByPredicate(
				[&Entry](const FHyperTwistSkillCleanRoomCommandContractSpec& Candidate)
				{
					return Candidate.SkillId == Entry.SkillId;
				}
			);
		if (ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ControlEntry->bEffectiveEnabled
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| CommandContractSpec == nullptr
			|| !CommandContractSpec->IsStructurallyValid()
			|| !HasEvalValidationCaseWithMode(
				AuthoringHarnessState,
				Entry.SkillId,
				EHyperTwistSkillValidationExecutionMode::DeclarationOnly
			))
		{
			return FHyperTwistSkillCleanRoomSkillSpecState();
		}

		const FHyperTwistSkillCleanRoomSkillSpec SkillSpec =
			MakeCleanRoomSkillSpec(Entry, *CommandContractSpec);
		if (!SkillSpec.IsStructurallyValid())
		{
			return FHyperTwistSkillCleanRoomSkillSpecState();
		}

		SkillSpecState.Specs.Add(SkillSpec);
	}

	TArray<FString> SkillIds;
	TArray<FString> StepIds;
	TArray<FString> SafetyRuleIds;
	for (const FHyperTwistSkillCleanRoomSkillSpec& Spec : SkillSpecState.Specs)
	{
		SkillIds.AddUnique(Spec.SkillId);
		SkillSpecState.bEverySpecUsesFirstPartyTerms &= Spec.bUsesFirstPartyTermsOnly;
		SkillSpecState.bEverySpecAvoidsDonorWording &= Spec.bAvoidsDonorWording;
		SkillSpecState.bEverySpecBindsToCommandContractState &= !Spec.CommandContractSpecId.IsEmpty();
		SkillSpecState.bEverySpecReadyForFutureImplementation &= Spec.bSpecReadyForFutureImplementation;
		SkillSpecState.bNoSpecClaimsLiveImplementation &= Spec.bNotLiveImplementationYet;
		SkillSpecState.bEverySpecPreservesOptionalAssistiveOffState
			&= Spec.bPreservesOptionalAssistiveOffState;
		SkillSpecState.bEverySpecRestrictsToDerivedAssistiveOutput &= Spec.bDerivedAssistiveOnly;
		SkillSpecState.bEverySpecRequiresProvenanceLedger &= Spec.bRequiresProvenanceLedger;
		SkillSpecState.bEverySpecAvoidsProductTruthMutation &= Spec.bNoProductTruthMutation;
		SkillSpecState.bEverySpecHasAuthoringHarnessCoverage
			&= Spec.RequiredTemplateSectionIds.Num() > 0;
		SkillSpecState.bEverySpecUsesDeclarationOnlyValidation
			&= Spec.SmokeExecutionMode == EHyperTwistSkillValidationExecutionMode::DeclarationOnly
				&& Spec.EvalExecutionMode == EHyperTwistSkillValidationExecutionMode::DeclarationOnly;

		for (const FString& StepId : Spec.SpecStepIds)
		{
			StepIds.AddUnique(StepId);
		}

		for (const FString& SafetyRuleId : Spec.SafetyRuleIds)
		{
			SafetyRuleIds.AddUnique(SafetyRuleId);
		}
	}

	SkillSpecState.SkillCount = SkillIds.Num();
	SkillSpecState.SpecCount = SkillSpecState.Specs.Num();
	SkillSpecState.StepCount = StepIds.Num();
	SkillSpecState.SafetyRuleCount = SafetyRuleIds.Num();

	return SkillSpecState;
}

FHyperTwistSkillContinuityResumeState
UHyperTwistSkillCoreLibrary::DeriveSkillContinuityResumeState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistMemoryChronicleContinuityState& ChronicleContinuityState,
	const FHyperTwistMemoryRecallSharedContextState& RecallSharedContextState,
	const FHyperTwistMemoryKnowledgeNotesState& KnowledgeNotesState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !ChronicleContinuityState.IsStructurallyValid()
		|| !RecallSharedContextState.IsStructurallyValid()
		|| !KnowledgeNotesState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillContinuityResumeState();
	}

	FHyperTwistSkillContinuityResumeState ContinuityState;
	ContinuityState.RegistryId = RegistryState.RegistryId;
	ContinuityState.ManifestVersion = TEXT("s3a-v1");
	ContinuityState.ReferenceUtc = TEXT("2026-05-29T03:05:00Z");
	ContinuityState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	ContinuityState.TemplateVersion = TEXT("skill-continuity-resume-v1");
	ContinuityState.bEveryLiveSkillReadsAuthoritativeStores = true;
	ContinuityState.bEverySkillPreservesOptionalAssistiveOffState = true;
	ContinuityState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	ContinuityState.bNoSkillClaimsActiveUserNoteCaptureWithoutOwnerActivation = true;
	ContinuityState.Summary =
		TEXT("First-party continuity and resume skill layer over landed memory seams.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto BuildContinuitySkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillContinuityResumeSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsContinuityResumeSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid())
		{
			return FHyperTwistSkillContinuityResumeSkill();
		}

		const bool bHasValidationCoverage =
			Entry->Status == EHyperTwistSkillStatus::ImplementedNow
				? HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
				: HasEvalValidationCaseWithMode(
					AuthoringHarnessState,
					SkillId,
					EHyperTwistSkillValidationExecutionMode::DeferredUntilWrapper
				);

		if (!bHasValidationCoverage)
		{
			return FHyperTwistSkillContinuityResumeSkill();
		}

		FHyperTwistSkillContinuityResumeSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = bHasValidationCoverage;

		if (SkillId == TEXT("skill/resume-session"))
		{
			SkillState.InputStateKinds = {
				TEXT("state/memory-chronicle-continuity"),
				TEXT("state/memory-resume-pack"),
				TEXT("state/memory-continuity-guard")
			};

			for (const FHyperTwistMemoryResumePack& ResumePack :
				ChronicleContinuityState.ResumePacks)
			{
				AddPreviewHeadline(SkillState.PreviewHeadlines, ResumePack.Headline);
			}
			for (const FHyperTwistMemoryContinuityGuard& ContinuityGuard :
				ChronicleContinuityState.ContinuityGuards)
			{
				if (ContinuityGuard.bBlocksResume)
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, ContinuityGuard.Headline);
				}
			}

			SkillState.AvailableItemCount = ChronicleContinuityState.ResumePacks.Num();
			SkillState.BlockingItemCount = ChronicleContinuityState.BlockingGuardCount;
			SkillState.bLiveSkill = true;
			SkillState.bReadsAuthoritativeStores =
				ChronicleContinuityState.ResumePacks.Num() > 0
				&& ChronicleContinuityState.ResumeRequiredCount > 0;
			SkillState.bAvailableNow = ChronicleContinuityState.ResumePacks.Num() > 0;
			SkillState.bRequiresOwnerActivation = false;
			SkillState.Summary =
				TEXT("Live first-party continuity skill over authoritative resume packs and guards.");
		}
		else if (SkillId == TEXT("skill/search-history"))
		{
			SkillState.InputStateKinds = {
				TEXT("state/memory-recall-shared-context"),
				TEXT("state/memory-recall-match"),
				TEXT("state/memory-provenance-drilldown")
			};

			for (const FHyperTwistMemoryRecallMatch& RecallMatch :
				RecallSharedContextState.RecallMatches)
			{
				if (RecallMatch.AuthorityKind ==
					EHyperTwistMemoryAuthorityKind::Authoritative)
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, RecallMatch.Headline);
				}
			}
			AddPreviewHeadline(SkillState.PreviewHeadlines, RecallSharedContextState.QueryText);

			SkillState.AvailableItemCount = RecallSharedContextState.AuthoritativeRecallCount;
			SkillState.BlockingItemCount = 0;
			SkillState.bLiveSkill = true;
			SkillState.bReadsAuthoritativeStores =
				RecallSharedContextState.AuthoritativeRecallCount > 0;
			SkillState.bAvailableNow =
				RecallSharedContextState.AuthoritativeRecallCount > 0;
			SkillState.bRequiresOwnerActivation = false;
			SkillState.Summary =
				TEXT("Live first-party history-search skill over authoritative memory evidence.");
		}
		else if (SkillId == TEXT("skill/capture-note"))
		{
			SkillState.InputStateKinds = {
				TEXT("state/memory-knowledge-notes"),
				TEXT("state/memory-user-notes-posture")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				KnowledgeNotesState.UserNotesPosture.Headline
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				KnowledgeNotesState.UserNotesPosture.SummaryLine
			);

			SkillState.AvailableItemCount =
				KnowledgeNotesState.bUserNotesLaneAvailable ? 1 : 0;
			SkillState.BlockingItemCount =
				KnowledgeNotesState.UserNotesPosture.bRequiresSeparateOwnerActivation ? 1 : 0;
			SkillState.bLiveSkill = false;
			SkillState.bReadsAuthoritativeStores =
				KnowledgeNotesState.UserNotesPosture.bOwnershipJustified;
			SkillState.bAvailableNow = KnowledgeNotesState.bUserNotesLaneAvailable;
			SkillState.bRequiresOwnerActivation =
				KnowledgeNotesState.UserNotesPosture.bRequiresSeparateOwnerActivation;
			SkillState.Summary =
				TEXT("Declared note-capture skill remains pending until the user-notes owner lane is explicitly active.");
		}

		if (SkillState.PreviewHeadlines.Num() == 0)
		{
			AddPreviewHeadline(SkillState.PreviewHeadlines, SkillState.DisplayLabel);
		}

		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/resume-session")),
		FString(TEXT("skill/search-history")),
		FString(TEXT("skill/capture-note"))
	})
	{
		const FHyperTwistSkillContinuityResumeSkill SkillState =
			BuildContinuitySkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillContinuityResumeState();
		}

		ContinuityState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillContinuityResumeSkill& SkillState : ContinuityState.Skills)
	{
		ContinuityState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		ContinuityState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		ContinuityState.PendingSkillCount +=
			SkillState.Status == EHyperTwistSkillStatus::CommandContractPending ? 1 : 0;
		ContinuityState.ResumeSessionSkillCount +=
			SkillState.SkillId == TEXT("skill/resume-session") ? 1 : 0;
		ContinuityState.SearchHistorySkillCount +=
			SkillState.SkillId == TEXT("skill/search-history") ? 1 : 0;
		ContinuityState.CaptureNoteSkillCount +=
			SkillState.SkillId == TEXT("skill/capture-note") ? 1 : 0;
		ContinuityState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;

		if (SkillState.bLiveSkill)
		{
			ContinuityState.bEveryLiveSkillReadsAuthoritativeStores &=
				SkillState.bReadsAuthoritativeStores;
			ContinuityState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}

		if (SkillState.SkillId == TEXT("skill/capture-note"))
		{
			ContinuityState.bNoSkillClaimsActiveUserNoteCaptureWithoutOwnerActivation =
				!SkillState.bLiveSkill
				&& !SkillState.bAvailableNow
				&& SkillState.bRequiresOwnerActivation;
		}
	}

	ContinuityState.SkillCount = ContinuityState.Skills.Num();

	return ContinuityState;
}

FHyperTwistSkillRecallCompactViewState
UHyperTwistSkillCoreLibrary::DeriveSkillRecallCompactViewState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistMemoryRecallSharedContextState& RecallSharedContextState,
	const FHyperTwistMemoryDerivedAdjunctState& DerivedAdjunctState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !RecallSharedContextState.IsStructurallyValid()
		|| !DerivedAdjunctState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillRecallCompactViewState();
	}

	FHyperTwistSkillRecallCompactViewState RecallCompactViewState;
	RecallCompactViewState.RegistryId = RegistryState.RegistryId;
	RecallCompactViewState.ManifestVersion = TEXT("s3b-v1");
	RecallCompactViewState.ReferenceUtc = TEXT("2026-05-29T04:05:00Z");
	RecallCompactViewState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	RecallCompactViewState.TemplateVersion = TEXT("skill-recall-compact-view-v1");
	RecallCompactViewState.bEveryLiveSkillReadsAuthoritativeStores = true;
	RecallCompactViewState.bEverySkillPreservesOptionalAssistiveOffState = true;
	RecallCompactViewState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	RecallCompactViewState.bCompactViewsRemainOptionalAndLinkedToAuthoritativeSources = true;
	RecallCompactViewState.Summary =
		TEXT("First-party recall and compact-view skill layer over landed memory seams.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto AddUniqueSourceId = [](
		TArray<FString>& SourceIds,
		const FString& SourceId
	)
	{
		if (!SourceId.IsEmpty())
		{
			SourceIds.AddUnique(SourceId);
		}
	};

	auto BuildRecallCompactSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillRecallCompactViewSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsRecallCompactViewSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId))
		{
			return FHyperTwistSkillRecallCompactViewSkill();
		}

		FHyperTwistSkillRecallCompactViewSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;

		TArray<FString> LinkedSourceIds;

		if (SkillId == TEXT("skill/recall-memory"))
		{
			SkillState.InputStateKinds = {
				TEXT("state/memory-recall-shared-context"),
				TEXT("state/memory-recall-match"),
				TEXT("state/memory-provenance-drilldown")
			};

			for (const FHyperTwistMemoryRecallMatch& RecallMatch :
				RecallSharedContextState.RecallMatches)
			{
				if (RecallMatch.AuthorityKind ==
					EHyperTwistMemoryAuthorityKind::Authoritative)
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, RecallMatch.Headline);
					AddUniqueSourceId(LinkedSourceIds, RecallMatch.SourceEntityId);
				}
			}
			for (const FHyperTwistMemoryProvenanceDrillDownEntry& DrillDownEntry :
				RecallSharedContextState.ProvenanceDrillDownEntries)
			{
				AddPreviewHeadline(SkillState.PreviewHeadlines, DrillDownEntry.Headline);
				AddUniqueSourceId(LinkedSourceIds, DrillDownEntry.RootEntityId);
			}
			AddPreviewHeadline(SkillState.PreviewHeadlines, RecallSharedContextState.QueryText);

			SkillState.AvailableItemCount = RecallSharedContextState.AuthoritativeRecallCount;
			SkillState.LinkedSourceCount = LinkedSourceIds.Num();
			SkillState.bReadsAuthoritativeStores =
				RecallSharedContextState.AuthoritativeRecallCount > 0
				&& RecallSharedContextState.ProvenanceDrillDownEntries.Num() > 0;
			SkillState.bAvailableNow =
				RecallSharedContextState.AuthoritativeRecallCount > 0;
			SkillState.bOptionalCompactView = false;
			SkillState.bLinkedToAuthoritativeSources = SkillState.LinkedSourceCount > 0;
			SkillState.Summary =
				TEXT("Live first-party recall skill over authoritative memory matches and provenance drill-down lineage.");
		}
		else if (SkillId == TEXT("skill/generate-compact-view"))
		{
			SkillState.InputStateKinds = {
				TEXT("state/memory-derived-adjunct"),
				TEXT("state/memory-compact-summary"),
				TEXT("state/memory-reduced-context-packet"),
				TEXT("state/memory-digest-view")
			};

			for (const FHyperTwistMemoryCompactSummary& CompactSummary :
				DerivedAdjunctState.CompactSummaries)
			{
				AddPreviewHeadline(SkillState.PreviewHeadlines, CompactSummary.Headline);
				for (const FString& SourceEntityId : CompactSummary.SourceEntityIds)
				{
					AddUniqueSourceId(LinkedSourceIds, SourceEntityId);
				}
			}
			for (const FHyperTwistMemoryReducedContextPacket& ReducedContextPacket :
				DerivedAdjunctState.ReducedContextPackets)
			{
				AddPreviewHeadline(SkillState.PreviewHeadlines, ReducedContextPacket.Headline);
				for (const FString& SourceEntityId : ReducedContextPacket.SourceEntityIds)
				{
					AddUniqueSourceId(LinkedSourceIds, SourceEntityId);
				}
			}
			for (const FHyperTwistMemoryDigestView& DigestView :
				DerivedAdjunctState.DigestViews)
			{
				AddPreviewHeadline(SkillState.PreviewHeadlines, DigestView.Title);
				AddPreviewHeadline(SkillState.PreviewHeadlines, DigestView.SummaryLine);
				for (const FString& SourceEntityId : DigestView.SourceEntityIds)
				{
					AddUniqueSourceId(LinkedSourceIds, SourceEntityId);
				}
			}

			SkillState.AvailableItemCount =
				DerivedAdjunctState.CompactSummaryCount
				+ DerivedAdjunctState.ReducedContextPacketCount
				+ DerivedAdjunctState.DigestViewCount;
			SkillState.LinkedSourceCount = LinkedSourceIds.Num();
			SkillState.bReadsAuthoritativeStores =
				DerivedAdjunctState.bDerivedGateActive
				&& DerivedAdjunctState.bDerivedOnlyStorageConfirmed
				&& DerivedAdjunctState.CompactSummaryCount > 0
				&& DerivedAdjunctState.ReducedContextPacketCount > 0
				&& DerivedAdjunctState.DigestViewCount > 0;
			SkillState.bAvailableNow = DerivedAdjunctState.bDerivedGateActive;
			SkillState.bOptionalCompactView = true;
			SkillState.bLinkedToAuthoritativeSources = SkillState.LinkedSourceCount > 0;
			SkillState.Summary =
				TEXT("Live first-party optional compact-view skill over derived adjunct surfaces linked back to authoritative sources.");
		}

		if (SkillState.PreviewHeadlines.Num() == 0)
		{
			AddPreviewHeadline(SkillState.PreviewHeadlines, SkillState.DisplayLabel);
		}

		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/recall-memory")),
		FString(TEXT("skill/generate-compact-view"))
	})
	{
		const FHyperTwistSkillRecallCompactViewSkill SkillState =
			BuildRecallCompactSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillRecallCompactViewState();
		}

		RecallCompactViewState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillRecallCompactViewSkill& SkillState :
		RecallCompactViewState.Skills)
	{
		RecallCompactViewState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		RecallCompactViewState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		RecallCompactViewState.RecallMemorySkillCount +=
			SkillState.SkillId == TEXT("skill/recall-memory") ? 1 : 0;
		RecallCompactViewState.GenerateCompactViewSkillCount +=
			SkillState.SkillId == TEXT("skill/generate-compact-view") ? 1 : 0;
		RecallCompactViewState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;

		if (SkillState.bLiveSkill)
		{
			RecallCompactViewState.bEveryLiveSkillReadsAuthoritativeStores &=
				SkillState.bReadsAuthoritativeStores;
			RecallCompactViewState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}

		if (SkillState.SkillId == TEXT("skill/generate-compact-view"))
		{
			RecallCompactViewState.bCompactViewsRemainOptionalAndLinkedToAuthoritativeSources =
				SkillState.bOptionalCompactView && SkillState.bLinkedToAuthoritativeSources;
		}
	}

	RecallCompactViewState.SkillCount = RecallCompactViewState.Skills.Num();

	return RecallCompactViewState;
}

FHyperTwistSkillWorkflowMemoryCaptureState
UHyperTwistSkillCoreLibrary::DeriveSkillWorkflowMemoryCaptureState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistMemoryLedgerState& LedgerState,
	const FHyperTwistMemoryChronicleContinuityState& ChronicleContinuityState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !LedgerState.IsStructurallyValid()
		|| !ChronicleContinuityState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillWorkflowMemoryCaptureState();
	}

	FHyperTwistSkillWorkflowMemoryCaptureState WorkflowCaptureState;
	WorkflowCaptureState.RegistryId = RegistryState.RegistryId;
	WorkflowCaptureState.ManifestVersion = TEXT("s3c-v1");
	WorkflowCaptureState.ReferenceUtc = TEXT("2026-05-29T07:30:00Z");
	WorkflowCaptureState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	WorkflowCaptureState.TemplateVersion = TEXT("skill-workflow-memory-capture-v1");
	WorkflowCaptureState.bEveryLiveSkillReadsAuthoritativeStores = true;
	WorkflowCaptureState.bEverySkillPreservesOptionalAssistiveOffState = true;
	WorkflowCaptureState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	WorkflowCaptureState.bWorkflowMemoryRemainsSeparateFromUserAuthoredNotes = true;
	WorkflowCaptureState.bWorkflowMemoryDoesNotCollapseIntoOpaqueSummaries = true;
	WorkflowCaptureState.Summary =
		TEXT("First-party workflow-memory capture skill layer over authoritative procedural and continuity seams.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto AddUniqueEntityId = [](
		TArray<FString>& EntityIds,
		const FString& EntityId
	)
	{
		if (!EntityId.IsEmpty())
		{
			EntityIds.AddUnique(EntityId);
		}
	};

	const bool bHasProceduralWorkflowLaneEvidence = LedgerState.LaneContracts.ContainsByPredicate(
		[](const FHyperTwistMemoryLaneContract& LaneContract)
		{
			return LaneContract.Lane == EHyperTwistMemoryLane::ProceduralWorkflow
				&& LaneContract.AuthorityKind == EHyperTwistMemoryAuthorityKind::Authoritative
				&& LaneContract.bFirstPartyOwned
				&& LaneContract.bCurrentEvidencePresent;
		}
	);

	auto BuildWorkflowSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillWorkflowMemoryCaptureSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsWorkflowMemoryCaptureSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId))
		{
			return FHyperTwistSkillWorkflowMemoryCaptureSkill();
		}

		FHyperTwistSkillWorkflowMemoryCaptureSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bAvoidsUserAuthoredNoteCapture = true;
		SkillState.bAvoidsOpaqueSummaryCollapse = true;

		TArray<FString> LinkedWorkflowEntityIds;

		if (SkillId == TEXT("skill/capture-session-template"))
		{
			SkillState.InputStateKinds = {
				TEXT("state/memory-ledger"),
				TEXT("state/memory-entity-descriptor"),
				TEXT("state/memory-procedural-workflow-lane")
			};

			for (const FHyperTwistMemoryEntityDescriptor& Entity : LedgerState.Entities)
			{
				if (Entity.Lane != EHyperTwistMemoryLane::ProceduralWorkflow
					|| Entity.AuthorityKind != EHyperTwistMemoryAuthorityKind::Authoritative)
				{
					continue;
				}

				if (Entity.RecordKind == TEXT("training-session-template")
					|| Entity.RecordKind == TEXT("method-drill-favorite")
					|| Entity.RecordKind == TEXT("method-drill-batch"))
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, Entity.DisplayLabel);
					AddUniqueEntityId(LinkedWorkflowEntityIds, Entity.EntityId);
				}
			}

			SkillState.AvailableItemCount = LinkedWorkflowEntityIds.Num();
			SkillState.LinkedWorkflowEntityCount = LinkedWorkflowEntityIds.Num();
			SkillState.BlockingItemCount = 0;
			SkillState.bReadsAuthoritativeStores =
				bHasProceduralWorkflowLaneEvidence && LinkedWorkflowEntityIds.Num() > 0;
			SkillState.bAvailableNow = LinkedWorkflowEntityIds.Num() > 0;
			SkillState.Summary =
				TEXT("Live first-party workflow capture skill over authoritative session-template and drill-workflow entities.");
		}
		else if (SkillId == TEXT("skill/capture-follow-up-routine"))
		{
			SkillState.InputStateKinds = {
				TEXT("state/memory-ledger"),
				TEXT("state/memory-entity-descriptor"),
				TEXT("state/memory-chronicle-continuity"),
				TEXT("state/memory-session-group"),
				TEXT("state/memory-resume-pack"),
				TEXT("state/memory-continuity-guard")
			};

			int32 RelevantResumePackCount = 0;
			int32 RelevantOpenGroupCount = 0;
			int32 RelevantBlockingGuardCount = 0;

			for (const FHyperTwistMemoryEntityDescriptor& Entity : LedgerState.Entities)
			{
				if (Entity.Lane != EHyperTwistMemoryLane::ProceduralWorkflow
					|| Entity.AuthorityKind != EHyperTwistMemoryAuthorityKind::Authoritative)
				{
					continue;
				}

				if (Entity.RecordKind == TEXT("training-review-plan")
					|| Entity.RecordKind == TEXT("coach-action-plan")
					|| Entity.RecordKind == TEXT("coach-session-queue"))
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, Entity.DisplayLabel);
					AddUniqueEntityId(LinkedWorkflowEntityIds, Entity.EntityId);
				}
			}

			for (const FHyperTwistMemorySessionGroup& SessionGroup :
				ChronicleContinuityState.SessionGroups)
			{
				if (SessionGroup.GroupKind == TEXT("review-plan")
					|| SessionGroup.GroupKind == TEXT("coach-session-queue"))
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, SessionGroup.Headline);
					RelevantOpenGroupCount += SessionGroup.bCompleted ? 0 : 1;
				}
			}

			for (const FHyperTwistMemoryResumePack& ResumePack :
				ChronicleContinuityState.ResumePacks)
			{
				if (ResumePack.PackKind == TEXT("review-plan-resume")
					|| ResumePack.PackKind == TEXT("coach-session-queue-resume"))
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, ResumePack.Headline);
					RelevantResumePackCount += 1;
				}
			}

			for (const FHyperTwistMemoryContinuityGuard& ContinuityGuard :
				ChronicleContinuityState.ContinuityGuards)
			{
				if (ContinuityGuard.GuardKind == TEXT("coach-session-queue"))
				{
					AddPreviewHeadline(SkillState.PreviewHeadlines, ContinuityGuard.Headline);
					RelevantBlockingGuardCount +=
						ContinuityGuard.Severity ==
								EHyperTwistMemoryContinuityGuardSeverity::Blocking
							? 1
							: 0;
				}
			}

			SkillState.AvailableItemCount =
				LinkedWorkflowEntityIds.Num() + RelevantResumePackCount;
			SkillState.LinkedWorkflowEntityCount = LinkedWorkflowEntityIds.Num();
			SkillState.BlockingItemCount = RelevantBlockingGuardCount;
			SkillState.bReadsAuthoritativeStores =
				bHasProceduralWorkflowLaneEvidence
				&& LinkedWorkflowEntityIds.Num() > 0
				&& (RelevantResumePackCount > 0 || RelevantOpenGroupCount > 0);
			SkillState.bAvailableNow = SkillState.AvailableItemCount > 0;
			SkillState.Summary =
				TEXT("Live first-party workflow capture skill over authoritative review-plan, follow-up, and queue continuity entities.");
		}

		if (SkillState.PreviewHeadlines.Num() == 0)
		{
			AddPreviewHeadline(SkillState.PreviewHeadlines, SkillState.DisplayLabel);
		}

		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/capture-session-template")),
		FString(TEXT("skill/capture-follow-up-routine"))
	})
	{
		const FHyperTwistSkillWorkflowMemoryCaptureSkill SkillState =
			BuildWorkflowSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillWorkflowMemoryCaptureState();
		}

		WorkflowCaptureState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillWorkflowMemoryCaptureSkill& SkillState :
		WorkflowCaptureState.Skills)
	{
		WorkflowCaptureState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		WorkflowCaptureState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		WorkflowCaptureState.CaptureSessionTemplateSkillCount +=
			SkillState.SkillId == TEXT("skill/capture-session-template") ? 1 : 0;
		WorkflowCaptureState.CaptureFollowUpRoutineSkillCount +=
			SkillState.SkillId == TEXT("skill/capture-follow-up-routine") ? 1 : 0;
		WorkflowCaptureState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		WorkflowCaptureState.bWorkflowMemoryRemainsSeparateFromUserAuthoredNotes &=
			SkillState.bAvoidsUserAuthoredNoteCapture;
		WorkflowCaptureState.bWorkflowMemoryDoesNotCollapseIntoOpaqueSummaries &=
			SkillState.bAvoidsOpaqueSummaryCollapse;

		if (SkillState.bLiveSkill)
		{
			WorkflowCaptureState.bEveryLiveSkillReadsAuthoritativeStores &=
				SkillState.bReadsAuthoritativeStores;
			WorkflowCaptureState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	WorkflowCaptureState.SkillCount = WorkflowCaptureState.Skills.Num();

	return WorkflowCaptureState;
}

FHyperTwistSkillExtractionState
UHyperTwistSkillCoreLibrary::DeriveSkillExtractionState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillExtractionState();
	}

	FHyperTwistSkillExtractionState ExtractionState;
	ExtractionState.RegistryId = RegistryState.RegistryId;
	ExtractionState.ManifestVersion = TEXT("s4a-v1");
	ExtractionState.ReferenceUtc = TEXT("2026-05-29T09:55:00Z");
	ExtractionState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	ExtractionState.TemplateVersion = TEXT("skill-extraction-v1");
	ExtractionState.bEveryLiveSkillReadsAuthoritativeSourceSurfaces = true;
	ExtractionState.bEverySkillPreservesOptionalAssistiveOffState = true;
	ExtractionState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	ExtractionState.bStructuredExtractionRemainsBounded = true;
	ExtractionState.bNoBrowserDiagnosticsWidening = true;
	ExtractionState.bNoDesignTranslationWidening = true;
	ExtractionState.Summary =
		TEXT("First-party extraction skill layer over authoritative docs and design-spec source surfaces.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto BuildExtractionSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillExtractionSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsExtractionSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId))
		{
			return FHyperTwistSkillExtractionSkill();
		}

		FHyperTwistSkillExtractionSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeSourceSurfaces = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bStructuredExtractionOnly = true;
		SkillState.bAvoidsBrowserDiagnosticsWidening = true;
		SkillState.bAvoidsDesignTranslationWidening = true;

		if (SkillId == TEXT("skill/extract-docs"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/feature-registry"),
				TEXT("source-surface/architecture-manual"),
				TEXT("source-surface/roadmap"),
				TEXT("source-surface/skills-manual"),
				TEXT("source-surface/provenance-and-trust-model"),
				TEXT("source-surface/implementation-phase-kickoff")
			};
			SkillState.StructuredFieldIds = {
				TEXT("field/docs-source-title"),
				TEXT("field/docs-owner-lane"),
				TEXT("field/docs-owner-feature"),
				TEXT("field/docs-bounded-status"),
				TEXT("field/docs-provenance-note"),
				TEXT("field/docs-next-clean-step")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Feature registry extraction")
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Architecture manual extraction")
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Roadmap and provenance extraction")
			);
			SkillState.bExtractsDocumentation = true;
			SkillState.bExtractsDesignSpecs = false;
			SkillState.Summary =
				TEXT("Live first-party structured docs-extraction skill over authoritative HyperTwist canon surfaces.");
		}
		else if (SkillId == TEXT("skill/extract-design-spec"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/skillization-doctrine"),
				TEXT("source-surface/architecture-manual"),
				TEXT("source-surface/implementation-packets"),
				TEXT("source-surface/feature-registry"),
				TEXT("source-surface/roadmap")
			};
			SkillState.StructuredFieldIds = {
				TEXT("field/design-target-feature"),
				TEXT("field/design-owner-lane"),
				TEXT("field/design-command-surface"),
				TEXT("field/design-output-artifact"),
				TEXT("field/design-bounded-non-goals"),
				TEXT("field/design-provenance-guard")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Skill packet boundary extraction")
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Architecture seam extraction")
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Bounded design-spec extraction")
			);
			SkillState.bExtractsDocumentation = false;
			SkillState.bExtractsDesignSpecs = true;
			SkillState.Summary =
				TEXT("Live first-party structured design-spec extraction skill over authoritative HyperTwist design and packet surfaces.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.StructuredFieldCount = SkillState.StructuredFieldIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/extract-docs")),
		FString(TEXT("skill/extract-design-spec"))
	})
	{
		const FHyperTwistSkillExtractionSkill SkillState =
			BuildExtractionSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillExtractionState();
		}

		ExtractionState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillExtractionSkill& SkillState : ExtractionState.Skills)
	{
		ExtractionState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		ExtractionState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		ExtractionState.DocsExtractionSkillCount +=
			SkillState.bExtractsDocumentation ? 1 : 0;
		ExtractionState.DesignSpecExtractionSkillCount +=
			SkillState.bExtractsDesignSpecs ? 1 : 0;
		ExtractionState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		ExtractionState.bStructuredExtractionRemainsBounded &=
			SkillState.bStructuredExtractionOnly;
		ExtractionState.bNoBrowserDiagnosticsWidening &=
			SkillState.bAvoidsBrowserDiagnosticsWidening;
		ExtractionState.bNoDesignTranslationWidening &=
			SkillState.bAvoidsDesignTranslationWidening;

		if (SkillState.bLiveSkill)
		{
			ExtractionState.bEveryLiveSkillReadsAuthoritativeSourceSurfaces &=
				SkillState.bReadsAuthoritativeSourceSurfaces;
			ExtractionState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	ExtractionState.SkillCount = ExtractionState.Skills.Num();

	return ExtractionState;
}

FHyperTwistSkillBrowserDiagnosticsState
UHyperTwistSkillCoreLibrary::DeriveSkillBrowserDiagnosticsState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillExtractionState& ExtractionState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !ExtractionState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != ExtractionState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != ExtractionState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillBrowserDiagnosticsState();
	}

	FHyperTwistSkillBrowserDiagnosticsState DiagnosticsState;
	DiagnosticsState.RegistryId = RegistryState.RegistryId;
	DiagnosticsState.ManifestVersion = TEXT("s4b-v1");
	DiagnosticsState.ReferenceUtc = TEXT("2026-05-29T10:40:00Z");
	DiagnosticsState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	DiagnosticsState.TemplateVersion = TEXT("skill-browser-diagnostics-v1");
	DiagnosticsState.bEveryLiveSkillReadsAuthoritativeBrowserAndDocSurfaces = true;
	DiagnosticsState.bEverySkillPreservesOptionalAssistiveOffState = true;
	DiagnosticsState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	DiagnosticsState.bDiagnosticsRemainBounded = true;
	DiagnosticsState.bEverySkillRequiresExtractionSubstrate = true;
	DiagnosticsState.bNoDesignTranslationWidening = true;
	DiagnosticsState.Summary =
		TEXT("First-party browser diagnostics skill layer above the landed docs/design extraction seam.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto ExtractionSkillExists = [&ExtractionState](const FString& SkillId)
	{
		for (const FHyperTwistSkillExtractionSkill& SkillState : ExtractionState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildBrowserDiagnosticSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillBrowserDiagnosticSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsBrowserDiagnosticsSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !ExtractionSkillExists(TEXT("skill/extract-docs"))
			|| !ExtractionSkillExists(TEXT("skill/extract-design-spec")))
		{
			return FHyperTwistSkillBrowserDiagnosticSkill();
		}

		FHyperTwistSkillBrowserDiagnosticSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredExtractionSkillIds = {
			TEXT("skill/extract-docs"),
			TEXT("skill/extract-design-spec")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeBrowserAndDocSurfaces = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToDiagnosticsOnly = true;
		SkillState.bRequiresExtractionSubstrate = true;
		SkillState.bAvoidsDesignTranslationWidening = true;

		if (SkillId == TEXT("skill/capture-browser-trace"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/browser-diagnostics-packet"),
				TEXT("source-surface/architecture-manual"),
				TEXT("source-surface/skills-manual"),
				TEXT("source-surface/provenance-and-trust-model"),
				TEXT("source-surface/extraction-state")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Browser trace readiness"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Trace-capture prerequisites"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded diagnostics trace output"));
			SkillState.bCapturesBrowserTrace = true;
			SkillState.bPerformsBrowserApiDiscovery = false;
			SkillState.Summary =
				TEXT("Live first-party bounded browser trace-capture skill above the landed extraction seam.");
		}
		else if (SkillId == TEXT("skill/discover-browser-api"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/browser-api-contracts"),
				TEXT("source-surface/browser-diagnostics-packet"),
				TEXT("source-surface/skills-manual"),
				TEXT("source-surface/provenance-and-trust-model"),
				TEXT("source-surface/extraction-state")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Browser/API discovery readiness"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Diagnostic API surface extraction"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded browser/API discovery output"));
			SkillState.bCapturesBrowserTrace = false;
			SkillState.bPerformsBrowserApiDiscovery = true;
			SkillState.Summary =
				TEXT("Live first-party bounded browser/API discovery skill above the landed extraction seam.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredExtractionSkillCount = SkillState.RequiredExtractionSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/capture-browser-trace")),
		FString(TEXT("skill/discover-browser-api"))
	})
	{
		const FHyperTwistSkillBrowserDiagnosticSkill SkillState =
			BuildBrowserDiagnosticSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillBrowserDiagnosticsState();
		}

		DiagnosticsState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillBrowserDiagnosticSkill& SkillState : DiagnosticsState.Skills)
	{
		DiagnosticsState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		DiagnosticsState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		DiagnosticsState.BrowserTraceCaptureSkillCount += SkillState.bCapturesBrowserTrace ? 1 : 0;
		DiagnosticsState.BrowserApiDiscoverySkillCount +=
			SkillState.bPerformsBrowserApiDiscovery ? 1 : 0;
		DiagnosticsState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		DiagnosticsState.bDiagnosticsRemainBounded &= SkillState.bBoundedToDiagnosticsOnly;
		DiagnosticsState.bEverySkillRequiresExtractionSubstrate &=
			SkillState.bRequiresExtractionSubstrate;
		DiagnosticsState.bNoDesignTranslationWidening &=
			SkillState.bAvoidsDesignTranslationWidening;

		if (SkillState.bLiveSkill)
		{
			DiagnosticsState.bEveryLiveSkillReadsAuthoritativeBrowserAndDocSurfaces &=
				SkillState.bReadsAuthoritativeBrowserAndDocSurfaces;
			DiagnosticsState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	DiagnosticsState.SkillCount = DiagnosticsState.Skills.Num();

	return DiagnosticsState;
}

FHyperTwistSkillDesignShellState
UHyperTwistSkillCoreLibrary::DeriveSkillDesignShellState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillExtractionState& ExtractionState,
	const FHyperTwistSkillBrowserDiagnosticsState& BrowserDiagnosticsState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !ExtractionState.IsStructurallyValid()
		|| !BrowserDiagnosticsState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != ExtractionState.RegistryId
		|| RegistryState.RegistryId != BrowserDiagnosticsState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != ExtractionState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != BrowserDiagnosticsState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillDesignShellState();
	}

	FHyperTwistSkillDesignShellState DesignShellState;
	DesignShellState.RegistryId = RegistryState.RegistryId;
	DesignShellState.ManifestVersion = TEXT("s4c-v1");
	DesignShellState.ReferenceUtc = TEXT("2026-05-29T12:20:00Z");
	DesignShellState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	DesignShellState.TemplateVersion = TEXT("skill-design-shell-v1");
	DesignShellState.bEveryLiveSkillReadsAuthoritativeDocsBrowserAndDesignSurfaces = true;
	DesignShellState.bEverySkillPreservesOptionalAssistiveOffState = true;
	DesignShellState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	DesignShellState.bDesignShellTranslationRemainsBounded = true;
	DesignShellState.bEverySkillRequiresExtractionSubstrate = true;
	DesignShellState.bEverySkillRequiresBrowserDiagnosticsSubstrate = true;
	DesignShellState.bNoGenericBrowserShellWidening = true;
	DesignShellState.Summary =
		TEXT("First-party bounded design-shell translation skill layer above the landed extraction and browser diagnostics seams.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto ExtractionSkillExists = [&ExtractionState](const FString& SkillId)
	{
		for (const FHyperTwistSkillExtractionSkill& SkillState : ExtractionState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BrowserDiagnosticsSkillExists = [&BrowserDiagnosticsState](const FString& SkillId)
	{
		for (const FHyperTwistSkillBrowserDiagnosticSkill& SkillState : BrowserDiagnosticsState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildDesignShellSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillDesignShellSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsDesignShellSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !ExtractionSkillExists(TEXT("skill/extract-docs"))
			|| !ExtractionSkillExists(TEXT("skill/extract-design-spec"))
			|| !BrowserDiagnosticsSkillExists(TEXT("skill/capture-browser-trace"))
			|| !BrowserDiagnosticsSkillExists(TEXT("skill/discover-browser-api")))
		{
			return FHyperTwistSkillDesignShellSkill();
		}

		FHyperTwistSkillDesignShellSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredExtractionSkillIds = {
			TEXT("skill/extract-docs"),
			TEXT("skill/extract-design-spec")
		};
		SkillState.RequiredBrowserDiagnosticSkillIds = {
			TEXT("skill/capture-browser-trace"),
			TEXT("skill/discover-browser-api")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeDocsBrowserAndDesignSurfaces = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToDesignShellOnly = true;
		SkillState.bRequiresExtractionSubstrate = true;
		SkillState.bRequiresBrowserDiagnosticsSubstrate = true;
		SkillState.bAvoidsGenericBrowserShellWidening = true;

		if (SkillId == TEXT("skill/translate-design-shell"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/design-spec-extraction"),
				TEXT("source-surface/browser-trace-diagnostics"),
				TEXT("source-surface/browser-api-discovery"),
				TEXT("source-surface/architecture-manual"),
				TEXT("source-surface/design-shell-packet")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Native shell translation readiness"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded layout and panel translation"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Design-shell translation output"));
			SkillState.bTranslatesDesignShell = true;
			SkillState.bTranslatesInteractionContract = false;
			SkillState.Summary =
				TEXT("Live first-party bounded design-shell translation skill above the extraction and browser diagnostics seams.");
		}
		else if (SkillId == TEXT("skill/translate-design-interaction"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/design-spec-extraction"),
				TEXT("source-surface/browser-api-discovery"),
				TEXT("source-surface/provenance-and-trust-model"),
				TEXT("source-surface/skills-manual"),
				TEXT("source-surface/design-shell-packet")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Interaction translation readiness"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded interaction-contract translation"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Native interaction translation output"));
			SkillState.bTranslatesDesignShell = false;
			SkillState.bTranslatesInteractionContract = true;
			SkillState.Summary =
				TEXT("Live first-party bounded design-interaction translation skill above the extraction and browser diagnostics seams.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredExtractionSkillCount = SkillState.RequiredExtractionSkillIds.Num();
		SkillState.RequiredBrowserDiagnosticSkillCount =
			SkillState.RequiredBrowserDiagnosticSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/translate-design-shell")),
		FString(TEXT("skill/translate-design-interaction"))
	})
	{
		const FHyperTwistSkillDesignShellSkill SkillState =
			BuildDesignShellSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillDesignShellState();
		}

		DesignShellState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillDesignShellSkill& SkillState : DesignShellState.Skills)
	{
		DesignShellState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		DesignShellState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		DesignShellState.DesignShellTranslationSkillCount +=
			SkillState.bTranslatesDesignShell ? 1 : 0;
		DesignShellState.InteractionContractTranslationSkillCount +=
			SkillState.bTranslatesInteractionContract ? 1 : 0;
		DesignShellState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		DesignShellState.bDesignShellTranslationRemainsBounded &=
			SkillState.bBoundedToDesignShellOnly;
		DesignShellState.bEverySkillRequiresExtractionSubstrate &=
			SkillState.bRequiresExtractionSubstrate;
		DesignShellState.bEverySkillRequiresBrowserDiagnosticsSubstrate &=
			SkillState.bRequiresBrowserDiagnosticsSubstrate;
		DesignShellState.bNoGenericBrowserShellWidening &=
			SkillState.bAvoidsGenericBrowserShellWidening;

		if (SkillState.bLiveSkill)
		{
			DesignShellState.bEveryLiveSkillReadsAuthoritativeDocsBrowserAndDesignSurfaces &=
				SkillState.bReadsAuthoritativeDocsBrowserAndDesignSurfaces;
			DesignShellState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	DesignShellState.SkillCount = DesignShellState.Skills.Num();

	return DesignShellState;
}

FHyperTwistSkillWorkflowReviewState
UHyperTwistSkillCoreLibrary::DeriveSkillWorkflowReviewState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillExtractionState& ExtractionState,
	const FHyperTwistSkillWorkflowMemoryCaptureState& WorkflowMemoryCaptureState,
	const FHyperTwistSkillDesignShellState& DesignShellState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !ExtractionState.IsStructurallyValid()
		|| !WorkflowMemoryCaptureState.IsStructurallyValid()
		|| !DesignShellState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != ExtractionState.RegistryId
		|| RegistryState.RegistryId != WorkflowMemoryCaptureState.RegistryId
		|| RegistryState.RegistryId != DesignShellState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != ExtractionState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != WorkflowMemoryCaptureState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != DesignShellState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillWorkflowReviewState();
	}

	FHyperTwistSkillWorkflowReviewState WorkflowReviewState;
	WorkflowReviewState.RegistryId = RegistryState.RegistryId;
	WorkflowReviewState.ManifestVersion = TEXT("s5a-v1");
	WorkflowReviewState.ReferenceUtc = TEXT("2026-05-31T01:45:00Z");
	WorkflowReviewState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	WorkflowReviewState.TemplateVersion = TEXT("skill-workflow-review-v1");
	WorkflowReviewState.bEveryLiveSkillReadsAuthoritativeWorkflowAndReviewSurfaces = true;
	WorkflowReviewState.bEverySkillPreservesOptionalAssistiveOffState = true;
	WorkflowReviewState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	WorkflowReviewState.bWorkflowReviewRemainsBounded = true;
	WorkflowReviewState.bEverySkillRequiresExtractionSubstrate = true;
	WorkflowReviewState.bEverySkillRequiresWorkflowMemorySubstrate = true;
	WorkflowReviewState.bEverySkillRequiresDesignShellSubstrate = true;
	WorkflowReviewState.bNoImplementationReviewDelegationWidening = true;
	WorkflowReviewState.bNoPlanSynthesisWidening = true;
	WorkflowReviewState.Summary =
		TEXT("First-party bounded workflow/review wrapper layer above the landed extraction, workflow-memory, and design-shell seams.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto ExtractionSkillExists = [&ExtractionState](const FString& SkillId)
	{
		for (const FHyperTwistSkillExtractionSkill& SkillState : ExtractionState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto WorkflowMemorySkillExists = [&WorkflowMemoryCaptureState](const FString& SkillId)
	{
		for (const FHyperTwistSkillWorkflowMemoryCaptureSkill& SkillState :
			WorkflowMemoryCaptureState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto DesignShellSkillExists = [&DesignShellState](const FString& SkillId)
	{
		for (const FHyperTwistSkillDesignShellSkill& SkillState : DesignShellState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildWorkflowReviewSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillWorkflowReviewSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsWorkflowReviewSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !ExtractionSkillExists(TEXT("skill/extract-docs"))
			|| !ExtractionSkillExists(TEXT("skill/extract-design-spec"))
			|| !WorkflowMemorySkillExists(TEXT("skill/capture-session-template"))
			|| !WorkflowMemorySkillExists(TEXT("skill/capture-follow-up-routine"))
			|| !DesignShellSkillExists(TEXT("skill/translate-design-shell"))
			|| !DesignShellSkillExists(TEXT("skill/translate-design-interaction")))
		{
			return FHyperTwistSkillWorkflowReviewSkill();
		}

		FHyperTwistSkillWorkflowReviewSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredExtractionSkillIds = {
			TEXT("skill/extract-docs"),
			TEXT("skill/extract-design-spec")
		};
		SkillState.RequiredWorkflowMemorySkillIds = {
			TEXT("skill/capture-session-template"),
			TEXT("skill/capture-follow-up-routine")
		};
		SkillState.RequiredDesignShellSkillIds = {
			TEXT("skill/translate-design-shell"),
			TEXT("skill/translate-design-interaction")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeWorkflowAndReviewSurfaces = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToWorkflowReviewOnly = true;
		SkillState.bRequiresExtractionSubstrate = true;
		SkillState.bRequiresWorkflowMemorySubstrate = true;
		SkillState.bRequiresDesignShellSubstrate = true;
		SkillState.bAvoidsImplementationReviewDelegationWidening = true;
		SkillState.bAvoidsPlanSynthesisWidening = true;

		if (SkillId == TEXT("skill/review-proposal"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/docs-extraction"),
				TEXT("source-surface/design-spec-extraction"),
				TEXT("source-surface/workflow-session-template-capture"),
				TEXT("source-surface/design-shell-translation"),
				TEXT("source-surface/phase-s5a-packet")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Proposal review readiness"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded proposal-review framing"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Proposal review output"));
			SkillState.bReviewsProposal = true;
			SkillState.bReviewsDiff = false;
			SkillState.bWrapsBoundedWorkflow = false;
			SkillState.Summary =
				TEXT("Live first-party bounded proposal-review wrapper above the extraction, workflow-memory, and design-shell seams.");
		}
		else if (SkillId == TEXT("skill/review-diff"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/docs-extraction"),
				TEXT("source-surface/design-spec-extraction"),
				TEXT("source-surface/workflow-follow-up-capture"),
				TEXT("source-surface/design-interaction-translation"),
				TEXT("source-surface/phase-s5a-packet")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Diff review readiness"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded diff-review framing"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Diff review output"));
			SkillState.bReviewsProposal = false;
			SkillState.bReviewsDiff = true;
			SkillState.bWrapsBoundedWorkflow = false;
			SkillState.Summary =
				TEXT("Live first-party bounded diff-review wrapper above the extraction, workflow-memory, and design-shell seams.");
		}
		else if (SkillId == TEXT("skill/wrap-bounded-workflow"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/docs-extraction"),
				TEXT("source-surface/workflow-follow-up-capture"),
				TEXT("source-surface/workflow-session-template-capture"),
				TEXT("source-surface/design-shell-translation"),
				TEXT("source-surface/phase-s5a-packet")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded workflow wrapper readiness"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Review-to-workflow wrapper framing"));
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Bounded workflow wrapper output"));
			SkillState.bReviewsProposal = false;
			SkillState.bReviewsDiff = false;
			SkillState.bWrapsBoundedWorkflow = true;
			SkillState.Summary =
				TEXT("Live first-party bounded workflow-wrapper skill above the extraction, workflow-memory, and design-shell seams.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredExtractionSkillCount = SkillState.RequiredExtractionSkillIds.Num();
		SkillState.RequiredWorkflowMemorySkillCount =
			SkillState.RequiredWorkflowMemorySkillIds.Num();
		SkillState.RequiredDesignShellSkillCount =
			SkillState.RequiredDesignShellSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/review-proposal")),
		FString(TEXT("skill/review-diff")),
		FString(TEXT("skill/wrap-bounded-workflow"))
	})
	{
		const FHyperTwistSkillWorkflowReviewSkill SkillState =
			BuildWorkflowReviewSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillWorkflowReviewState();
		}

		WorkflowReviewState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillWorkflowReviewSkill& SkillState :
		WorkflowReviewState.Skills)
	{
		WorkflowReviewState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		WorkflowReviewState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		WorkflowReviewState.ProposalReviewSkillCount +=
			SkillState.bReviewsProposal ? 1 : 0;
		WorkflowReviewState.DiffReviewSkillCount +=
			SkillState.bReviewsDiff ? 1 : 0;
		WorkflowReviewState.BoundedWorkflowWrapperSkillCount +=
			SkillState.bWrapsBoundedWorkflow ? 1 : 0;
		WorkflowReviewState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		WorkflowReviewState.bWorkflowReviewRemainsBounded &=
			SkillState.bBoundedToWorkflowReviewOnly;
		WorkflowReviewState.bEverySkillRequiresExtractionSubstrate &=
			SkillState.bRequiresExtractionSubstrate;
		WorkflowReviewState.bEverySkillRequiresWorkflowMemorySubstrate &=
			SkillState.bRequiresWorkflowMemorySubstrate;
		WorkflowReviewState.bEverySkillRequiresDesignShellSubstrate &=
			SkillState.bRequiresDesignShellSubstrate;
		WorkflowReviewState.bNoImplementationReviewDelegationWidening &=
			SkillState.bAvoidsImplementationReviewDelegationWidening;
		WorkflowReviewState.bNoPlanSynthesisWidening &=
			SkillState.bAvoidsPlanSynthesisWidening;

		if (SkillState.bLiveSkill)
		{
			WorkflowReviewState.bEveryLiveSkillReadsAuthoritativeWorkflowAndReviewSurfaces &=
				SkillState.bReadsAuthoritativeWorkflowAndReviewSurfaces;
			WorkflowReviewState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	WorkflowReviewState.SkillCount = WorkflowReviewState.Skills.Num();

	return WorkflowReviewState;
}

FHyperTwistSkillImplementationDelegationState
UHyperTwistSkillCoreLibrary::DeriveSkillImplementationDelegationState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillWorkflowReviewState& WorkflowReviewState,
	const FHyperTwistSkillDesignShellState& DesignShellState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !WorkflowReviewState.IsStructurallyValid()
		|| !DesignShellState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != WorkflowReviewState.RegistryId
		|| RegistryState.RegistryId != DesignShellState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != WorkflowReviewState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != DesignShellState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillImplementationDelegationState();
	}

	FHyperTwistSkillImplementationDelegationState ImplementationDelegationState;
	ImplementationDelegationState.RegistryId = RegistryState.RegistryId;
	ImplementationDelegationState.ManifestVersion = TEXT("s5b-v1");
	ImplementationDelegationState.ReferenceUtc = TEXT("2026-05-31T02:35:00Z");
	ImplementationDelegationState.CommandSurfaceRootId =
		RegistryState.CommandSurfaceRootId;
	ImplementationDelegationState.TemplateVersion =
		TEXT("skill-implementation-delegation-v1");
	ImplementationDelegationState.bEverySpecUsesFirstPartyTerms = true;
	ImplementationDelegationState.bEverySpecPreservesOptionalAssistiveOffState = true;
	ImplementationDelegationState.bEverySpecRequiresProvenanceLedger = true;
	ImplementationDelegationState.bEverySpecRemainsBounded = true;
	ImplementationDelegationState.bEverySpecRequiresWorkflowReviewSubstrate = true;
	ImplementationDelegationState.bEverySpecRequiresDesignShellSubstrate = true;
	ImplementationDelegationState.bNoPlanSynthesisWidening = true;
	ImplementationDelegationState.bNoAutonomousExecutionClaims = true;
	ImplementationDelegationState.bEverySpecReadyForFutureWrapperBinding = true;
	ImplementationDelegationState.Summary =
		TEXT("First-party bounded implementation-review and delegation spec layer above the landed workflow/review and design-shell seams.");

	auto WorkflowReviewSkillExists = [&WorkflowReviewState](const FString& SkillId)
	{
		for (const FHyperTwistSkillWorkflowReviewSkill& SkillState :
			WorkflowReviewState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto DesignShellSkillExists = [&DesignShellState](const FString& SkillId)
	{
		for (const FHyperTwistSkillDesignShellSkill& SkillState :
			DesignShellState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildImplementationDelegationSpec = [&](
		const FString& SkillId
	) -> FHyperTwistSkillImplementationDelegationSpec
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsImplementationDelegationSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !WorkflowReviewSkillExists(TEXT("skill/review-proposal"))
			|| !WorkflowReviewSkillExists(TEXT("skill/review-diff"))
			|| !WorkflowReviewSkillExists(TEXT("skill/wrap-bounded-workflow"))
			|| !DesignShellSkillExists(TEXT("skill/translate-design-shell"))
			|| !DesignShellSkillExists(TEXT("skill/translate-design-interaction")))
		{
			return FHyperTwistSkillImplementationDelegationSpec();
		}

		FHyperTwistSkillImplementationDelegationSpec Spec;
		Spec.SpecId = TEXT("implementation-delegation-spec/")
			+ MakeInvocationSlug(Entry->SkillId);
		Spec.SkillId = Entry->SkillId;
		Spec.DisplayLabel = Entry->DisplayLabel + TEXT(" Spec");
		Spec.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		Spec.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		Spec.OwnerLaneId = Entry->OwnerLaneId;
		Spec.OwnerFeatureId = Entry->OwnerFeatureId;
		Spec.RequiredWorkflowReviewSkillIds = {
			TEXT("skill/review-proposal"),
			TEXT("skill/review-diff"),
			TEXT("skill/wrap-bounded-workflow")
		};
		Spec.RequiredDesignShellSkillIds = {
			TEXT("skill/translate-design-shell"),
			TEXT("skill/translate-design-interaction")
		};
		Spec.bUsesFirstPartyTermsOnly = true;
		Spec.bPreservesOptionalAssistiveOffState = ControlEntry->bInertWhenDisabled;
		Spec.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		Spec.bRequiresProvenanceLedger = true;
		Spec.bBoundedToImplementationReviewAndDelegationOnly = true;
		Spec.bAvoidsPlanSynthesisWidening = true;
		Spec.bAvoidsAutonomousExecutionClaims = true;
		Spec.bReadyForFutureWrapperBinding = true;

		if (SkillId == TEXT("skill/review-implementation"))
		{
			Spec.InputArtifactKinds = {
				TEXT("artifact/proposal-review-brief"),
				TEXT("artifact/diff-review-brief"),
				TEXT("artifact/native-design-shell-translation-brief")
			};
			Spec.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
			Spec.SpecStepIds = {
				TEXT("step/load-workflow-review-briefs"),
				TEXT("step/derive-bounded-implementation-risks"),
				TEXT("step/emit-provenance-visible-implementation-review")
			};
			Spec.SafetyRuleIds = {
				TEXT("safety/skills/first-party-terms-only"),
				TEXT("safety/skills/optional-assistive-off-state-preserved"),
				TEXT("safety/skills/derived-output-only"),
				TEXT("safety/skills/provenance-ledger-required"),
				TEXT("safety/skills/no-plan-synthesis-widening"),
				TEXT("safety/skills/no-autonomous-execution-claims")
			};
			Spec.bCoversImplementationReview = true;
			Spec.bDefinesBoundedDelegationSpec = false;
			Spec.Summary =
				TEXT("Live first-party bounded implementation-review spec above the landed workflow/review and design-shell seams.");
		}
		else if (SkillId == TEXT("skill/specify-bounded-delegation"))
		{
			Spec.InputArtifactKinds = {
				TEXT("artifact/implementation-review-brief"),
				TEXT("artifact/bounded-workflow-wrapper-brief"),
				TEXT("artifact/native-interaction-translation-brief")
			};
			Spec.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
			Spec.SpecStepIds = {
				TEXT("step/load-bounded-implementation-review"),
				TEXT("step/derive-bounded-delegation-envelope"),
				TEXT("step/emit-provenance-visible-delegation-spec")
			};
			Spec.SafetyRuleIds = {
				TEXT("safety/skills/first-party-terms-only"),
				TEXT("safety/skills/optional-assistive-off-state-preserved"),
				TEXT("safety/skills/derived-output-only"),
				TEXT("safety/skills/provenance-ledger-required"),
				TEXT("safety/skills/no-plan-synthesis-widening"),
				TEXT("safety/skills/no-autonomous-execution-claims")
			};
			Spec.bCoversImplementationReview = false;
			Spec.bDefinesBoundedDelegationSpec = true;
			Spec.Summary =
				TEXT("Live first-party bounded delegation spec above the landed workflow/review and design-shell seams.");
		}

		Spec.RequiredWorkflowReviewSkillCount =
			Spec.RequiredWorkflowReviewSkillIds.Num();
		Spec.RequiredDesignShellSkillCount =
			Spec.RequiredDesignShellSkillIds.Num();
		return Spec;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/review-implementation")),
		FString(TEXT("skill/specify-bounded-delegation"))
	})
	{
		const FHyperTwistSkillImplementationDelegationSpec Spec =
			BuildImplementationDelegationSpec(SkillId);
		if (!Spec.IsStructurallyValid())
		{
			return FHyperTwistSkillImplementationDelegationState();
		}

		ImplementationDelegationState.Specs.Add(Spec);
	}

	for (const FHyperTwistSkillImplementationDelegationSpec& Spec :
		ImplementationDelegationState.Specs)
	{
		ImplementationDelegationState.ImplementationReviewSpecCount +=
			Spec.bCoversImplementationReview ? 1 : 0;
		ImplementationDelegationState.DelegationSpecCount +=
			Spec.bDefinesBoundedDelegationSpec ? 1 : 0;
		ImplementationDelegationState.bEverySpecUsesFirstPartyTerms &=
			Spec.bUsesFirstPartyTermsOnly;
		ImplementationDelegationState.bEverySpecPreservesOptionalAssistiveOffState &=
			Spec.bPreservesOptionalAssistiveOffState;
		ImplementationDelegationState.bEverySpecRequiresProvenanceLedger &=
			Spec.bRequiresProvenanceLedger;
		ImplementationDelegationState.bEverySpecRemainsBounded &=
			Spec.bBoundedToImplementationReviewAndDelegationOnly;
		ImplementationDelegationState.bEverySpecRequiresWorkflowReviewSubstrate &=
			Spec.RequiredWorkflowReviewSkillIds.Num() > 0;
		ImplementationDelegationState.bEverySpecRequiresDesignShellSubstrate &=
			Spec.RequiredDesignShellSkillIds.Num() > 0;
		ImplementationDelegationState.bNoPlanSynthesisWidening &=
			Spec.bAvoidsPlanSynthesisWidening;
		ImplementationDelegationState.bNoAutonomousExecutionClaims &=
			Spec.bAvoidsAutonomousExecutionClaims;
		ImplementationDelegationState.bEverySpecReadyForFutureWrapperBinding &=
			Spec.bReadyForFutureWrapperBinding;
	}

	TArray<FString> SeenStepIds;
	TArray<FString> SeenSafetyRuleIds;
	for (const FHyperTwistSkillImplementationDelegationSpec& Spec :
		ImplementationDelegationState.Specs)
	{
		for (const FString& StepId : Spec.SpecStepIds)
		{
			SeenStepIds.AddUnique(StepId);
		}

		for (const FString& SafetyRuleId : Spec.SafetyRuleIds)
		{
			SeenSafetyRuleIds.AddUnique(SafetyRuleId);
		}
	}

	ImplementationDelegationState.SkillCount =
		ImplementationDelegationState.Specs.Num();
	ImplementationDelegationState.SpecCount =
		ImplementationDelegationState.Specs.Num();
	ImplementationDelegationState.StepCount = SeenStepIds.Num();
	ImplementationDelegationState.SafetyRuleCount = SeenSafetyRuleIds.Num();

	return ImplementationDelegationState;
}

FHyperTwistSkillPlanOrchestrationState
UHyperTwistSkillCoreLibrary::DeriveSkillPlanOrchestrationState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillImplementationDelegationState&
		ImplementationDelegationState,
	const FHyperTwistSkillWorkflowMemoryCaptureState&
		WorkflowMemoryCaptureState,
	const FHyperTwistSkillWorkflowReviewState& WorkflowReviewState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !ImplementationDelegationState.IsStructurallyValid()
		|| !WorkflowMemoryCaptureState.IsStructurallyValid()
		|| !WorkflowReviewState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != ImplementationDelegationState.RegistryId
		|| RegistryState.RegistryId != WorkflowMemoryCaptureState.RegistryId
		|| RegistryState.RegistryId != WorkflowReviewState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= ImplementationDelegationState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= WorkflowMemoryCaptureState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != WorkflowReviewState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillPlanOrchestrationState();
	}

	FHyperTwistSkillPlanOrchestrationState PlanOrchestrationState;
	PlanOrchestrationState.RegistryId = RegistryState.RegistryId;
	PlanOrchestrationState.ManifestVersion = TEXT("s5c-v1");
	PlanOrchestrationState.ReferenceUtc = TEXT("2026-05-31T04:20:00Z");
	PlanOrchestrationState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	PlanOrchestrationState.TemplateVersion = TEXT("skill-plan-orchestration-v1");
	PlanOrchestrationState
		.bEveryLiveSkillReadsAuthoritativeWorkflowImplementationAndMemorySurfaces =
		true;
	PlanOrchestrationState.bEverySkillPreservesOptionalAssistiveOffState = true;
	PlanOrchestrationState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	PlanOrchestrationState.bPlanOrchestrationRemainsBounded = true;
	PlanOrchestrationState.bEverySkillRequiresImplementationDelegationSubstrate =
		true;
	PlanOrchestrationState.bEverySkillRequiresWorkflowMemorySubstrate = true;
	PlanOrchestrationState.bEverySkillRequiresWorkflowReviewSubstrate = true;
	PlanOrchestrationState.bNoProviderWidening = true;
	PlanOrchestrationState.bNoDomainSkillPackWidening = true;
	PlanOrchestrationState.bNoAutonomousExecutionClaims = true;
	PlanOrchestrationState.Summary =
		TEXT("First-party bounded plan-synthesis and workflow-chaining layer above the landed implementation/delegation, workflow-memory, and workflow/review seams.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto ImplementationDelegationSkillExists = [&ImplementationDelegationState](
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillImplementationDelegationSpec& Spec :
			ImplementationDelegationState.Specs)
		{
			if (Spec.SkillId == SkillId && Spec.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto WorkflowMemorySkillExists = [&WorkflowMemoryCaptureState](
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillWorkflowMemoryCaptureSkill& SkillState :
			WorkflowMemoryCaptureState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto WorkflowReviewSkillExists = [&WorkflowReviewState](const FString& SkillId)
	{
		for (const FHyperTwistSkillWorkflowReviewSkill& SkillState :
			WorkflowReviewState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildPlanOrchestrationSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillPlanOrchestrationSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsPlanOrchestrationSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !ImplementationDelegationSkillExists(TEXT("skill/review-implementation"))
			|| !ImplementationDelegationSkillExists(
				TEXT("skill/specify-bounded-delegation"))
			|| !WorkflowMemorySkillExists(TEXT("skill/capture-session-template"))
			|| !WorkflowMemorySkillExists(TEXT("skill/capture-follow-up-routine"))
			|| !WorkflowReviewSkillExists(TEXT("skill/review-proposal"))
			|| !WorkflowReviewSkillExists(TEXT("skill/wrap-bounded-workflow")))
		{
			return FHyperTwistSkillPlanOrchestrationSkill();
		}

		FHyperTwistSkillPlanOrchestrationSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredImplementationDelegationSkillIds = {
			TEXT("skill/review-implementation"),
			TEXT("skill/specify-bounded-delegation")
		};
		SkillState.RequiredWorkflowMemorySkillIds = {
			TEXT("skill/capture-session-template"),
			TEXT("skill/capture-follow-up-routine")
		};
		SkillState.RequiredWorkflowReviewSkillIds = {
			TEXT("skill/review-proposal"),
			TEXT("skill/wrap-bounded-workflow")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeWorkflowImplementationAndMemorySurfaces = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState =
			ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToPlanOrchestrationOnly = true;
		SkillState.bRequiresImplementationDelegationSubstrate = true;
		SkillState.bRequiresWorkflowMemorySubstrate = true;
		SkillState.bRequiresWorkflowReviewSubstrate = true;
		SkillState.bAvoidsProviderWidening = true;
		SkillState.bAvoidsDomainSkillPackWidening = true;
		SkillState.bAvoidsAutonomousExecutionClaims = true;

		if (SkillId == TEXT("skill/synthesize-plan"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/implementation-review-spec"),
				TEXT("source-surface/bounded-delegation-spec"),
				TEXT("source-surface/workflow-session-template-capture"),
				TEXT("source-surface/proposal-review"),
				TEXT("source-surface/phase-s5c-packet")
			};
			AddPreviewHeadline(SkillState.PreviewHeadlines, TEXT("Plan synthesis readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Bounded first-party plan shaping")
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Plan-synthesis output")
			);
			SkillState.bSynthesizesBoundedPlan = true;
			SkillState.bChainsBoundedWorkflow = false;
			SkillState.Summary =
				TEXT("Live first-party bounded plan-synthesis skill above the implementation/delegation, workflow-memory, and workflow/review seams.");
		}
		else if (SkillId == TEXT("skill/chain-bounded-workflow"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/bounded-plan-synthesis"),
				TEXT("source-surface/bounded-delegation-spec"),
				TEXT("source-surface/workflow-follow-up-capture"),
				TEXT("source-surface/bounded-workflow-wrapper"),
				TEXT("source-surface/phase-s5c-packet")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Workflow chaining readiness")
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Bounded workflow-chain shaping")
			);
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Workflow-chain output")
			);
			SkillState.bSynthesizesBoundedPlan = false;
			SkillState.bChainsBoundedWorkflow = true;
			SkillState.Summary =
				TEXT("Live first-party bounded workflow-chaining skill above the implementation/delegation, workflow-memory, and workflow/review seams.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredImplementationDelegationSkillCount =
			SkillState.RequiredImplementationDelegationSkillIds.Num();
		SkillState.RequiredWorkflowMemorySkillCount =
			SkillState.RequiredWorkflowMemorySkillIds.Num();
		SkillState.RequiredWorkflowReviewSkillCount =
			SkillState.RequiredWorkflowReviewSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/synthesize-plan")),
		FString(TEXT("skill/chain-bounded-workflow"))
	})
	{
		const FHyperTwistSkillPlanOrchestrationSkill SkillState =
			BuildPlanOrchestrationSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillPlanOrchestrationState();
		}

		PlanOrchestrationState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillPlanOrchestrationSkill& SkillState :
		PlanOrchestrationState.Skills)
	{
		PlanOrchestrationState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		PlanOrchestrationState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		PlanOrchestrationState.PlanSynthesisSkillCount +=
			SkillState.bSynthesizesBoundedPlan ? 1 : 0;
		PlanOrchestrationState.WorkflowChainingSkillCount +=
			SkillState.bChainsBoundedWorkflow ? 1 : 0;
		PlanOrchestrationState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		PlanOrchestrationState.bPlanOrchestrationRemainsBounded &=
			SkillState.bBoundedToPlanOrchestrationOnly;
		PlanOrchestrationState
			.bEverySkillRequiresImplementationDelegationSubstrate &=
			SkillState.bRequiresImplementationDelegationSubstrate;
		PlanOrchestrationState.bEverySkillRequiresWorkflowMemorySubstrate &=
			SkillState.bRequiresWorkflowMemorySubstrate;
		PlanOrchestrationState.bEverySkillRequiresWorkflowReviewSubstrate &=
			SkillState.bRequiresWorkflowReviewSubstrate;
		PlanOrchestrationState.bNoProviderWidening &=
			SkillState.bAvoidsProviderWidening;
		PlanOrchestrationState.bNoDomainSkillPackWidening &=
			SkillState.bAvoidsDomainSkillPackWidening;
		PlanOrchestrationState.bNoAutonomousExecutionClaims &=
			SkillState.bAvoidsAutonomousExecutionClaims;

		if (SkillState.bLiveSkill)
		{
			PlanOrchestrationState
				.bEveryLiveSkillReadsAuthoritativeWorkflowImplementationAndMemorySurfaces &=
				SkillState.bReadsAuthoritativeWorkflowImplementationAndMemorySurfaces;
			PlanOrchestrationState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	PlanOrchestrationState.SkillCount = PlanOrchestrationState.Skills.Num();

	return PlanOrchestrationState;
}

FHyperTwistSkillProviderProfileRoutingState
UHyperTwistSkillCoreLibrary::DeriveSkillProviderProfileRoutingState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillAnalyzerWrapperState& AnalyzerWrapperState,
	const FHyperTwistSpeechSessionConfig& SpeechSessionConfig,
	const FHyperTwistSpeechServiceHealth& SpeechServiceHealth
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !AnalyzerWrapperState.IsStructurallyValid()
		|| !SpeechSessionConfig.IsStructurallyValid()
		|| !SpeechServiceHealth.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != AnalyzerWrapperState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AnalyzerWrapperState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillProviderProfileRoutingState();
	}

	FHyperTwistSkillProviderProfileRoutingState ProviderProfileRoutingState;
	ProviderProfileRoutingState.RegistryId = RegistryState.RegistryId;
	ProviderProfileRoutingState.ManifestVersion = TEXT("s6a-v1");
	ProviderProfileRoutingState.ReferenceUtc = TEXT("2026-05-31T05:35:00Z");
	ProviderProfileRoutingState.CommandSurfaceRootId =
		RegistryState.CommandSurfaceRootId;
	ProviderProfileRoutingState.TemplateVersion =
		TEXT("skill-provider-profile-routing-v1");
	ProviderProfileRoutingState
		.bEveryLiveSkillReadsAuthoritativeProviderNeutralState = true;
	ProviderProfileRoutingState.bEverySkillPreservesOptionalAssistiveOffState =
		true;
	ProviderProfileRoutingState.bEveryLiveSkillHasValidationHarnessCoverage =
		true;
	ProviderProfileRoutingState.bProviderProfileRoutingRemainsBounded = true;
	ProviderProfileRoutingState.bEverySkillRequiresAnalyzerWrapperSubstrate =
		true;
	ProviderProfileRoutingState.bEverySkillRequiresProviderSessionConfigState =
		true;
	ProviderProfileRoutingState.bEverySkillRequiresProviderServiceHealthState =
		true;
	ProviderProfileRoutingState
		.bOpenAiCompatibleCustomEndpointsRemainFirstClass = true;
	ProviderProfileRoutingState.bUserLabeledByokProfilesRemainSupported = true;
	ProviderProfileRoutingState.bProviderNeutralityRemainsPreserved = true;
	ProviderProfileRoutingState.bNoProviderSpecificOverlayWidening = true;
	ProviderProfileRoutingState.Summary =
		TEXT("First-party bounded provider-profile inspection, BYOK profile setup, and routing-diagnostic layer above the landed provider wrapper and provider-neutral speech/provider seams.");

	const bool bSupportsOpenAiCompatibleCustomEndpoints =
		SpeechSessionConfig.ByokCustodyProfileDefinition
			.bSupportsOpenAiCompatibleCustomEndpoints
		&& SpeechSessionConfig.ProviderRoutingPolicyDefinition
			.bAllowOpenAiCompatibleCustomEndpointRoutes
		&& SpeechServiceHealth.ByokCustodyProfileDefinition
			.bSupportsOpenAiCompatibleCustomEndpoints
		&& SpeechServiceHealth.Capabilities.Contains(
			TEXT("openAiCompatibleCustomEndpointProfile"));
	const bool bSupportsUserLabeledByokProfiles =
		SpeechSessionConfig.ByokCustodyProfileDefinition
			.bSupportsUserLabeledProfiles
		&& SpeechServiceHealth.ByokCustodyProfileDefinition
			.bSupportsUserLabeledProfiles
		&& SpeechServiceHealth.Capabilities.Contains(TEXT("userLabeledByokProfiles"));
	const bool bPreservesProviderNeutrality =
		SpeechSessionConfig.ByokCustodyProfileDefinition
			.bPreservesProviderNeutrality
		&& SpeechServiceHealth.ByokCustodyProfileDefinition
			.bPreservesProviderNeutrality
		&& SpeechSessionConfig.ProviderProfileDefinition
			.bPreservesFirstPartyCustody
		&& SpeechServiceHealth.ProviderProfileDefinition
			.bPreservesFirstPartyCustody;

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto AnalyzerWrapperSkillExists = [&AnalyzerWrapperState](
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillAnalyzerWrapperOutput& Output :
			AnalyzerWrapperState.Outputs)
		{
			if (Output.SkillId == SkillId && Output.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildProviderProfileRoutingSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillProviderProfileRoutingSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsProviderProfileRoutingSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !AnalyzerWrapperSkillExists(TEXT("skill/provider-routing-inspector"))
			|| !bSupportsOpenAiCompatibleCustomEndpoints
			|| !bSupportsUserLabeledByokProfiles
			|| !bPreservesProviderNeutrality)
		{
			return FHyperTwistSkillProviderProfileRoutingSkill();
		}

		FHyperTwistSkillProviderProfileRoutingSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredAnalyzerWrapperSkillIds = {
			TEXT("skill/provider-routing-inspector")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeProviderNeutralState = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState =
			ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToProviderProfileRoutingOnly = true;
		SkillState.bRequiresAnalyzerWrapperSubstrate = true;
		SkillState.bRequiresProviderSessionConfigState = true;
		SkillState.bRequiresProviderServiceHealthState = true;
		SkillState.bPreservesOpenAiCompatibleCustomEndpointFirstClass = true;
		SkillState.bPreservesUserLabeledByokProfiles = true;
		SkillState.bPreservesProviderNeutrality = true;
		SkillState.bAvoidsProviderSpecificOverlayWidening = true;

		if (SkillId == TEXT("skill/inspect-provider-profile"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/provider-profile-definition"),
				TEXT("source-surface/byok-custody-profile"),
				TEXT("source-surface/provider-session-config"),
				TEXT("source-surface/phase-6r-x-packet"),
				TEXT("source-surface/phase-6r-ai-custom-endpoint-runtime")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-profile inspection readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-profile custody and capability review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-profile inspection output"));
			SkillState.bInspectsProviderProfile = true;
			SkillState.bSetsUpByokProfile = false;
			SkillState.bDiagnosesRouting = false;
			SkillState.Summary =
				TEXT("Live first-party bounded provider-profile inspection skill above the landed provider wrapper and provider-neutral speech/provider seams.");
		}
		else if (SkillId == TEXT("skill/setup-byok-profile"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/byok-custody-profile"),
				TEXT("source-surface/provider-profile-definition"),
				TEXT("source-surface/provider-routing-policy"),
				TEXT("source-surface/phase-6r-x-packet"),
				TEXT("source-surface/phase-6r-ai-custom-endpoint-runtime")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("BYOK-profile setup readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("User-labeled custom-endpoint setup posture"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("BYOK-profile setup output"));
			SkillState.bInspectsProviderProfile = false;
			SkillState.bSetsUpByokProfile = true;
			SkillState.bDiagnosesRouting = false;
			SkillState.Summary =
				TEXT("Live first-party bounded BYOK profile-setup skill above the landed provider wrapper and provider-neutral speech/provider seams.");
		}
		else if (SkillId == TEXT("skill/diagnose-provider-routing"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/provider-routing-policy"),
				TEXT("source-surface/provider-route-decision"),
				TEXT("source-surface/provider-route-inspection-wrapper"),
				TEXT("source-surface/provider-service-health"),
				TEXT("source-surface/phase-6r-y-packet"),
				TEXT("source-surface/phase-6r-ai-custom-endpoint-runtime")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-routing diagnostic readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Route-policy and fallback review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-routing diagnostic output"));
			SkillState.bInspectsProviderProfile = false;
			SkillState.bSetsUpByokProfile = false;
			SkillState.bDiagnosesRouting = true;
			SkillState.Summary =
				TEXT("Live first-party bounded provider-routing diagnostic skill above the landed provider wrapper and provider-neutral speech/provider seams.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredAnalyzerWrapperSkillCount =
			SkillState.RequiredAnalyzerWrapperSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/inspect-provider-profile")),
		FString(TEXT("skill/setup-byok-profile")),
		FString(TEXT("skill/diagnose-provider-routing"))
	})
	{
		const FHyperTwistSkillProviderProfileRoutingSkill SkillState =
			BuildProviderProfileRoutingSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillProviderProfileRoutingState();
		}

		ProviderProfileRoutingState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillProviderProfileRoutingSkill& SkillState :
		ProviderProfileRoutingState.Skills)
	{
		ProviderProfileRoutingState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		ProviderProfileRoutingState.AvailableNowCount +=
			SkillState.bAvailableNow ? 1 : 0;
		ProviderProfileRoutingState.ProviderProfileInspectionSkillCount +=
			SkillState.bInspectsProviderProfile ? 1 : 0;
		ProviderProfileRoutingState.ByokProfileSetupSkillCount +=
			SkillState.bSetsUpByokProfile ? 1 : 0;
		ProviderProfileRoutingState.RoutingDiagnosticSkillCount +=
			SkillState.bDiagnosesRouting ? 1 : 0;
		ProviderProfileRoutingState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		ProviderProfileRoutingState.bProviderProfileRoutingRemainsBounded &=
			SkillState.bBoundedToProviderProfileRoutingOnly;
		ProviderProfileRoutingState.bEverySkillRequiresAnalyzerWrapperSubstrate &=
			SkillState.bRequiresAnalyzerWrapperSubstrate;
		ProviderProfileRoutingState.bEverySkillRequiresProviderSessionConfigState &=
			SkillState.bRequiresProviderSessionConfigState;
		ProviderProfileRoutingState.bEverySkillRequiresProviderServiceHealthState &=
			SkillState.bRequiresProviderServiceHealthState;
		ProviderProfileRoutingState
			.bOpenAiCompatibleCustomEndpointsRemainFirstClass &=
			SkillState.bPreservesOpenAiCompatibleCustomEndpointFirstClass;
		ProviderProfileRoutingState.bUserLabeledByokProfilesRemainSupported &=
			SkillState.bPreservesUserLabeledByokProfiles;
		ProviderProfileRoutingState.bProviderNeutralityRemainsPreserved &=
			SkillState.bPreservesProviderNeutrality;
		ProviderProfileRoutingState.bNoProviderSpecificOverlayWidening &=
			SkillState.bAvoidsProviderSpecificOverlayWidening;

		if (SkillState.bLiveSkill)
		{
			ProviderProfileRoutingState
				.bEveryLiveSkillReadsAuthoritativeProviderNeutralState &=
				SkillState.bReadsAuthoritativeProviderNeutralState;
			ProviderProfileRoutingState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	ProviderProfileRoutingState.SkillCount =
		ProviderProfileRoutingState.Skills.Num();

	return ProviderProfileRoutingState;
}

FHyperTwistSkillProviderUsageOperationsAuditState
UHyperTwistSkillCoreLibrary::DeriveSkillProviderUsageOperationsAuditState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillProviderProfileRoutingState&
		ProviderProfileRoutingState,
	const FHyperTwistSpeechSessionConfig& SpeechSessionConfig,
	const FHyperTwistSpeechServiceHealth& SpeechServiceHealth
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !ProviderProfileRoutingState.IsStructurallyValid()
		|| !SpeechSessionConfig.IsStructurallyValid()
		|| !SpeechServiceHealth.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != ProviderProfileRoutingState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId != AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= ProviderProfileRoutingState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillProviderUsageOperationsAuditState();
	}

	FHyperTwistSkillProviderUsageOperationsAuditState AuditState;
	AuditState.RegistryId = RegistryState.RegistryId;
	AuditState.ManifestVersion = TEXT("s6b-v1");
	AuditState.ReferenceUtc = TEXT("2026-05-31T06:25:00Z");
	AuditState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	AuditState.TemplateVersion = TEXT("skill-provider-usage-ops-audit-v1");
	AuditState.bEveryLiveSkillReadsNormalizedFirstPartyState = true;
	AuditState.bEverySkillPreservesOptionalAssistiveOffState = true;
	AuditState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	AuditState.bUsageOperationsAuditRemainsBounded = true;
	AuditState.bEverySkillRequiresProviderProfileRoutingSubstrate = true;
	AuditState.bEverySkillRequiresUsageCostAccountingState = true;
	AuditState.bEverySkillRequiresRouteAndServiceHealthState = true;
	AuditState.bNormalizedFirstPartyAccountingOwnershipPreserved = true;
	AuditState.bNoSettlementExecutionWidening = true;
	AuditState.bNoProviderPortalWidening = true;
	AuditState.Summary =
		TEXT("First-party bounded provider usage-audit, topology-inspection, and route/service-diagnostic layer above the landed provider-profile/routing and normalized usage/cost seams.");

	const bool bReadsNormalizedFirstPartyState =
		SpeechSessionConfig.UsageCostAccountingProfileDefinition
			.IsStructurallyValid()
		&& SpeechSessionConfig.UsageEventTemplate.IsStructurallyValid()
		&& SpeechSessionConfig.CostEventTemplate.IsStructurallyValid()
		&& SpeechServiceHealth.UsageCostAccountingProfileDefinition
			.IsStructurallyValid()
		&& SpeechServiceHealth.LatestUsageEvent.IsStructurallyValid()
		&& SpeechServiceHealth.LatestCostEvent.IsStructurallyValid()
		&& SpeechServiceHealth.QuotaRateLimitState.IsStructurallyValid()
		&& SpeechServiceHealth.Capabilities.Contains(TEXT("normalizedUsageEvents"))
		&& SpeechServiceHealth.Capabilities.Contains(TEXT("normalizedCostEvents"))
		&& SpeechServiceHealth.Capabilities.Contains(TEXT("quotaRateLimitState"));

	const bool bPreservesNormalizedFirstPartyAccountingOwnership =
		SpeechSessionConfig.UsageCostAccountingProfileDefinition
			.bPreservesFirstPartyAccountingOwnership
		&& !SpeechSessionConfig.UsageCostAccountingProfileDefinition
			.bAllowsDonorOwnedCostGovernance
		&& SpeechServiceHealth.UsageCostAccountingProfileDefinition
			.bPreservesFirstPartyAccountingOwnership
		&& !SpeechServiceHealth.UsageCostAccountingProfileDefinition
			.bAllowsDonorOwnedCostGovernance;

	const bool bHasBoundedOperatorShellTopology =
		SpeechSessionConfig.UsageCostDashboardShellProfileDefinition
			.IsStructurallyValid()
		&& SpeechSessionConfig.UsageCostHistoryExportShellProfileDefinition
			.IsStructurallyValid()
		&& SpeechSessionConfig.ProviderReceiptReviewShellProfileDefinition
			.IsStructurallyValid()
		&& SpeechSessionConfig.ProviderBillingSettlementShellProfileDefinition
			.IsStructurallyValid()
		&& SpeechSessionConfig.ProviderSettlementExceptionShellProfileDefinition
			.IsStructurallyValid()
		&& SpeechServiceHealth.Capabilities.Contains(
			TEXT("providerUsageCostDashboardShell"))
		&& SpeechServiceHealth.Capabilities.Contains(
			TEXT("providerUsageCostHistoryShell"))
		&& SpeechServiceHealth.Capabilities.Contains(
			TEXT("providerUsageCostExportPreview"))
		&& SpeechServiceHealth.Capabilities.Contains(
			TEXT("providerUsageCostSummaryCopy"))
		&& SpeechServiceHealth.Capabilities.Contains(
			TEXT("providerRouteCostDiagnostics"));

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto ProviderProfileRoutingSkillExists = [&ProviderProfileRoutingState](
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillProviderProfileRoutingSkill& SkillState :
			ProviderProfileRoutingState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildProviderUsageOperationsAuditSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillProviderUsageOperationsAuditSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsProviderUsageOperationsAuditSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !ProviderProfileRoutingSkillExists(
				TEXT("skill/inspect-provider-profile"))
			|| !ProviderProfileRoutingSkillExists(TEXT("skill/setup-byok-profile"))
			|| !ProviderProfileRoutingSkillExists(
				TEXT("skill/diagnose-provider-routing"))
			|| !bReadsNormalizedFirstPartyState
			|| !bPreservesNormalizedFirstPartyAccountingOwnership
			|| !bHasBoundedOperatorShellTopology)
		{
			return FHyperTwistSkillProviderUsageOperationsAuditSkill();
		}

		FHyperTwistSkillProviderUsageOperationsAuditSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredProviderProfileRoutingSkillIds = {
			TEXT("skill/inspect-provider-profile"),
			TEXT("skill/setup-byok-profile"),
			TEXT("skill/diagnose-provider-routing")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsNormalizedFirstPartyState = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState =
			ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToUsageOperationsAuditOnly = true;
		SkillState.bRequiresProviderProfileRoutingSubstrate = true;
		SkillState.bRequiresUsageCostAccountingState = true;
		SkillState.bRequiresRouteAndServiceHealthState = true;
		SkillState.bPreservesNormalizedFirstPartyAccountingOwnership = true;
		SkillState.bAvoidsSettlementExecutionWidening = true;
		SkillState.bAvoidsProviderPortalWidening = true;

		if (SkillId == TEXT("skill/audit-provider-usage"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/usage-cost-accounting-profile"),
				TEXT("source-surface/normalized-usage-event"),
				TEXT("source-surface/normalized-cost-event"),
				TEXT("source-surface/quota-rate-limit-state"),
				TEXT("source-surface/usage-cost-dashboard-shell-profile"),
				TEXT("source-surface/usage-cost-history-export-shell-profile"),
				TEXT("source-surface/phase-6r-z-packet")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-usage audit readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Normalized usage, cost, and quota review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-usage audit output"));
			SkillState.bAuditsUsage = true;
			SkillState.bInspectsTopology = false;
			SkillState.bDiagnosesRouteService = false;
			SkillState.Summary =
				TEXT("Live first-party bounded provider-usage audit skill above the landed provider-profile/routing and normalized usage/cost seams.");
		}
		else if (SkillId == TEXT("skill/inspect-provider-topology"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/provider-profile-definition"),
				TEXT("source-surface/provider-route-decision"),
				TEXT("source-surface/provider-service-health"),
				TEXT("source-surface/usage-cost-dashboard-shell-profile"),
				TEXT("source-surface/usage-cost-history-export-shell-profile"),
				TEXT("source-surface/provider-receipt-review-shell-profile"),
				TEXT("source-surface/provider-billing-settlement-shell-profile"),
				TEXT("source-surface/provider-settlement-exception-shell-profile"),
				TEXT("source-surface/phase-6r-aa-operator-shells")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-topology inspection readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Service-lane and operator-shell topology review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Provider-topology inspection output"));
			SkillState.bAuditsUsage = false;
			SkillState.bInspectsTopology = true;
			SkillState.bDiagnosesRouteService = false;
			SkillState.Summary =
				TEXT("Live first-party bounded provider-topology inspection skill above the landed provider-profile/routing and operator-shell seams.");
		}
		else if (SkillId == TEXT("skill/diagnose-route-service"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/provider-routing-policy"),
				TEXT("source-surface/provider-route-decision"),
				TEXT("source-surface/provider-service-health"),
				TEXT("source-surface/quota-rate-limit-state"),
				TEXT("source-surface/provider-route-cost-diagnostics-capability"),
				TEXT("source-surface/usage-cost-dashboard-shell-profile"),
				TEXT("source-surface/phase-6r-y-packet"),
				TEXT("source-surface/phase-6r-z-packet")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Route/service diagnostic readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Quota, route, and health diagnostic review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Route/service diagnostic output"));
			SkillState.bAuditsUsage = false;
			SkillState.bInspectsTopology = false;
			SkillState.bDiagnosesRouteService = true;
			SkillState.Summary =
				TEXT("Live first-party bounded route/service diagnostic skill above the landed provider-profile/routing, normalized usage/cost, and service-health seams.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredProviderProfileRoutingSkillCount =
			SkillState.RequiredProviderProfileRoutingSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/audit-provider-usage")),
		FString(TEXT("skill/inspect-provider-topology")),
		FString(TEXT("skill/diagnose-route-service"))
	})
	{
		const FHyperTwistSkillProviderUsageOperationsAuditSkill SkillState =
			BuildProviderUsageOperationsAuditSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillProviderUsageOperationsAuditState();
		}

		AuditState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillProviderUsageOperationsAuditSkill& SkillState :
		AuditState.Skills)
	{
		AuditState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		AuditState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		AuditState.UsageAuditSkillCount += SkillState.bAuditsUsage ? 1 : 0;
		AuditState.TopologyInspectionSkillCount += SkillState.bInspectsTopology ? 1 : 0;
		AuditState.RouteServiceDiagnosticSkillCount +=
			SkillState.bDiagnosesRouteService ? 1 : 0;
		AuditState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		AuditState.bUsageOperationsAuditRemainsBounded &=
			SkillState.bBoundedToUsageOperationsAuditOnly;
		AuditState.bEverySkillRequiresProviderProfileRoutingSubstrate &=
			SkillState.bRequiresProviderProfileRoutingSubstrate;
		AuditState.bEverySkillRequiresUsageCostAccountingState &=
			SkillState.bRequiresUsageCostAccountingState;
		AuditState.bEverySkillRequiresRouteAndServiceHealthState &=
			SkillState.bRequiresRouteAndServiceHealthState;
		AuditState.bNormalizedFirstPartyAccountingOwnershipPreserved &=
			SkillState.bPreservesNormalizedFirstPartyAccountingOwnership;
		AuditState.bNoSettlementExecutionWidening &=
			SkillState.bAvoidsSettlementExecutionWidening;
		AuditState.bNoProviderPortalWidening &=
			SkillState.bAvoidsProviderPortalWidening;

		if (SkillState.bLiveSkill)
		{
			AuditState.bEveryLiveSkillReadsNormalizedFirstPartyState &=
				SkillState.bReadsNormalizedFirstPartyState;
			AuditState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	AuditState.SkillCount = AuditState.Skills.Num();

	return AuditState;
}

FHyperTwistSkillDomainPackFrameworkState
UHyperTwistSkillCoreLibrary::DeriveSkillDomainPackFrameworkState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillPlanOrchestrationState& PlanOrchestrationState,
	const FHyperTwistSkillProviderUsageOperationsAuditState&
		ProviderUsageOperationsAuditState
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !PlanOrchestrationState.IsStructurallyValid()
		|| !ProviderUsageOperationsAuditState.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != PlanOrchestrationState.RegistryId
		|| RegistryState.RegistryId
			!= ProviderUsageOperationsAuditState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= PlanOrchestrationState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= ProviderUsageOperationsAuditState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillDomainPackFrameworkState();
	}

	FHyperTwistSkillDomainPackFrameworkState FrameworkState;
	FrameworkState.RegistryId = RegistryState.RegistryId;
	FrameworkState.ManifestVersion = TEXT("s7a-v1");
	FrameworkState.ReferenceUtc = TEXT("2026-05-31T07:20:00Z");
	FrameworkState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	FrameworkState.TemplateVersion = TEXT("skill-domain-pack-framework-v1");
	FrameworkState.bEveryLiveSkillReadsAuthoritativeSkillAndFrameworkState = true;
	FrameworkState.bEverySkillPreservesOptionalAssistiveOffState = true;
	FrameworkState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	FrameworkState.bDomainPackFrameworkRemainsBounded = true;
	FrameworkState.bEverySkillRequiresPlanOrchestrationSubstrate = true;
	FrameworkState.bEverySkillRequiresProviderUsageOperationsAuditSubstrate = true;
	FrameworkState.bPlaceholderDomainPackDeferralRemainsPreserved = true;
	FrameworkState.bNoRetainedDomainPackClaims = true;
	FrameworkState.bNoCreativeMediaWidening = true;
	FrameworkState.Summary =
		TEXT("First-party bounded domain-pack framework layer for packaging rules and enable/disable grouping above the landed plan/orchestration and provider usage/ops audit seams.");

	const bool bReadsAuthoritativeSkillAndFrameworkState =
		PlanOrchestrationState
			.bEveryLiveSkillReadsAuthoritativeWorkflowImplementationAndMemorySurfaces
		&& PlanOrchestrationState.bPlanOrchestrationRemainsBounded
		&& ProviderUsageOperationsAuditState
			.bEveryLiveSkillReadsNormalizedFirstPartyState
		&& ProviderUsageOperationsAuditState.bUsageOperationsAuditRemainsBounded;

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto PlanOrchestrationSkillExists = [&PlanOrchestrationState](
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillPlanOrchestrationSkill& SkillState :
			PlanOrchestrationState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto ProviderUsageAuditSkillExists = [&ProviderUsageOperationsAuditState](
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillProviderUsageOperationsAuditSkill& SkillState :
			ProviderUsageOperationsAuditState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildDomainPackFrameworkSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillDomainPackFrameworkSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		const FHyperTwistSkillManifestEntry* PlaceholderEntry =
			FindManifestEntryById(RegistryState, TEXT("skill/curriculum-draft-pack"));
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsDomainPackFrameworkSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| PlaceholderEntry == nullptr
			|| !PlaceholderEntry->IsStructurallyValid()
			|| PlaceholderEntry->Status != EHyperTwistSkillStatus::PlaceholderFamily
			|| !PlanOrchestrationSkillExists(TEXT("skill/synthesize-plan"))
			|| !PlanOrchestrationSkillExists(TEXT("skill/chain-bounded-workflow"))
			|| !ProviderUsageAuditSkillExists(TEXT("skill/audit-provider-usage"))
			|| !ProviderUsageAuditSkillExists(TEXT("skill/inspect-provider-topology"))
			|| !ProviderUsageAuditSkillExists(TEXT("skill/diagnose-route-service"))
			|| !bReadsAuthoritativeSkillAndFrameworkState)
		{
			return FHyperTwistSkillDomainPackFrameworkSkill();
		}

		FHyperTwistSkillDomainPackFrameworkSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredPlanOrchestrationSkillIds = {
			TEXT("skill/synthesize-plan"),
			TEXT("skill/chain-bounded-workflow")
		};
		SkillState.RequiredProviderUsageAuditSkillIds = {
			TEXT("skill/audit-provider-usage"),
			TEXT("skill/inspect-provider-topology"),
			TEXT("skill/diagnose-route-service")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeSkillAndFrameworkState = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState =
			ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToDomainPackFrameworkOnly = true;
		SkillState.bRequiresPlanOrchestrationSubstrate = true;
		SkillState.bRequiresProviderUsageOperationsAuditSubstrate = true;
		SkillState.bPreservesPlaceholderDomainPackDeferral = true;
		SkillState.bAvoidsRetainedDomainPackClaims = true;
		SkillState.bAvoidsCreativeMediaWidening = true;

		if (SkillId == TEXT("skill/specify-domain-packaging"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/plan-orchestration-state"),
				TEXT("source-surface/provider-usage-ops-audit-state"),
				TEXT("source-surface/domain-creative-placeholder-pack"),
				TEXT("source-surface/skillization-doctrine-s7-a"),
				TEXT("source-surface/skills-roadmap-domain-pack-sequence"),
				TEXT("source-surface/feature-registry-domain-creative-family")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Domain-pack packaging rules readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Placeholder-to-retained pack transition guard"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Domain-pack packaging rules output"));
			SkillState.bSpecifiesPackagingRules = true;
			SkillState.bSpecifiesEnableDisableGrouping = false;
			SkillState.Summary =
				TEXT("Live first-party bounded domain-pack packaging-rules skill above the landed plan/orchestration and provider usage/ops audit seams.");
		}
		else if (SkillId == TEXT("skill/specify-domain-pack-grouping"))
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/skill-control-domain-creative-visibility-group"),
				TEXT("source-surface/plan-orchestration-state"),
				TEXT("source-surface/provider-usage-ops-audit-state"),
				TEXT("source-surface/domain-creative-placeholder-pack"),
				TEXT("source-surface/skillization-doctrine-s7-a"),
				TEXT("source-surface/feature-registry-domain-creative-family")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Domain-pack enable/disable grouping readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Domain-creative family visibility and off-state review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Domain-pack grouping output"));
			SkillState.bSpecifiesPackagingRules = false;
			SkillState.bSpecifiesEnableDisableGrouping = true;
			SkillState.Summary =
				TEXT("Live first-party bounded domain-pack enable/disable-grouping skill above the landed plan/orchestration and provider usage/ops audit seams.");
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredPlanOrchestrationSkillCount =
			SkillState.RequiredPlanOrchestrationSkillIds.Num();
		SkillState.RequiredProviderUsageAuditSkillCount =
			SkillState.RequiredProviderUsageAuditSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/specify-domain-packaging")),
		FString(TEXT("skill/specify-domain-pack-grouping"))
	})
	{
		const FHyperTwistSkillDomainPackFrameworkSkill SkillState =
			BuildDomainPackFrameworkSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillDomainPackFrameworkState();
		}

		FrameworkState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillDomainPackFrameworkSkill& SkillState :
		FrameworkState.Skills)
	{
		FrameworkState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		FrameworkState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		FrameworkState.PackagingRuleSkillCount +=
			SkillState.bSpecifiesPackagingRules ? 1 : 0;
		FrameworkState.EnableDisableGroupingSkillCount +=
			SkillState.bSpecifiesEnableDisableGrouping ? 1 : 0;
		FrameworkState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		FrameworkState.bDomainPackFrameworkRemainsBounded &=
			SkillState.bBoundedToDomainPackFrameworkOnly;
		FrameworkState.bEverySkillRequiresPlanOrchestrationSubstrate &=
			SkillState.bRequiresPlanOrchestrationSubstrate;
		FrameworkState.bEverySkillRequiresProviderUsageOperationsAuditSubstrate &=
			SkillState.bRequiresProviderUsageOperationsAuditSubstrate;
		FrameworkState.bPlaceholderDomainPackDeferralRemainsPreserved &=
			SkillState.bPreservesPlaceholderDomainPackDeferral;
		FrameworkState.bNoRetainedDomainPackClaims &=
			SkillState.bAvoidsRetainedDomainPackClaims;
		FrameworkState.bNoCreativeMediaWidening &=
			SkillState.bAvoidsCreativeMediaWidening;

		if (SkillState.bLiveSkill)
		{
			FrameworkState.bEveryLiveSkillReadsAuthoritativeSkillAndFrameworkState &=
				SkillState.bReadsAuthoritativeSkillAndFrameworkState;
			FrameworkState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	FrameworkState.SkillCount = FrameworkState.Skills.Num();

	return FrameworkState;
}

FHyperTwistSkillRetainedDomainPackState
UHyperTwistSkillCoreLibrary::DeriveSkillRetainedDomainPackState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillDomainPackFrameworkState& DomainPackFrameworkState,
	const FHyperTwistTrainingRepositoryIntegrityReport&
		TrainingRepositoryIntegrityReport,
	const FHyperTwistTrainingDeckHistorySummary& DeckHistorySummary,
	const FHyperTwistTrainingTimingTrendSummary& TimingTrendSummary,
	const FHyperTwistTrainingPersonalBestSummary& PersonalBestSummary,
	const FHyperTwistReplayReviewAnalytics& ReplayReviewAnalytics,
	const TArray<FHyperTwistContentPack>& RetainedContentPacks,
	const FHyperTwistTrainingTimerExportPacket& TrainingTimerExportPacket,
	const FHyperTwistTrainingMediaExportReferenceBundle& MediaExportReferenceBundle
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !DomainPackFrameworkState.IsStructurallyValid()
		|| !TimingTrendSummary.IsStructurallyValid()
		|| !PersonalBestSummary.IsStructurallyValid()
		|| !TrainingTimerExportPacket.IsStructurallyValid()
		|| !MediaExportReferenceBundle.IsStructurallyValid()
		|| RegistryState.RegistryId != ControlState.RegistryId
		|| RegistryState.RegistryId != AuthoringHarnessState.RegistryId
		|| RegistryState.RegistryId != DomainPackFrameworkState.RegistryId
		|| RegistryState.CommandSurfaceRootId != ControlState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= AuthoringHarnessState.CommandSurfaceRootId
		|| RegistryState.CommandSurfaceRootId
			!= DomainPackFrameworkState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillRetainedDomainPackState();
	}

	const bool bHasTrainingReplayState =
		TrainingRepositoryIntegrityReport.TotalRunRecordCount > 0
		&& TrainingRepositoryIntegrityReport.TotalReviewPlanCount > 0
		&& TrainingRepositoryIntegrityReport.TotalStoredSessionTemplateCount > 0
		&& !DeckHistorySummary.UserId.IsEmpty()
		&& !DeckHistorySummary.DeckId.IsEmpty()
		&& DeckHistorySummary.SessionCount > 0
		&& ReplayReviewAnalytics.EventCount > 0
		&& ReplayReviewAnalytics.ReviewAnchors.Num() > 0
		&& ReplayReviewAnalytics.UniquePhaseCount > 0;

	bool bHasCurriculumContentState = RetainedContentPacks.Num() >= 3;
	TArray<FString> SeenContentPackIds;
	for (const FHyperTwistContentPack& ContentPack : RetainedContentPacks)
	{
		if (!ContentPack.IsStructurallyValid()
			|| SeenContentPackIds.Contains(ContentPack.ContentPackId))
		{
			bHasCurriculumContentState = false;
			break;
		}

		SeenContentPackIds.Add(ContentPack.ContentPackId);
	}

	const bool bHasMediaExportState =
		TrainingTimerExportPacket.Entries.Num() > 0
		&& MediaExportReferenceBundle.PackageReferences.Num() > 0
		&& MediaExportReferenceBundle.EmbeddedPlaybackContracts.Num() > 0
		&& MediaExportReferenceBundle.RenderOrchestrationContracts.Num() > 0
		&& MediaExportReferenceBundle.ComplianceBoundaries.Num() > 0;

	FHyperTwistSkillRetainedDomainPackState PackState;
	PackState.RegistryId = RegistryState.RegistryId;
	PackState.ManifestVersion = TEXT("s7b-v1");
	PackState.ReferenceUtc = TEXT("2026-05-31T08:10:00Z");
	PackState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	PackState.TemplateVersion = TEXT("skill-retained-domain-pack-v1");
	PackState.bEveryLiveSkillReadsAuthoritativeFirstPartyDomainState = true;
	PackState.bEverySkillPreservesOptionalAssistiveOffState = true;
	PackState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	PackState.bRetainedDomainPackLayerRemainsBounded = true;
	PackState.bEverySkillRequiresDomainPackFrameworkSubstrate = true;
	PackState.bRetainedPackClaimsRemainFirstPartyGrounded = true;
	PackState.bUnlandedPackDeferralRemainsPreserved = true;
	PackState.bNoCreativeAdjunctWidening = true;
	PackState.Summary =
		TEXT("First-party bounded retained domain-pack layer for training/replay review, curriculum/content, and media/export packs above the landed domain-pack framework seam.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto DomainFrameworkSkillExists = [&DomainPackFrameworkState](
		const FString& SkillId
	)
	{
		for (const FHyperTwistSkillDomainPackFrameworkSkill& SkillState :
			DomainPackFrameworkState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildRetainedDomainPackSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillRetainedDomainPackSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		const FHyperTwistSkillManifestEntry* PlaceholderEntry =
			FindManifestEntryById(RegistryState, TEXT("skill/curriculum-draft-pack"));
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsRetainedDomainPackSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| PlaceholderEntry == nullptr
			|| !PlaceholderEntry->IsStructurallyValid()
			|| PlaceholderEntry->Status != EHyperTwistSkillStatus::PlaceholderFamily
			|| !DomainFrameworkSkillExists(TEXT("skill/specify-domain-packaging"))
			|| !DomainFrameworkSkillExists(TEXT("skill/specify-domain-pack-grouping")))
		{
			return FHyperTwistSkillRetainedDomainPackSkill();
		}

		FHyperTwistSkillRetainedDomainPackSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.RequiredDomainPackFrameworkSkillIds = {
			TEXT("skill/specify-domain-packaging"),
			TEXT("skill/specify-domain-pack-grouping")
		};
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeFirstPartyDomainState = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState =
			ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToRetainedDomainPackOnly = true;
		SkillState.bRequiresDomainPackFrameworkSubstrate = true;
		SkillState.bPreservesFirstPartyRetainedPackGrounding = true;
		SkillState.bPreservesUnlandedPackDeferral = true;
		SkillState.bAvoidsCreativeAdjunctWidening = true;

		if (SkillId == TEXT("skill/review-training-replay-pack")
			&& bHasTrainingReplayState)
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/training-repository-integrity-report"),
				TEXT("source-surface/training-deck-history-summary"),
				TEXT("source-surface/training-timing-trend-summary"),
				TEXT("source-surface/training-personal-best-summary"),
				TEXT("source-surface/replay-review-analytics"),
				TEXT("source-surface/s7-a-domain-pack-framework")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Retained training/replay pack readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Training history, timing, and replay review synthesis"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Retained training/replay pack output"));
			SkillState.bReadsTrainingReplayState = true;
			SkillState.Summary =
				TEXT("Live first-party retained training/replay review pack grounded in repository integrity, training history, timing, and replay-review surfaces.");
		}
		else if (SkillId == TEXT("skill/curate-curriculum-content-pack")
			&& bHasCurriculumContentState)
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/alg-trainer-content-pack"),
				TEXT("source-surface/cross-trainer-content-pack"),
				TEXT("source-surface/five-style-content-pack"),
				TEXT("source-surface/phase-3-training-catalog"),
				TEXT("source-surface/s7-a-domain-pack-framework")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Retained curriculum/content pack readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Starter-pack and catalog curation review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Retained curriculum/content pack output"));
			SkillState.bReadsCurriculumContentState = true;
			SkillState.Summary =
				TEXT("Live first-party retained curriculum/content pack grounded in retained starter packs and phase-3 catalog surfaces.");
		}
		else if (SkillId == TEXT("skill/prepare-media-export-pack")
			&& bHasMediaExportState)
		{
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/training-timer-export-packet"),
				TEXT("source-surface/training-media-export-reference-bundle"),
				TEXT("source-surface/training-media-export-compliance-boundary"),
				TEXT("source-surface/s7-a-domain-pack-framework")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Retained media/export pack readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Timer export, playback, and render boundary review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Retained media/export pack output"));
			SkillState.bReadsMediaExportState = true;
			SkillState.Summary =
				TEXT("Live first-party retained media/export pack grounded in timer-export and media-export reference surfaces.");
		}
		else
		{
			return FHyperTwistSkillRetainedDomainPackSkill();
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredDomainPackFrameworkSkillCount =
			SkillState.RequiredDomainPackFrameworkSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/review-training-replay-pack")),
		FString(TEXT("skill/curate-curriculum-content-pack")),
		FString(TEXT("skill/prepare-media-export-pack"))
	})
	{
		const FHyperTwistSkillRetainedDomainPackSkill SkillState =
			BuildRetainedDomainPackSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillRetainedDomainPackState();
		}

		PackState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillRetainedDomainPackSkill& SkillState :
		PackState.Skills)
	{
		PackState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		PackState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		PackState.TrainingReplayPackSkillCount +=
			SkillState.bReadsTrainingReplayState ? 1 : 0;
		PackState.CurriculumContentPackSkillCount +=
			SkillState.bReadsCurriculumContentState ? 1 : 0;
		PackState.MediaExportPackSkillCount +=
			SkillState.bReadsMediaExportState ? 1 : 0;
		PackState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		PackState.bRetainedDomainPackLayerRemainsBounded &=
			SkillState.bBoundedToRetainedDomainPackOnly;
		PackState.bEverySkillRequiresDomainPackFrameworkSubstrate &=
			SkillState.bRequiresDomainPackFrameworkSubstrate;
		PackState.bRetainedPackClaimsRemainFirstPartyGrounded &=
			SkillState.bPreservesFirstPartyRetainedPackGrounding;
		PackState.bUnlandedPackDeferralRemainsPreserved &=
			SkillState.bPreservesUnlandedPackDeferral;
		PackState.bNoCreativeAdjunctWidening &=
			SkillState.bAvoidsCreativeAdjunctWidening;

		if (SkillState.bLiveSkill)
		{
			PackState.bEveryLiveSkillReadsAuthoritativeFirstPartyDomainState &=
				SkillState.bReadsAuthoritativeFirstPartyDomainState;
			PackState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	PackState.SkillCount = PackState.Skills.Num();

	return PackState;
}

FHyperTwistSkillCreativeMediaPackState
UHyperTwistSkillCoreLibrary::DeriveSkillCreativeMediaPackState(
	const FHyperTwistSkillRegistryState& RegistryState,
	const FHyperTwistSkillControlState& ControlState,
	const FHyperTwistSkillAuthoringHarnessState& AuthoringHarnessState,
	const FHyperTwistSkillRetainedDomainPackState& RetainedDomainPackState,
	const FHyperTwistReplayReviewAnalytics& ReplayReviewAnalytics,
	const FHyperTwistTrainingTimerExportPacket& TrainingTimerExportPacket,
	const FHyperTwistTrainingMediaExportReferenceBundle&
		MediaExportReferenceBundle,
	const FHyperTwistTrainingSharedAssetReferenceBundle&
		SharedAssetReferenceBundle
)
{
	using namespace HyperTwistSkillCoreLibraryInternal;

	if (!RegistryState.IsStructurallyValid()
		|| !ControlState.IsStructurallyValid()
		|| !AuthoringHarnessState.IsStructurallyValid()
		|| !RetainedDomainPackState.IsStructurallyValid()
		|| !TrainingTimerExportPacket.IsStructurallyValid()
		|| !MediaExportReferenceBundle.IsStructurallyValid()
		|| !SharedAssetReferenceBundle.IsStructurallyValid()
		|| ControlState.RegistryId != RegistryState.RegistryId
		|| AuthoringHarnessState.RegistryId != RegistryState.RegistryId
		|| RetainedDomainPackState.RegistryId != RegistryState.RegistryId
		|| RetainedDomainPackState.CommandSurfaceRootId
			!= RegistryState.CommandSurfaceRootId)
	{
		return FHyperTwistSkillCreativeMediaPackState();
	}

	const bool bHasReplayExplainerState =
		ReplayReviewAnalytics.EventCount > 0
		&& ReplayReviewAnalytics.ReviewAnchors.Num() > 0
		&& ReplayReviewAnalytics.UniquePhaseCount > 0
		&& TrainingTimerExportPacket.Entries.Num() > 0
		&& MediaExportReferenceBundle.EmbeddedPlaybackContracts.Num() > 0
		&& MediaExportReferenceBundle.RenderOrchestrationContracts.Num() > 0
		&& MediaExportReferenceBundle.ExplainerStudioContracts.Num() > 0
		&& MediaExportReferenceBundle.ComplianceBoundaries.Num() > 0;
	const bool bHasMediaParserState =
		TrainingTimerExportPacket.Entries.Num() > 0
		&& MediaExportReferenceBundle.PackageReferences.Num() > 0
		&& MediaExportReferenceBundle.MediaParserContracts.Num() > 0
		&& MediaExportReferenceBundle.ComplianceBoundaries.Num() > 0;
	const bool bHasSharedFixtureState =
		SharedAssetReferenceBundle.FixtureReferences.Num() > 0
		&& SharedAssetReferenceBundle.QaPackContracts.Num() > 0
		&& SharedAssetReferenceBundle.ProvenanceBoundaries.Num() > 0
		&& SharedAssetReferenceBundle.RefreshPatterns.Num() > 0;

	FHyperTwistSkillCreativeMediaPackState PackState;
	PackState.RegistryId = RegistryState.RegistryId;
	PackState.ManifestVersion = TEXT("s7c-v1");
	PackState.ReferenceUtc = TEXT("2026-05-31T09:20:00Z");
	PackState.CommandSurfaceRootId = RegistryState.CommandSurfaceRootId;
	PackState.TemplateVersion = TEXT("skill-creative-media-pack-v1");
	PackState.bEveryLiveSkillReadsAuthoritativeFirstPartyCreativeMediaState =
		true;
	PackState.bEverySkillPreservesOptionalAssistiveOffState = true;
	PackState.bEveryLiveSkillHasValidationHarnessCoverage = true;
	PackState.bCreativeMediaPackLayerRemainsBounded = true;
	PackState.bEverySkillRequiresRetainedDomainPackSubstrate = true;
	PackState.bCreativeMediaAdjunctsRemainOptional = true;
	PackState.bNoCoreRuntimePromotion = true;
	PackState.bBoundarySensitiveLicensingRemainsExplicit = true;
	PackState.Summary =
		TEXT("First-party bounded optional creative/media pack layer for replay explainers, media-parser briefs, and shared-fixture curation above the landed retained domain-pack seam.");

	auto AddPreviewHeadline = [](
		TArray<FString>& PreviewHeadlines,
		const FString& Headline
	)
	{
		if (!Headline.IsEmpty())
		{
			PreviewHeadlines.AddUnique(Headline);
		}
	};

	auto RetainedSkillExists = [&RetainedDomainPackState](const FString& SkillId)
	{
		for (const FHyperTwistSkillRetainedDomainPackSkill& SkillState :
			RetainedDomainPackState.Skills)
		{
			if (SkillState.SkillId == SkillId && SkillState.IsStructurallyValid())
			{
				return true;
			}
		}

		return false;
	};

	auto BuildCreativeMediaPackSkill = [&](
		const FString& SkillId
	) -> FHyperTwistSkillCreativeMediaPackSkill
	{
		const FHyperTwistSkillManifestEntry* Entry =
			FindManifestEntryById(RegistryState, SkillId);
		const FHyperTwistSkillControlStateEntry* ControlEntry =
			FindControlStateEntryById(ControlState, SkillId);
		const FHyperTwistSkillAuthoringExampleState* ExampleState =
			FindAuthoringExampleBySkillId(AuthoringHarnessState, SkillId);
		if (Entry == nullptr
			|| !Entry->IsStructurallyValid()
			|| !IsCreativeMediaPackSkill(SkillId)
			|| ControlEntry == nullptr
			|| !ControlEntry->IsStructurallyValid()
			|| !ControlEntry->bInstalled
			|| !ControlEntry->bOptionalAssistive
			|| ExampleState == nullptr
			|| !ExampleState->IsStructurallyValid()
			|| !HasLiveEvalValidationCase(AuthoringHarnessState, SkillId)
			|| !RetainedSkillExists(TEXT("skill/prepare-media-export-pack")))
		{
			return FHyperTwistSkillCreativeMediaPackSkill();
		}

		FHyperTwistSkillCreativeMediaPackSkill SkillState;
		SkillState.SkillId = Entry->SkillId;
		SkillState.DisplayLabel = Entry->DisplayLabel;
		SkillState.CommandSurfaceId = Entry->CommandBindings[0].CommandSurfaceId;
		SkillState.ServiceBindingId = Entry->CommandBindings[0].ServiceBindingId;
		SkillState.OwnerLaneId = Entry->OwnerLaneId;
		SkillState.OwnerFeatureId = Entry->OwnerFeatureId;
		SkillState.Status = Entry->Status;
		SkillState.PermissionScopeIds = MakePermissionScopeIds(*Entry);
		SkillState.OutputArtifactKinds = Entry->Provenance.ProducedArtifactKinds;
		SkillState.bLiveSkill = true;
		SkillState.bReadsAuthoritativeFirstPartyCreativeMediaState = true;
		SkillState.bAvailableNow = true;
		SkillState.bRequiresOwnerActivation = false;
		SkillState.bPreservesOptionalAssistiveOffState =
			ControlEntry->bInertWhenDisabled;
		SkillState.bDerivedAssistiveOnly = Entry->bOptionalAssistive;
		SkillState.bHasValidationHarnessCoverage = true;
		SkillState.bBoundedToCreativeMediaPackOnly = true;
		SkillState.bRequiresRetainedDomainPackSubstrate = true;
		SkillState.bCreativeMediaAdjunctOnly = true;
		SkillState.bAvoidsCoreRuntimePromotion = true;
		SkillState.bBoundarySensitiveLicensingRemainsExplicit = true;

		if (SkillId == TEXT("skill/compose-replay-explainer-pack")
			&& bHasReplayExplainerState
			&& RetainedSkillExists(TEXT("skill/review-training-replay-pack")))
		{
			SkillState.RequiredRetainedDomainPackSkillIds = {
				TEXT("skill/review-training-replay-pack"),
				TEXT("skill/prepare-media-export-pack")
			};
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/replay-review-analytics"),
				TEXT("source-surface/training-timer-export-packet"),
				TEXT("source-surface/training-media-export-embedded-playback-contract"),
				TEXT("source-surface/training-media-export-render-orchestration-contract"),
				TEXT("source-surface/training-media-export-explainer-studio-contract"),
				TEXT("source-surface/s7-b-retained-domain-packs")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Replay explainer pack readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Replay timeline, playback, and explainer-studio synthesis"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Optional replay explainer pack output"));
			SkillState.bReadsReplayExplainerState = true;
			SkillState.Summary =
				TEXT("Live first-party optional replay-explainer pack grounded in replay analytics, timer export, and bounded playback/render/explainer contracts.");
		}
		else if (SkillId == TEXT("skill/prepare-media-parser-pack")
			&& bHasMediaParserState)
		{
			SkillState.RequiredRetainedDomainPackSkillIds = {
				TEXT("skill/prepare-media-export-pack")
			};
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/training-media-export-media-parser-contract"),
				TEXT("source-surface/training-media-export-package-reference-bundle"),
				TEXT("source-surface/training-media-export-compliance-boundary"),
				TEXT("source-surface/training-timer-export-packet"),
				TEXT("source-surface/s7-b-retained-domain-packs")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Media parser pack readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Parser callbacks, worker-seeking, and preflight review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Optional media parser pack output"));
			SkillState.bReadsMediaParserState = true;
			SkillState.Summary =
				TEXT("Live first-party optional media-parser pack grounded in bounded parser, package-reference, timer-export, and compliance surfaces.");
		}
		else if (SkillId == TEXT("skill/curate-shared-fixture-pack")
			&& bHasSharedFixtureState)
		{
			SkillState.RequiredRetainedDomainPackSkillIds = {
				TEXT("skill/prepare-media-export-pack")
			};
			SkillState.SourceSurfaceIds = {
				TEXT("source-surface/shared-asset-reference-bundle"),
				TEXT("source-surface/shared-asset-qa-pack-contract"),
				TEXT("source-surface/shared-asset-provenance-boundary"),
				TEXT("source-surface/shared-asset-refresh-pattern"),
				TEXT("source-surface/s7-b-retained-domain-packs")
			};
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Shared fixture pack readiness"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Fixture allowlist, provenance, and refresh-boundary review"));
			AddPreviewHeadline(
				SkillState.PreviewHeadlines,
				TEXT("Optional shared fixture pack output"));
			SkillState.bReadsSharedFixtureState = true;
			SkillState.Summary =
				TEXT("Live first-party optional shared-fixture pack grounded in first-party fixture allowlist, provenance-boundary, and refresh-pattern surfaces.");
		}
		else
		{
			return FHyperTwistSkillCreativeMediaPackSkill();
		}

		SkillState.SourceSurfaceCount = SkillState.SourceSurfaceIds.Num();
		SkillState.RequiredRetainedDomainPackSkillCount =
			SkillState.RequiredRetainedDomainPackSkillIds.Num();
		return SkillState;
	};

	for (const FString& SkillId : {
		FString(TEXT("skill/compose-replay-explainer-pack")),
		FString(TEXT("skill/prepare-media-parser-pack")),
		FString(TEXT("skill/curate-shared-fixture-pack"))
	})
	{
		const FHyperTwistSkillCreativeMediaPackSkill SkillState =
			BuildCreativeMediaPackSkill(SkillId);
		if (!SkillState.IsStructurallyValid())
		{
			return FHyperTwistSkillCreativeMediaPackState();
		}

		PackState.Skills.Add(SkillState);
	}

	for (const FHyperTwistSkillCreativeMediaPackSkill& SkillState :
		PackState.Skills)
	{
		PackState.LiveSkillCount += SkillState.bLiveSkill ? 1 : 0;
		PackState.AvailableNowCount += SkillState.bAvailableNow ? 1 : 0;
		PackState.ReplayExplainerPackSkillCount +=
			SkillState.bReadsReplayExplainerState ? 1 : 0;
		PackState.MediaParserPackSkillCount +=
			SkillState.bReadsMediaParserState ? 1 : 0;
		PackState.SharedFixturePackSkillCount +=
			SkillState.bReadsSharedFixtureState ? 1 : 0;
		PackState.bEverySkillPreservesOptionalAssistiveOffState &=
			SkillState.bPreservesOptionalAssistiveOffState;
		PackState.bCreativeMediaPackLayerRemainsBounded &=
			SkillState.bBoundedToCreativeMediaPackOnly;
		PackState.bEverySkillRequiresRetainedDomainPackSubstrate &=
			SkillState.bRequiresRetainedDomainPackSubstrate;
		PackState.bCreativeMediaAdjunctsRemainOptional &=
			SkillState.bCreativeMediaAdjunctOnly;
		PackState.bNoCoreRuntimePromotion &=
			SkillState.bAvoidsCoreRuntimePromotion;
		PackState.bBoundarySensitiveLicensingRemainsExplicit &=
			SkillState.bBoundarySensitiveLicensingRemainsExplicit;

		if (SkillState.bLiveSkill)
		{
			PackState.bEveryLiveSkillReadsAuthoritativeFirstPartyCreativeMediaState &=
				SkillState.bReadsAuthoritativeFirstPartyCreativeMediaState;
			PackState.bEveryLiveSkillHasValidationHarnessCoverage &=
				SkillState.bHasValidationHarnessCoverage;
		}
	}

	PackState.SkillCount = PackState.Skills.Num();

	return PackState;
}
