Bias queue competition by deferred-first history

This commit is contained in:
axiomlogicnexus 2026-04-28 03:02:16 +02:00
parent c8fa056f54
commit 622a62cc26

View file

@ -235,6 +235,31 @@ namespace HyperTwistTrainingCoachLibraryInternal
);
}
float ResolveDeferredFirstFollowUpPacketPressure(
const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot)
{
const bool bPreferredGuidanceSource =
CoachMemorySnapshot.PreferredGuidanceSourceLabel
== TEXT("recommendation-history-deferred-first-follow-up");
const bool bPreferredHandoffSource =
CoachMemorySnapshot.PreferredCoachHandoffSourceLabel
== TEXT("recommendation-history-deferred-first-follow-up");
if (CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount <= 0
&& !bPreferredGuidanceSource
&& !bPreferredHandoffSource)
{
return 0.0f;
}
return FMath::Clamp(
(static_cast<float>(CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount) * 1.5f)
+ (bPreferredGuidanceSource ? 2.0f : 0.0f)
+ (bPreferredHandoffSource ? 2.0f : 0.0f),
0.0f,
8.0f
);
}
float ResolvePreferredGuidanceQueueBias(
const FString& SourceLabel,
const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
@ -377,6 +402,7 @@ namespace HyperTwistTrainingCoachLibraryInternal
float ResolveDeferredLaunchCompetitionQueueBias(
const FString& SourceLabel,
const FHyperTwistCoachBrief& FollowUpBrief,
const FHyperTwistTrainingCoachMemorySnapshot& CoachMemorySnapshot,
const bool bHasCompetingGuidanceEntry,
const bool bHasArchiveEntry)
{
@ -386,25 +412,51 @@ namespace HyperTwistTrainingCoachLibraryInternal
return 0.0f;
}
const float FollowUpBoost = FMath::Clamp(
float FollowUpBoost = FMath::Clamp(
(DeferredLaunchPressure * 0.6f)
+ (bHasCompetingGuidanceEntry ? 1.5f : 0.0f)
+ (FollowUpBrief.bHasTightenedLaunchOverflow ? 1.5f : 0.0f),
0.0f,
9.0f
);
const float PrimaryPenalty = FMath::Clamp(
float PrimaryPenalty = FMath::Clamp(
(DeferredLaunchPressure * 0.4f)
+ (bHasCompetingGuidanceEntry ? 1.0f : 0.0f),
0.0f,
6.0f
);
const float ArchivePenalty = FMath::Clamp(
float ArchivePenalty = FMath::Clamp(
(DeferredLaunchPressure * 0.22f)
+ (FollowUpBrief.bHasTightenedLaunchOverflow ? 0.5f : 0.0f),
0.0f,
3.0f
);
const float DeferredFirstPacketPressure = ResolveDeferredFirstFollowUpPacketPressure(
CoachMemorySnapshot
);
if (DeferredFirstPacketPressure > 0.0f)
{
const bool bFollowUpPreferredLane =
CoachMemorySnapshot.PreferredGuidanceLane
== EHyperTwistTrainingCoachGuidanceLane::FollowUp;
FollowUpBoost = FMath::Clamp(
FollowUpBoost
+ (DeferredFirstPacketPressure * 0.7f)
+ (bFollowUpPreferredLane ? 1.0f : 0.0f),
0.0f,
12.0f
);
PrimaryPenalty = FMath::Clamp(
PrimaryPenalty + (DeferredFirstPacketPressure * 0.55f),
0.0f,
8.0f
);
ArchivePenalty = FMath::Clamp(
ArchivePenalty + (DeferredFirstPacketPressure * 0.2f),
0.0f,
4.0f
);
}
if (SourceLabel == TEXT("follow-up-brief"))
{
@ -445,12 +497,18 @@ namespace HyperTwistTrainingCoachLibraryInternal
}
const bool bNeedsDeferredLaunchCompetition =
FollowUpBrief.bNeedsDeferredLaunchRecovery && FollowUpBrief.DeferredLaunchCaseCount > 0;
const float DeferredFirstPacketPressure = ResolveDeferredFirstFollowUpPacketPressure(
CoachMemorySnapshot
);
const bool bDeferredFirstFollowUpHistoryPreferred = DeferredFirstPacketPressure > 0.0f;
const bool bScheduleRecoveryPrefersFollowUp =
CoachMemorySnapshot.bNeedsScheduleFrictionRecovery
&& CoachMemorySnapshot.PreferredQueueRecoveryAction
== EHyperTwistTrainingQueueRecoveryAction::PromoteDeferred
&& CoachMemorySnapshot.PreferredGuidanceLane == EHyperTwistTrainingCoachGuidanceLane::FollowUp;
if (!bScheduleRecoveryPrefersFollowUp && !bNeedsDeferredLaunchCompetition)
if (!bScheduleRecoveryPrefersFollowUp
&& !bNeedsDeferredLaunchCompetition
&& !bDeferredFirstFollowUpHistoryPreferred)
{
return true;
}
@ -464,11 +522,25 @@ namespace HyperTwistTrainingCoachLibraryInternal
+ static_cast<float>(CoachMemorySnapshot.FollowUpGuidanceContinueBias)
+ (static_cast<float>(CoachMemorySnapshot.SuppressedPrimaryQueuePressureCount) * 2.0f)
+ (FollowUpBrief.bNeedsCoachReview ? 8.0f : 0.0f)
+ DeferredLaunchPressure;
const bool bShouldCreate = RecommendedRetentionScore >= FollowUpPressureScore + 8.0f;
+ DeferredLaunchPressure
+ DeferredFirstPacketPressure;
const float RecommendedRetentionThreshold =
bDeferredFirstFollowUpHistoryPreferred ? 10.0f : 8.0f;
const bool bShouldCreate =
RecommendedRetentionScore >= FollowUpPressureScore + RecommendedRetentionThreshold;
if (!bShouldCreate && OutSuppressionReason != nullptr)
{
if (bNeedsDeferredLaunchCompetition)
if (bNeedsDeferredLaunchCompetition && bDeferredFirstFollowUpHistoryPreferred)
{
*OutSuppressionReason = FString::Printf(
TEXT("Recommended queue creation was suppressed because successful deferred-first follow-up history is reinforcing narrowed continuation while tightened-budget deferred coach work remains unresolved (recommended %.1f vs follow-up %.1f, deferredLaunchCases=%d, deferredFirstHistory=%d)."),
RecommendedRetentionScore,
FollowUpPressureScore,
FollowUpBrief.DeferredLaunchCaseCount,
CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount
);
}
else if (bNeedsDeferredLaunchCompetition)
{
*OutSuppressionReason = FString::Printf(
TEXT("Recommended queue creation was suppressed because tightened-budget deferred coach work is still unresolved (recommended %.1f vs follow-up %.1f, deferredLaunchCases=%d)."),
@ -477,6 +549,15 @@ namespace HyperTwistTrainingCoachLibraryInternal
FollowUpBrief.DeferredLaunchCaseCount
);
}
else if (bDeferredFirstFollowUpHistoryPreferred)
{
*OutSuppressionReason = FString::Printf(
TEXT("Recommended queue creation was suppressed because successful deferred-first follow-up history is reinforcing narrowed continuation before broader recommendation work resumes (recommended %.1f vs follow-up %.1f, deferredFirstHistory=%d)."),
RecommendedRetentionScore,
FollowUpPressureScore,
CoachMemorySnapshot.DeferredFirstFollowUpPacketHistoryCount
);
}
else
{
*OutSuppressionReason = FString::Printf(
@ -1727,6 +1808,7 @@ FHyperTwistCoachSessionQueueSummary UHyperTwistTrainingCoachLibrary::DeriveCoach
HyperTwistTrainingCoachLibraryInternal::ResolveDeferredLaunchCompetitionQueueBias(
SourceLabel,
FollowUpBrief,
CoachMemorySnapshot,
bHasCompetingGuidanceEntry,
bHasArchiveEntry
);