diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp index 53acd25..2a5e262 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistBootstrap/HyperTwistContractLibrary.cpp @@ -3788,6 +3788,46 @@ FHyperTwistMemoryRecallSharedContextState ); } +FHyperTwistMemoryCognitiveConsolidationState + UHyperTwistContractLibrary::MakeSampleTrainingMemoryCognitiveConsolidationState() +{ + FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState(); + RepositoryState = HyperTwistContractLibraryInternal::AppendSampleCoachArtifacts(RepositoryState); + + const FHyperTwistCoachBrief FollowUpBrief = MakeSampleTrainingCoachFollowUpBrief(); + const FHyperTwistTrainingCoachActionPlan FollowUpPlan = + UHyperTwistTrainingRepositoryLibrary::BuildCoachActionPlan( + FollowUpBrief, + MakeSampleTrainingCoachMemorySnapshot(), + TEXT("coach_follow_up_training_session_02"), + TEXT("2026-04-28T12:20:00Z"), + 0, + 0, + FString(), + FollowUpBrief.FocusCaseIds + ); + if (FollowUpPlan.IsStructurallyValid()) + { + RepositoryState = UHyperTwistTrainingRepositoryLibrary::UpsertCoachActionPlan( + RepositoryState, + FollowUpPlan + ); + } + + const FString UserId = + HyperTwistContractLibraryInternal::ResolveSampleRepositoryUserId(RepositoryState); + if (UserId.IsEmpty()) + { + return FHyperTwistMemoryCognitiveConsolidationState(); + } + + return UHyperTwistMemoryCoreLibrary::DeriveMemoryCognitiveConsolidationState( + RepositoryState, + UserId, + TEXT("2026-04-28T12:40:00Z") + ); +} + FHyperTwistTrainingRepositoryIntegrityReport UHyperTwistContractLibrary::MakeSampleTrainingRepositoryIntegrityReport() { FHyperTwistTrainingRepositoryState RepositoryState = MakeSampleTrainingRepositoryState(); @@ -4870,6 +4910,15 @@ FString UHyperTwistContractLibrary::SerializeMemoryRecallSharedContextStateToJso ); } +FString UHyperTwistContractLibrary::SerializeMemoryCognitiveConsolidationStateToJson( + const FHyperTwistMemoryCognitiveConsolidationState& CognitiveConsolidationState +) +{ + return HyperTwistContractLibraryInternal::SerializeStructToJson( + CognitiveConsolidationState + ); +} + FString UHyperTwistContractLibrary::SerializeTrainingTimerExportPacketToJson( const FHyperTwistTrainingTimerExportPacket& TimerExportPacket ) @@ -4959,6 +5008,17 @@ bool UHyperTwistContractLibrary::DeserializeMemoryRecallSharedContextStateFromJs ); } +bool UHyperTwistContractLibrary::DeserializeMemoryCognitiveConsolidationStateFromJson( + const FString& Json, + FHyperTwistMemoryCognitiveConsolidationState& OutCognitiveConsolidationState +) +{ + return HyperTwistContractLibraryInternal::DeserializeStructFromJson( + Json, + OutCognitiveConsolidationState + ); +} + bool UHyperTwistContractLibrary::DeserializeTrainingTimerExportPacketFromJson( const FString& Json, FHyperTwistTrainingTimerExportPacket& OutTimerExportPacket diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistMemory/HyperTwistMemoryCoreLibrary.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistMemory/HyperTwistMemoryCoreLibrary.cpp index 48822f6..4c48ae1 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistMemory/HyperTwistMemoryCoreLibrary.cpp +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Private/HyperTwistMemory/HyperTwistMemoryCoreLibrary.cpp @@ -3253,3 +3253,741 @@ FHyperTwistMemoryRecallSharedContextState return RecallState; } + +FHyperTwistMemoryCognitiveConsolidationState + UHyperTwistMemoryCoreLibrary::DeriveMemoryCognitiveConsolidationState( + const FHyperTwistTrainingRepositoryState& RepositoryState, + const FString& UserId, + const FString& ReferenceUtc + ) +{ + FHyperTwistMemoryCognitiveConsolidationState CognitiveState; + if (UserId.IsEmpty()) + { + return CognitiveState; + } + + const FString ResolvedReferenceUtc = + HyperTwistMemoryCoreLibraryInternal::ResolveReferenceUtc(ReferenceUtc); + CognitiveState.UserId = UserId; + CognitiveState.ReferenceUtc = ResolvedReferenceUtc; + + const FHyperTwistMemoryLedgerState MemoryLedgerState = DeriveMemoryLedgerState( + RepositoryState, + UserId, + ResolvedReferenceUtc + ); + + TMap LedgerEntitiesById; + for (const FHyperTwistMemoryEntityDescriptor& Entity : MemoryLedgerState.Entities) + { + LedgerEntitiesById.Add(Entity.EntityId, Entity); + } + + const FString ReviewProgramEntityId = FString::Printf( + TEXT("memory-entity/recall/review-program-summary/%s"), + *UserId + ); + const FString CoachMemoryEntityId = FString::Printf( + TEXT("memory-entity/cognitive/coach-memory-snapshot/%s"), + *UserId + ); + const FString CoachClosureEntityId = FString::Printf( + TEXT("memory-entity/cognitive/coach-closure-memory-summary/%s"), + *UserId + ); + const FString RecommendationHistoryEntityId = FString::Printf( + TEXT("memory-entity/cognitive/coach-recommendation-history-summary/%s"), + *UserId + ); + const FString CarryForwardEntityId = FString::Printf( + TEXT("memory-entity/cognitive/coach-carry-forward-policy-summary/%s"), + *UserId + ); + const FString ArchivePolicyEntityId = FString::Printf( + TEXT("memory-entity/cognitive/coach-archive-policy-summary/%s"), + *UserId + ); + + TMap FactIndexById; + + auto AppendEntityProvenanceChain = + [&LedgerEntitiesById]( + const FString& EntityId, + const FString& SourceLabel, + TArray& ProvenanceLinks) + { + if (EntityId.IsEmpty()) + { + return; + } + + HyperTwistMemoryCoreLibraryInternal::TryAppendEntityProvenance( + LedgerEntitiesById, + EntityId, + SourceLabel, + ProvenanceLinks + ); + + const FHyperTwistMemoryEntityDescriptor* Entity = LedgerEntitiesById.Find(EntityId); + if (Entity == nullptr) + { + return; + } + + for (const FHyperTwistMemoryProvenanceLink& ProvenanceLink : Entity->ProvenanceLinks) + { + HyperTwistMemoryCoreLibraryInternal::AddUniqueProvenanceLink( + ProvenanceLinks, + ProvenanceLink + ); + } + }; + + auto AddFact = + [&](const FHyperTwistMemoryCognitiveFact& Fact) + { + if (!Fact.IsStructurallyValid() || FactIndexById.Contains(Fact.FactId)) + { + return; + } + + const int32 NewIndex = CognitiveState.Facts.Add(Fact); + FactIndexById.Add(Fact.FactId, NewIndex); + }; + + auto AddContradiction = + [&](const FHyperTwistMemoryCognitiveContradiction& Contradiction) + { + if (!Contradiction.IsStructurallyValid() + || CognitiveState.Contradictions.ContainsByPredicate( + [&Contradiction]( + const FHyperTwistMemoryCognitiveContradiction& ExistingContradiction) + { + return ExistingContradiction.ContradictionId == + Contradiction.ContradictionId; + })) + { + return; + } + + CognitiveState.Contradictions.Add(Contradiction); + }; + + auto AddSupersession = + [&](const FHyperTwistMemoryCognitiveSupersession& Supersession) + { + if (!Supersession.IsStructurallyValid() + || CognitiveState.Supersessions.ContainsByPredicate( + [&Supersession]( + const FHyperTwistMemoryCognitiveSupersession& ExistingSupersession) + { + return ExistingSupersession.SupersessionId == + Supersession.SupersessionId; + })) + { + return; + } + + CognitiveState.Supersessions.Add(Supersession); + }; + + auto AddConfidenceDecay = + [&](const FHyperTwistMemoryConfidenceDecayEntry& ConfidenceDecay) + { + if (!ConfidenceDecay.IsStructurallyValid() + || CognitiveState.ConfidenceDecays.ContainsByPredicate( + [&ConfidenceDecay]( + const FHyperTwistMemoryConfidenceDecayEntry& ExistingDecay) + { + return ExistingDecay.DecayId == ConfidenceDecay.DecayId; + })) + { + return; + } + + CognitiveState.ConfidenceDecays.Add(ConfidenceDecay); + }; + + auto ClampConfidence = [](const int32 Score) + { + return FMath::Clamp(Score, 0, 100); + }; + + auto MakeFact = + [&]( + const FString& FactId, + const FString& FactFamily, + const FString& FactKind, + const FString& Headline, + const FString& DeckId, + const TArray& SourceEntityIds, + const FString& SummaryLine, + const int32 ConfidenceScore, + const int32 EvidenceCount) + { + FHyperTwistMemoryCognitiveFact Fact; + Fact.FactId = FactId; + Fact.FactFamily = FactFamily; + Fact.FactKind = FactKind; + Fact.Headline = Headline; + Fact.UserId = UserId; + Fact.DeckId = DeckId; + Fact.ReferenceUtc = ResolvedReferenceUtc; + Fact.SourceEntityIds = SourceEntityIds; + Fact.SummaryLine = SummaryLine; + Fact.ConfidenceScore = ClampConfidence(ConfidenceScore); + Fact.EvidenceCount = FMath::Max(1, EvidenceCount); + Fact.bActive = true; + for (const FString& SourceEntityId : SourceEntityIds) + { + AppendEntityProvenanceChain( + SourceEntityId, + FactFamily, + Fact.ProvenanceLinks + ); + } + + return Fact; + }; + + auto ResolveFactPolarity = [](const FString& FactKind) + { + if (FactKind.Contains(TEXT("active")) + || FactKind.Contains(TEXT("risk")) + || FactKind.Contains(TEXT("persistent"))) + { + return 1; + } + if (FactKind.Contains(TEXT("stable")) + || FactKind.Contains(TEXT("settled")) + || FactKind.Contains(TEXT("stabilized"))) + { + return -1; + } + + return 0; + }; + + auto RegisterFactContradiction = + [&]( + const FString& FactFamily, + const FHyperTwistMemoryCognitiveFact& LeftFact, + const FHyperTwistMemoryCognitiveFact& RightFact) + { + FHyperTwistMemoryCognitiveContradiction Contradiction; + Contradiction.ContradictionId = FString::Printf( + TEXT("memory-cognitive-contradiction/%s/%s"), + *FactFamily, + *UserId + ); + Contradiction.FactFamily = FactFamily; + Contradiction.Headline = FString::Printf( + TEXT("Conflicting cognitive signals exist for %s"), + *FactFamily.Replace(TEXT("-"), TEXT(" ")) + ); + Contradiction.UserId = UserId; + Contradiction.ReferenceUtc = ResolvedReferenceUtc; + Contradiction.LeftFactId = LeftFact.FactId; + Contradiction.RightFactId = RightFact.FactId; + Contradiction.ResolutionLabel = + TEXT("Prefer the higher-confidence signal while keeping contradiction review explicit."); + Contradiction.bBlocksPromotion = true; + Contradiction.bNeedsManualReview = true; + Contradiction.ProvenanceLinks = LeftFact.ProvenanceLinks; + for (const FHyperTwistMemoryProvenanceLink& ProvenanceLink : RightFact.ProvenanceLinks) + { + HyperTwistMemoryCoreLibraryInternal::AddUniqueProvenanceLink( + Contradiction.ProvenanceLinks, + ProvenanceLink + ); + } + AddContradiction(Contradiction); + + if (const int32* LeftIndex = FactIndexById.Find(LeftFact.FactId)) + { + HyperTwistMemoryCoreLibraryInternal::AddUniqueString( + CognitiveState.Facts[*LeftIndex].ContradictionIds, + Contradiction.ContradictionId + ); + CognitiveState.Facts[*LeftIndex].bRequiresReview = true; + } + if (const int32* RightIndex = FactIndexById.Find(RightFact.FactId)) + { + HyperTwistMemoryCoreLibraryInternal::AddUniqueString( + CognitiveState.Facts[*RightIndex].ContradictionIds, + Contradiction.ContradictionId + ); + CognitiveState.Facts[*RightIndex].bRequiresReview = true; + } + + const FHyperTwistMemoryCognitiveFact* Winner = + LeftFact.ConfidenceScore >= RightFact.ConfidenceScore + ? &LeftFact + : &RightFact; + const FHyperTwistMemoryCognitiveFact* Loser = + Winner == &LeftFact ? &RightFact : &LeftFact; + + if (FMath::Abs(LeftFact.ConfidenceScore - RightFact.ConfidenceScore) >= 5) + { + FHyperTwistMemoryCognitiveSupersession Supersession; + Supersession.SupersessionId = FString::Printf( + TEXT("memory-cognitive-supersession/%s/%s/%s"), + *FactFamily, + *Loser->FactId, + *UserId + ); + Supersession.FactFamily = FactFamily; + Supersession.UserId = UserId; + Supersession.ReferenceUtc = ResolvedReferenceUtc; + Supersession.PriorFactId = Loser->FactId; + Supersession.CurrentFactId = Winner->FactId; + Supersession.ReasonLabel = + TEXT("Higher-confidence current signal supersedes the weaker stale derived conclusion."); + Supersession.bResolvedByHigherConfidence = true; + Supersession.ProvenanceLinks = Loser->ProvenanceLinks; + for (const FHyperTwistMemoryProvenanceLink& ProvenanceLink : Winner->ProvenanceLinks) + { + HyperTwistMemoryCoreLibraryInternal::AddUniqueProvenanceLink( + Supersession.ProvenanceLinks, + ProvenanceLink + ); + } + AddSupersession(Supersession); + + if (const int32* LoserIndex = FactIndexById.Find(Loser->FactId)) + { + CognitiveState.Facts[*LoserIndex].SupersededByFactId = Winner->FactId; + CognitiveState.Facts[*LoserIndex].bActive = false; + CognitiveState.Facts[*LoserIndex].bRequiresReview = true; + } + } + }; + + auto ApplyFactDecay = + [&](const FString& FactId, const FString& TriggerLabel, const int32 Penalty) + { + const int32* FactIndex = FactIndexById.Find(FactId); + if (FactIndex == nullptr || Penalty <= 0) + { + return; + } + + FHyperTwistMemoryCognitiveFact& Fact = CognitiveState.Facts[*FactIndex]; + const int32 PreviousConfidence = Fact.ConfidenceScore; + const int32 CurrentConfidence = + ClampConfidence(Fact.ConfidenceScore - Penalty); + if (CurrentConfidence >= PreviousConfidence) + { + return; + } + + FHyperTwistMemoryConfidenceDecayEntry DecayEntry; + DecayEntry.DecayId = FString::Printf( + TEXT("memory-confidence-decay/%s/%s"), + *Fact.FactId, + *TriggerLabel.Replace(TEXT(" "), TEXT("-")) + ); + DecayEntry.FactId = Fact.FactId; + DecayEntry.UserId = UserId; + DecayEntry.ReferenceUtc = ResolvedReferenceUtc; + DecayEntry.TriggerLabel = TriggerLabel; + DecayEntry.PreviousConfidenceScore = PreviousConfidence; + DecayEntry.CurrentConfidenceScore = CurrentConfidence; + DecayEntry.bBelowPromotionThreshold = CurrentConfidence < 50; + DecayEntry.ProvenanceLinks = Fact.ProvenanceLinks; + AddConfidenceDecay(DecayEntry); + + Fact.ConfidenceScore = CurrentConfidence; + Fact.bRequiresReview = true; + }; + + const FHyperTwistTrainingReviewProgramSummary ReviewProgramSummary = + UHyperTwistTrainingRepositoryLibrary::DeriveReviewProgramSummary( + RepositoryState, + UserId, + ResolvedReferenceUtc + ); + const FHyperTwistTrainingCoachMemorySnapshot CoachMemorySnapshot = + UHyperTwistTrainingRepositoryLibrary::DeriveCoachMemorySnapshot( + RepositoryState, + UserId, + ResolvedReferenceUtc + ); + const FHyperTwistTrainingCoachClosureMemorySummary CoachClosureSummary = + UHyperTwistTrainingRepositoryLibrary::DeriveCoachClosureMemorySummary( + RepositoryState, + UserId, + ResolvedReferenceUtc + ); + const FHyperTwistTrainingCoachRecommendationHistorySummary RecommendationHistorySummary = + UHyperTwistTrainingRepositoryLibrary::DeriveCoachRecommendationHistorySummary( + RepositoryState, + UserId, + ResolvedReferenceUtc + ); + const FHyperTwistTrainingCoachCarryForwardPolicySummary CarryForwardSummary = + UHyperTwistTrainingRepositoryLibrary::DeriveCoachCarryForwardPolicySummary( + RepositoryState, + UserId, + ResolvedReferenceUtc + ); + const FHyperTwistTrainingCoachArchivePolicySummary ArchivePolicySummary = + UHyperTwistTrainingRepositoryLibrary::DeriveCoachArchivePolicySummary( + RepositoryState, + UserId, + ResolvedReferenceUtc + ); + + if (ReviewProgramSummary.IsStructurallyValid()) + { + const bool bHasActiveReviewPressure = + ReviewProgramSummary.PendingPlanCount > 0 + || ReviewProgramSummary.ProgramPressureScore >= 0.2f + || ReviewProgramSummary.CarryoverCaseCount > 0; + if (bHasActiveReviewPressure) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/review-pressure-active/%s"), *UserId), + TEXT("review-pressure"), + TEXT("active-review-pressure"), + TEXT("Review pressure remains active"), + ReviewProgramSummary.FocusDeckId, + {ReviewProgramEntityId}, + TEXT("Open review plans and carryover still require active attention."), + 60 + ReviewProgramSummary.PendingPlanCount * 4 + + FMath::RoundToInt(ReviewProgramSummary.ProgramPressureScore * 10.0f), + FMath::Max(1, ReviewProgramSummary.PendingPlanCount + ReviewProgramSummary.CarryoverCaseCount) + )); + } + + if (ReviewProgramSummary.CompletedPlanCount > 0 + && ReviewProgramSummary.AveragePlanProgressRatio >= 0.5f) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/review-pressure-stabilized/%s"), *UserId), + TEXT("review-pressure"), + TEXT("stabilized-review-pressure"), + TEXT("Review program shows stabilization"), + ReviewProgramSummary.FocusDeckId, + {ReviewProgramEntityId}, + TEXT("Completed review work and sustained progress indicate a stabilizing review posture."), + 52 + ReviewProgramSummary.CompletedPlanCount * 4 + + FMath::RoundToInt(ReviewProgramSummary.AveragePlanProgressRatio * 12.0f), + FMath::Max(1, ReviewProgramSummary.CompletedPlanCount) + )); + } + } + + if (CoachClosureSummary.IsStructurallyValid() || RecommendationHistorySummary.IsStructurallyValid()) + { + const bool bHasActiveFollowUpPressure = + CoachClosureSummary.bHasFollowUpPressure + || RecommendationHistorySummary.FollowUpReadySequenceCount > 0 + || RecommendationHistorySummary.FollowUpLanePlanCount > 0 + || CoachMemorySnapshot.PendingReviewPlanIds.Num() > 0 + || CoachMemorySnapshot.SchedulePressureCaseIds.Num() > 0; + if (bHasActiveFollowUpPressure) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/follow-up-active/%s"), *UserId), + TEXT("follow-up-posture"), + TEXT("active-follow-up-pressure"), + TEXT("Coach follow-up pressure remains active"), + !CoachClosureSummary.FocusDeckId.IsEmpty() + ? CoachClosureSummary.FocusDeckId + : RecommendationHistorySummary.FocusDeckId, + {CoachClosureEntityId, RecommendationHistoryEntityId}, + TEXT("Follow-up-ready sequences and recommendation history still signal unresolved coaching pressure."), + 62 + CoachClosureSummary.FollowUpReadySequenceCount * 3 + + RecommendationHistorySummary.FollowUpReadySequenceCount * 3, + FMath::Max(1, CoachClosureSummary.FollowUpReadySequenceCount + + RecommendationHistorySummary.FollowUpReadySequenceCount + + RecommendationHistorySummary.FollowUpLanePlanCount + + CoachMemorySnapshot.PendingReviewPlanIds.Num() + + CoachMemorySnapshot.SchedulePressureCaseIds.Num()) + )); + } + + if ((CoachClosureSummary.ClosedSequenceCount > CoachClosureSummary.EscalatedSequenceCount + && CoachClosureSummary.ArchivedResolvedCaseCount > 0) + || CoachMemorySnapshot.ArchivedResolvedCaseIds.Num() > 0) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/follow-up-stabilized/%s"), *UserId), + TEXT("follow-up-posture"), + TEXT("stabilized-follow-up-posture"), + TEXT("Coach follow-up posture shows stabilization"), + CoachClosureSummary.FocusDeckId, + {CoachClosureEntityId, RecommendationHistoryEntityId}, + TEXT("Closed sequences and archived resolved cases indicate a stabilizing follow-up posture."), + 55 + CoachClosureSummary.ClosedSequenceCount * 3 + + FMath::RoundToInt(CoachClosureSummary.AverageClosureScore * 10.0f), + FMath::Max(1, CoachClosureSummary.ClosedSequenceCount + + CoachClosureSummary.ArchivedResolvedCaseCount + + CoachMemorySnapshot.ArchivedResolvedCaseIds.Num()) + )); + } + } + + { + const bool bHasActiveCarryForward = + CarryForwardSummary.bHasActiveCarryForwardPressure + || CarryForwardSummary.PinnedCarryForwardCaseCount > 0 + || CarryForwardSummary.RecurringCarryForwardCaseCount > 0 + || CarryForwardSummary.EscalationCarryForwardCaseCount > 0; + if (bHasActiveCarryForward) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/carry-forward-active/%s"), *UserId), + TEXT("carry-forward-posture"), + TEXT("active-carry-forward-pressure"), + TEXT("Carry-forward pressure remains active"), + CarryForwardSummary.FocusDeckId, + {CarryForwardEntityId, CoachMemoryEntityId}, + TEXT("Pinned, recurring, or escalation carry-forward cases still require durable attention."), + 60 + CarryForwardSummary.PinnedCarryForwardCaseCount * 4 + + CarryForwardSummary.EscalationCarryForwardCaseCount * 5, + FMath::Max(1, CarryForwardSummary.PinnedCarryForwardCaseCount + + CarryForwardSummary.RecurringCarryForwardCaseCount + + CarryForwardSummary.EscalationCarryForwardCaseCount) + )); + } + + if (CarryForwardSummary.SuppressedResolvedCaseCount > 0) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/carry-forward-settled/%s"), *UserId), + TEXT("carry-forward-posture"), + TEXT("settled-carry-forward-posture"), + TEXT("Carry-forward posture shows settled resolved work"), + CarryForwardSummary.FocusDeckId, + {CarryForwardEntityId, CoachMemoryEntityId}, + TEXT("Suppressed resolved resurfacing indicates older carry-forward pressure has partially settled."), + 54 + CarryForwardSummary.SuppressedResolvedCaseCount * 4, + FMath::Max(1, CarryForwardSummary.SuppressedResolvedCaseCount) + )); + } + } + + { + const bool bHasArchiveRisk = + ArchivePolicySummary.ReopenRiskArchivedCaseCount > 0 + || ArchivePolicySummary.EscalationRetainedCaseCount > 0 + || ArchivePolicySummary.RetainedCarryForwardCaseCount > 0; + if (bHasArchiveRisk) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/archive-risk/%s"), *UserId), + TEXT("archive-posture"), + TEXT("archive-reopen-risk"), + TEXT("Archived work still carries reopen risk"), + ArchivePolicySummary.FocusDeckId, + {ArchivePolicyEntityId, CoachMemoryEntityId}, + TEXT("Reopen-risk and retained carry-forward cases show that archived conclusions are not fully settled."), + 58 + ArchivePolicySummary.ReopenRiskArchivedCaseCount * 5 + + ArchivePolicySummary.EscalationRetainedCaseCount * 4, + FMath::Max(1, ArchivePolicySummary.ReopenRiskArchivedCaseCount + + ArchivePolicySummary.EscalationRetainedCaseCount + + ArchivePolicySummary.RetainedCarryForwardCaseCount) + )); + } + + if (ArchivePolicySummary.StableLongTermArchivedCaseCount > 0 + || ArchivePolicySummary.LongTermArchivedCaseCount > 0) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/archive-stable/%s"), *UserId), + TEXT("archive-posture"), + TEXT("stable-archive-posture"), + TEXT("Archived work shows stable long-term resolution"), + ArchivePolicySummary.FocusDeckId, + {ArchivePolicyEntityId, CoachMemoryEntityId}, + TEXT("Stable long-term archived cases indicate settled closure over older coaching work."), + 53 + ArchivePolicySummary.StableLongTermArchivedCaseCount * 4, + FMath::Max(1, ArchivePolicySummary.StableLongTermArchivedCaseCount + + ArchivePolicySummary.LongTermArchivedCaseCount) + )); + } + } + + if (!CoachMemorySnapshot.UserId.IsEmpty()) + { + if (CoachMemorySnapshot.PersistentCoachWeakCaseIds.Num() > 0 + || CoachMemorySnapshot.EscalationCaseIds.Num() > 0) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/weak-case-persistent/%s"), *UserId), + TEXT("weak-case-posture"), + TEXT("persistent-weak-case-pressure"), + TEXT("Persistent weak-case pressure remains visible"), + CoachMemorySnapshot.FocusDeckId, + {CoachMemoryEntityId}, + TEXT("Persistent weak cases and escalation cases continue to shape long-term coach memory."), + 57 + CoachMemorySnapshot.PersistentCoachWeakCaseIds.Num() * 3 + + CoachMemorySnapshot.EscalationCaseIds.Num() * 4, + FMath::Max(1, CoachMemorySnapshot.PersistentCoachWeakCaseIds.Num() + + CoachMemorySnapshot.EscalationCaseIds.Num()) + )); + } + + if (CoachMemorySnapshot.ArchivedResolvedCaseIds.Num() > 0 + && CoachMemorySnapshot.PersistentCoachWeakCaseIds.Num() == 0) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/weak-case-stable/%s"), *UserId), + TEXT("weak-case-posture"), + TEXT("stable-weak-case-posture"), + TEXT("Weak-case posture has stabilized"), + CoachMemorySnapshot.FocusDeckId, + {CoachMemoryEntityId}, + TEXT("Archived resolved coach cases remain while persistent weak-case pressure has cleared."), + 51 + CoachMemorySnapshot.ArchivedResolvedCaseIds.Num() * 3, + FMath::Max(1, CoachMemorySnapshot.ArchivedResolvedCaseIds.Num()) + )); + } + } + + if (RecommendationHistorySummary.IsStructurallyValid() + && RecommendationHistorySummary.PreferredGuidanceLane + != EHyperTwistTrainingCoachGuidanceLane::None) + { + AddFact(MakeFact( + FString::Printf(TEXT("memory-cognitive-fact/guidance-dominant/%s"), *UserId), + TEXT("guidance-posture"), + TEXT("dominant-guidance-lane"), + TEXT("Current coach guidance lane is stable enough to retain"), + RecommendationHistorySummary.FocusDeckId, + {RecommendationHistoryEntityId}, + TEXT("Recommendation history exposes a dominant guidance lane worth retaining as bounded coach memory."), + 56 + RecommendationHistorySummary.PlanCount * 2, + FMath::Max(1, RecommendationHistorySummary.PlanCount) + )); + } + + TMap> FactIdsByFamily; + for (const FHyperTwistMemoryCognitiveFact& Fact : CognitiveState.Facts) + { + FactIdsByFamily.FindOrAdd(Fact.FactFamily).Add(Fact.FactId); + } + + for (const TPair>& FamilyPair : FactIdsByFamily) + { + const FString& FactFamily = FamilyPair.Key; + const TArray& FamilyFactIds = FamilyPair.Value; + + const FHyperTwistMemoryCognitiveFact* PositiveFact = nullptr; + const FHyperTwistMemoryCognitiveFact* NegativeFact = nullptr; + for (const FString& FactId : FamilyFactIds) + { + const int32* FactIndex = FactIndexById.Find(FactId); + if (FactIndex == nullptr) + { + continue; + } + + const FHyperTwistMemoryCognitiveFact& Fact = CognitiveState.Facts[*FactIndex]; + const int32 Polarity = ResolveFactPolarity(Fact.FactKind); + if (Polarity > 0 + && (PositiveFact == nullptr || Fact.ConfidenceScore > PositiveFact->ConfidenceScore)) + { + PositiveFact = &Fact; + } + else if ( + Polarity < 0 + && (NegativeFact == nullptr || Fact.ConfidenceScore > NegativeFact->ConfidenceScore)) + { + NegativeFact = &Fact; + } + } + + if (PositiveFact == nullptr || NegativeFact == nullptr) + { + continue; + } + + RegisterFactContradiction(FactFamily, *PositiveFact, *NegativeFact); + } + + if (CognitiveState.Contradictions.Num() == 0) + { + const FHyperTwistMemoryCognitiveFact* ActiveFact = nullptr; + const FHyperTwistMemoryCognitiveFact* StableFact = nullptr; + for (const FHyperTwistMemoryCognitiveFact& Fact : CognitiveState.Facts) + { + const int32 Polarity = ResolveFactPolarity(Fact.FactKind); + if (Polarity > 0 && ActiveFact == nullptr) + { + ActiveFact = &Fact; + } + else if (Polarity < 0 && StableFact == nullptr) + { + StableFact = &Fact; + } + } + + if (ActiveFact != nullptr && StableFact != nullptr) + { + RegisterFactContradiction( + TEXT("mixed-coaching-horizon"), + *ActiveFact, + *StableFact + ); + } + } + + for (FHyperTwistMemoryCognitiveFact& Fact : CognitiveState.Facts) + { + if (!HyperTwistMemoryCoreLibraryInternal::HasAuthoritativeProvenance(Fact.ProvenanceLinks)) + { + ApplyFactDecay(Fact.FactId, TEXT("no-direct-authoritative-lineage"), 8); + } + if (Fact.ContradictionIds.Num() > 0) + { + ApplyFactDecay(Fact.FactId, TEXT("contradiction-review"), 15); + } + if (!Fact.SupersededByFactId.IsEmpty()) + { + ApplyFactDecay(Fact.FactId, TEXT("superseded-derived-conclusion"), 25); + } + } + + for (const FHyperTwistMemoryCognitiveFact& Fact : CognitiveState.Facts) + { + if (Fact.bActive) + { + ++CognitiveState.ActiveFactCount; + } + if (!Fact.SupersededByFactId.IsEmpty()) + { + ++CognitiveState.SupersededFactCount; + } + if (Fact.ConfidenceScore < 50) + { + ++CognitiveState.LowConfidenceFactCount; + } + if (Fact.bRequiresReview) + { + CognitiveState.bHasOpenCognitiveReview = true; + } + } + + CognitiveState.ContradictionCount = CognitiveState.Contradictions.Num(); + if (!CognitiveState.bHasOpenCognitiveReview) + { + CognitiveState.bHasOpenCognitiveReview = + CognitiveState.Contradictions.ContainsByPredicate( + [](const FHyperTwistMemoryCognitiveContradiction& Contradiction) + { + return Contradiction.bNeedsManualReview; + } + ); + } + + if (!CognitiveState.IsStructurallyValid()) + { + return FHyperTwistMemoryCognitiveConsolidationState(); + } + + return CognitiveState; +} diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistBootstrap/HyperTwistContractLibrary.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistBootstrap/HyperTwistContractLibrary.h index 0964f21..29ca017 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistBootstrap/HyperTwistContractLibrary.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistBootstrap/HyperTwistContractLibrary.h @@ -153,6 +153,10 @@ public: static FHyperTwistMemoryRecallSharedContextState MakeSampleTrainingMemoryRecallSharedContextState(); + UFUNCTION(BlueprintPure, Category = "HyperTwist|Memory") + static FHyperTwistMemoryCognitiveConsolidationState + MakeSampleTrainingMemoryCognitiveConsolidationState(); + UFUNCTION(BlueprintPure, Category = "HyperTwist|Training") static FHyperTwistTrainingRepositoryIntegrityReport MakeSampleTrainingRepositoryIntegrityReport(); @@ -327,6 +331,11 @@ public: const FHyperTwistMemoryRecallSharedContextState& RecallSharedContextState ); + UFUNCTION(BlueprintPure, Category = "HyperTwist|Serialization") + static FString SerializeMemoryCognitiveConsolidationStateToJson( + const FHyperTwistMemoryCognitiveConsolidationState& CognitiveConsolidationState + ); + UFUNCTION(BlueprintPure, Category = "HyperTwist|Serialization") static FString SerializeTrainingTimerExportPacketToJson(const FHyperTwistTrainingTimerExportPacket& TimerExportPacket); @@ -381,6 +390,12 @@ public: FHyperTwistMemoryRecallSharedContextState& OutRecallSharedContextState ); + UFUNCTION(BlueprintCallable, Category = "HyperTwist|Serialization") + static bool DeserializeMemoryCognitiveConsolidationStateFromJson( + const FString& Json, + FHyperTwistMemoryCognitiveConsolidationState& OutCognitiveConsolidationState + ); + UFUNCTION(BlueprintCallable, Category = "HyperTwist|Serialization") static bool DeserializeTrainingTimerExportPacketFromJson(const FString& Json, FHyperTwistTrainingTimerExportPacket& OutTimerExportPacket); }; diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryCoreLibrary.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryCoreLibrary.h index 38660cf..864087a 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryCoreLibrary.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryCoreLibrary.h @@ -33,4 +33,11 @@ public: const FString& ReferenceUtc, const FString& QueryText ); + + UFUNCTION(BlueprintPure, Category = "HyperTwist|Memory") + static FHyperTwistMemoryCognitiveConsolidationState DeriveMemoryCognitiveConsolidationState( + const FHyperTwistTrainingRepositoryState& RepositoryState, + const FString& UserId, + const FString& ReferenceUtc + ); }; diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryTypes.h b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryTypes.h index a935750..c899ffa 100644 --- a/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryTypes.h +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Public/HyperTwistMemory/HyperTwistMemoryTypes.h @@ -1120,3 +1120,398 @@ struct FHyperTwistMemoryRecallSharedContextState && bHasScopedSharedContext == (SharedContextProjections.Num() > 0); } }; + +USTRUCT(BlueprintType) +struct FHyperTwistMemoryCognitiveFact +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString FactId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString FactFamily; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString FactKind; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString Headline; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString UserId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString DeckId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ReferenceUtc; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + EHyperTwistMemoryLane Lane = EHyperTwistMemoryLane::CognitiveConsolidated; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + EHyperTwistMemoryAuthorityKind AuthorityKind = + EHyperTwistMemoryAuthorityKind::SemiAuthoritative; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray SourceEntityIds; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString SummaryLine; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 ConfidenceScore = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 EvidenceCount = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + bool bActive = false; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + bool bRequiresReview = false; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString SupersededByFactId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray ContradictionIds; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray ProvenanceLinks; + + bool IsStructurallyValid() const + { + if (FactId.IsEmpty() + || FactFamily.IsEmpty() + || FactKind.IsEmpty() + || Headline.IsEmpty() + || UserId.IsEmpty() + || ReferenceUtc.IsEmpty() + || Lane != EHyperTwistMemoryLane::CognitiveConsolidated + || AuthorityKind == EHyperTwistMemoryAuthorityKind::None + || SourceEntityIds.Num() == 0 + || SummaryLine.IsEmpty() + || ConfidenceScore < 0 + || ConfidenceScore > 100 + || EvidenceCount <= 0 + || ProvenanceLinks.Num() == 0) + { + return false; + } + + for (const FHyperTwistMemoryProvenanceLink& ProvenanceLink : ProvenanceLinks) + { + if (!ProvenanceLink.IsStructurallyValid()) + { + return false; + } + } + + return true; + } +}; + +USTRUCT(BlueprintType) +struct FHyperTwistMemoryCognitiveContradiction +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ContradictionId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString FactFamily; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString Headline; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString UserId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ReferenceUtc; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString LeftFactId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString RightFactId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ResolutionLabel; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + bool bBlocksPromotion = false; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + bool bNeedsManualReview = false; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray ProvenanceLinks; + + bool IsStructurallyValid() const + { + if (ContradictionId.IsEmpty() + || FactFamily.IsEmpty() + || Headline.IsEmpty() + || UserId.IsEmpty() + || ReferenceUtc.IsEmpty() + || LeftFactId.IsEmpty() + || RightFactId.IsEmpty() + || ResolutionLabel.IsEmpty() + || ProvenanceLinks.Num() == 0) + { + return false; + } + + for (const FHyperTwistMemoryProvenanceLink& ProvenanceLink : ProvenanceLinks) + { + if (!ProvenanceLink.IsStructurallyValid()) + { + return false; + } + } + + return true; + } +}; + +USTRUCT(BlueprintType) +struct FHyperTwistMemoryCognitiveSupersession +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString SupersessionId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString FactFamily; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString UserId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ReferenceUtc; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString PriorFactId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString CurrentFactId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ReasonLabel; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + bool bResolvedByHigherConfidence = false; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray ProvenanceLinks; + + bool IsStructurallyValid() const + { + if (SupersessionId.IsEmpty() + || FactFamily.IsEmpty() + || UserId.IsEmpty() + || ReferenceUtc.IsEmpty() + || PriorFactId.IsEmpty() + || CurrentFactId.IsEmpty() + || ReasonLabel.IsEmpty() + || ProvenanceLinks.Num() == 0) + { + return false; + } + + for (const FHyperTwistMemoryProvenanceLink& ProvenanceLink : ProvenanceLinks) + { + if (!ProvenanceLink.IsStructurallyValid()) + { + return false; + } + } + + return true; + } +}; + +USTRUCT(BlueprintType) +struct FHyperTwistMemoryConfidenceDecayEntry +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString DecayId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString FactId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString UserId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ReferenceUtc; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString TriggerLabel; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 PreviousConfidenceScore = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 CurrentConfidenceScore = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + bool bBelowPromotionThreshold = false; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray ProvenanceLinks; + + bool IsStructurallyValid() const + { + if (DecayId.IsEmpty() + || FactId.IsEmpty() + || UserId.IsEmpty() + || ReferenceUtc.IsEmpty() + || TriggerLabel.IsEmpty() + || PreviousConfidenceScore < 0 + || PreviousConfidenceScore > 100 + || CurrentConfidenceScore < 0 + || CurrentConfidenceScore > 100 + || CurrentConfidenceScore >= PreviousConfidenceScore + || ProvenanceLinks.Num() == 0) + { + return false; + } + + for (const FHyperTwistMemoryProvenanceLink& ProvenanceLink : ProvenanceLinks) + { + if (!ProvenanceLink.IsStructurallyValid()) + { + return false; + } + } + + return true; + } +}; + +USTRUCT(BlueprintType) +struct FHyperTwistMemoryCognitiveConsolidationState +{ + GENERATED_BODY() + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString UserId; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + FString ReferenceUtc; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray Facts; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray Contradictions; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray Supersessions; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + TArray ConfidenceDecays; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 ActiveFactCount = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 SupersededFactCount = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 ContradictionCount = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + int32 LowConfidenceFactCount = 0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HyperTwist") + bool bHasOpenCognitiveReview = false; + + bool IsStructurallyValid() const + { + if (UserId.IsEmpty() || ReferenceUtc.IsEmpty() || Facts.Num() == 0) + { + return false; + } + + for (const FHyperTwistMemoryCognitiveFact& Fact : Facts) + { + if (!Fact.IsStructurallyValid()) + { + return false; + } + } + + for (const FHyperTwistMemoryCognitiveContradiction& Contradiction : Contradictions) + { + if (!Contradiction.IsStructurallyValid()) + { + return false; + } + } + + for (const FHyperTwistMemoryCognitiveSupersession& Supersession : Supersessions) + { + if (!Supersession.IsStructurallyValid()) + { + return false; + } + } + + for (const FHyperTwistMemoryConfidenceDecayEntry& ConfidenceDecay : + ConfidenceDecays) + { + if (!ConfidenceDecay.IsStructurallyValid()) + { + return false; + } + } + + int32 ComputedActiveFactCount = 0; + int32 ComputedSupersededFactCount = 0; + int32 ComputedLowConfidenceFactCount = 0; + bool bComputedOpenCognitiveReview = false; + + for (const FHyperTwistMemoryCognitiveFact& Fact : Facts) + { + if (Fact.bActive) + { + ++ComputedActiveFactCount; + } + if (!Fact.SupersededByFactId.IsEmpty()) + { + ++ComputedSupersededFactCount; + } + if (Fact.ConfidenceScore < 50) + { + ++ComputedLowConfidenceFactCount; + } + if (Fact.bRequiresReview) + { + bComputedOpenCognitiveReview = true; + } + } + + for (const FHyperTwistMemoryCognitiveContradiction& Contradiction : Contradictions) + { + if (Contradiction.bNeedsManualReview) + { + bComputedOpenCognitiveReview = true; + } + } + + return ActiveFactCount == ComputedActiveFactCount + && SupersededFactCount == ComputedSupersededFactCount + && ContradictionCount == Contradictions.Num() + && LowConfidenceFactCount == ComputedLowConfidenceFactCount + && bHasOpenCognitiveReview == bComputedOpenCognitiveReview; + } +}; diff --git a/UnrealHyperTwist/Source/UnrealHyperTwist/Tests/HyperTwistMemoryPhase6RM4CognitiveConsolidationContractTest.cpp b/UnrealHyperTwist/Source/UnrealHyperTwist/Tests/HyperTwistMemoryPhase6RM4CognitiveConsolidationContractTest.cpp new file mode 100644 index 0000000..d74301a --- /dev/null +++ b/UnrealHyperTwist/Source/UnrealHyperTwist/Tests/HyperTwistMemoryPhase6RM4CognitiveConsolidationContractTest.cpp @@ -0,0 +1,208 @@ +// Copyright HyperTwist, Inc. All Rights Reserved. + +#include "Misc/AutomationTest.h" + +#include "HyperTwistBootstrap/HyperTwistContractLibrary.h" + +#if WITH_AUTOMATION_TESTS + +namespace HyperTwistMemoryPhase6RM4TestInternal +{ + const FHyperTwistMemoryCognitiveFact* FindFactByFamily( + const FHyperTwistMemoryCognitiveConsolidationState& CognitiveState, + const FString& FactFamily + ) + { + for (const FHyperTwistMemoryCognitiveFact& Fact : CognitiveState.Facts) + { + if (Fact.FactFamily == FactFamily) + { + return &Fact; + } + } + + return nullptr; + } + + const FHyperTwistMemoryCognitiveFact* FindFactByKind( + const FHyperTwistMemoryCognitiveConsolidationState& CognitiveState, + const FString& FactKind + ) + { + for (const FHyperTwistMemoryCognitiveFact& Fact : CognitiveState.Facts) + { + if (Fact.FactKind == FactKind) + { + return &Fact; + } + } + + return nullptr; + } +} + +IMPLEMENT_SIMPLE_AUTOMATION_TEST( + FHyperTwistMemoryPhase6RM4FactExtractionTest, + "HyperTwist.FirstParty.Memory.Phase6R.M4.FactExtraction", + EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter +) + +bool FHyperTwistMemoryPhase6RM4FactExtractionTest::RunTest(const FString& Parameters) +{ + const FHyperTwistMemoryCognitiveConsolidationState CognitiveState = + UHyperTwistContractLibrary::MakeSampleTrainingMemoryCognitiveConsolidationState(); + + TestTrue( + TEXT("The Phase 6R-M4 cognitive consolidation state must be structurally valid."), + CognitiveState.IsStructurallyValid() + ); + TestTrue( + TEXT("The M4 state must expose bounded cognitive facts."), + CognitiveState.Facts.Num() >= 5 + ); + TestTrue( + TEXT("The M4 state must expose active cognitive facts."), + CognitiveState.ActiveFactCount > 0 + ); + + const FHyperTwistMemoryCognitiveFact* FollowUpFact = + HyperTwistMemoryPhase6RM4TestInternal::FindFactByFamily( + CognitiveState, + TEXT("follow-up-posture") + ); + TestNotNull(TEXT("A follow-up-posture cognitive fact must exist."), FollowUpFact); + if (FollowUpFact != nullptr) + { + TestEqual( + TEXT("The follow-up-posture fact must stay in the cognitive lane."), + FollowUpFact->Lane, + EHyperTwistMemoryLane::CognitiveConsolidated + ); + TestTrue( + TEXT("The follow-up-posture fact must preserve provenance links."), + FollowUpFact->ProvenanceLinks.Num() > 0 + ); + } + + const FHyperTwistMemoryCognitiveFact* ArchiveFact = + HyperTwistMemoryPhase6RM4TestInternal::FindFactByFamily( + CognitiveState, + TEXT("archive-posture") + ); + TestNotNull(TEXT("An archive-posture cognitive fact must exist."), ArchiveFact); + + return true; +} + +IMPLEMENT_SIMPLE_AUTOMATION_TEST( + FHyperTwistMemoryPhase6RM4ContradictionSupersessionTest, + "HyperTwist.FirstParty.Memory.Phase6R.M4.ContradictionSupersession", + EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter +) + +bool FHyperTwistMemoryPhase6RM4ContradictionSupersessionTest::RunTest(const FString& Parameters) +{ + const FHyperTwistMemoryCognitiveConsolidationState CognitiveState = + UHyperTwistContractLibrary::MakeSampleTrainingMemoryCognitiveConsolidationState(); + + TestTrue( + TEXT("The Phase 6R-M4 cognitive consolidation state must be structurally valid."), + CognitiveState.IsStructurallyValid() + ); + TestTrue( + TEXT("The M4 state must expose contradiction records."), + CognitiveState.Contradictions.Num() > 0 + ); + TestTrue( + TEXT("The M4 state must expose supersession records."), + CognitiveState.Supersessions.Num() > 0 + ); + TestTrue( + TEXT("The M4 state must expose confidence-decay records."), + CognitiveState.ConfidenceDecays.Num() > 0 + ); + TestTrue( + TEXT("The M4 state must report open cognitive review."), + CognitiveState.bHasOpenCognitiveReview + ); + + bool bHasExplicitlyReviewedFact = false; + for (const FHyperTwistMemoryCognitiveFact& Fact : CognitiveState.Facts) + { + if (Fact.bRequiresReview + && (Fact.ContradictionIds.Num() > 0 || !Fact.SupersededByFactId.IsEmpty())) + { + bHasExplicitlyReviewedFact = true; + break; + } + } + TestTrue( + TEXT("At least one contradicted or superseded cognitive fact must be marked for explicit review."), + bHasExplicitlyReviewedFact + ); + + return true; +} + +IMPLEMENT_SIMPLE_AUTOMATION_TEST( + FHyperTwistMemoryPhase6RM4SerializationRoundTripTest, + "HyperTwist.FirstParty.Memory.Phase6R.M4.SerializationRoundTrip", + EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter +) + +bool FHyperTwistMemoryPhase6RM4SerializationRoundTripTest::RunTest(const FString& Parameters) +{ + const FHyperTwistMemoryCognitiveConsolidationState CognitiveState = + UHyperTwistContractLibrary::MakeSampleTrainingMemoryCognitiveConsolidationState(); + TestTrue( + TEXT("The Phase 6R-M4 cognitive consolidation state must be structurally valid."), + CognitiveState.IsStructurallyValid() + ); + + const FString Json = + UHyperTwistContractLibrary::SerializeMemoryCognitiveConsolidationStateToJson( + CognitiveState + ); + TestFalse(TEXT("The serialized M4 JSON must not be empty."), Json.IsEmpty()); + TestTrue( + TEXT("The serialized M4 JSON must expose contradiction records."), + Json.Contains(TEXT("Contradictions")) + ); + + FHyperTwistMemoryCognitiveConsolidationState RoundTrippedState; + TestTrue( + TEXT("The M4 JSON must deserialize cleanly."), + UHyperTwistContractLibrary::DeserializeMemoryCognitiveConsolidationStateFromJson( + Json, + RoundTrippedState + ) + ); + TestTrue( + TEXT("The round-tripped M4 state must remain structurally valid."), + RoundTrippedState.IsStructurallyValid() + ); + TestEqual( + TEXT("The round-tripped M4 state must preserve fact counts."), + RoundTrippedState.Facts.Num(), + CognitiveState.Facts.Num() + ); + TestEqual( + TEXT("The round-tripped M4 state must preserve contradiction counts."), + RoundTrippedState.Contradictions.Num(), + CognitiveState.Contradictions.Num() + ); + TestEqual( + TEXT("The round-tripped M4 state must preserve supersession counts."), + RoundTrippedState.Supersessions.Num(), + CognitiveState.Supersessions.Num() + ); + TestEqual( + TEXT("The round-tripped M4 state must preserve confidence-decay counts."), + RoundTrippedState.ConfidenceDecays.Num(), + CognitiveState.ConfidenceDecays.Num() + ); + + return true; +} + +#endif diff --git a/docs/arch/HYPERTWIST_PHASE6R_M4_FIRST_PARTY_COGNITIVE_CONSOLIDATION_IMPLEMENTATION_PACKET_2026-05-28.md b/docs/arch/HYPERTWIST_PHASE6R_M4_FIRST_PARTY_COGNITIVE_CONSOLIDATION_IMPLEMENTATION_PACKET_2026-05-28.md new file mode 100644 index 0000000..bc2c601 --- /dev/null +++ b/docs/arch/HYPERTWIST_PHASE6R_M4_FIRST_PARTY_COGNITIVE_CONSOLIDATION_IMPLEMENTATION_PACKET_2026-05-28.md @@ -0,0 +1,134 @@ +# HyperTwist Phase 6R-M4 first-party cognitive consolidation implementation packet + +Created on `2026-05-28` + +## Status + +- first-party HyperTwist packet +- bounded `Phase 6R-M4` implementation slice + +## Purpose + +This packet lands the bounded first-party cognitive consolidation seam under +the canonical `Memory Lanes` doctrine. + +The landed slice is: + +- provenance-backed cognitive facts +- contradiction handling +- supersession links +- confidence decay + +It is not: + +- a broad memory federation packet +- a replay of `6R-M1`, `6R-M2`, or `6R-M3` +- a curated knowledge-promotion packet +- a user-notes packet +- a compact reducer/digest packet + +## Current authority basis + +This implementation packet stands on: + +- `docs/ops/HYPERTWIST_MEMORY_LANE_AUTHORITY_AND_PHASE_IMPLEMENTATION_DOCTRINE_2026-05-21.md` +- `docs/ops/HYPERTWIST_CONTINUITY_LATTICE_AND_CONTEXT_ASSEMBLY_PROFILE_DOCTRINE_2026-05-23.md` +- `docs/ops/HYPERTWIST_IMPLEMENTATION_PHASE_1_KICKOFF.md` +- `docs/v6_5_deep_manual_pack/HyperTwist/ARCHITECTURE.md` +- `docs/v6_5_deep_manual_pack/HyperTwist/FEATURE_REGISTRY.md` +- `docs/v6_5_deep_manual_pack/HyperTwist/PROVENANCE_AND_TRUST_MODEL.md` +- `docs/arch/HYPERTWIST_PHASE6R_M4_FIRST_PARTY_COGNITIVE_CONSOLIDATION_PREPARATION_PACKET_2026-05-28.md` + +The preserved owners do not change: + +- first-party HyperTwist remains the top-level owner for live cognitive + consolidation product surfaces +- the landed `Phase 6R-M1` ledger remains the provenance substrate beneath this + packet +- the landed `Phase 6R-M2` chronicle/continuity layer remains the current + history/open-work substrate beneath this packet +- the landed `Phase 6R-M3` recall/shared-context layer remains the current + explicit retrieval and scoped-sharing substrate beneath this packet +- current training, replay, coaching, and repository code remains the raw + evidence substrate beneath this packet +- the VectorShell memory doctrine remains the external synchronization + entrypoint and authority map, not a frozen imported implementation + +## Landed scope + +The current code now owns a bounded first-party cognitive consolidation seam +through: + +- canonical cognitive-fact, contradiction, supersession, confidence-decay, and + cognitive-consolidation state types in: + - `HyperTwistMemoryTypes.h` +- first-party cognitive-consolidation derivation from current training + repository state over the already-landed `6R-M1`, `6R-M2`, and `6R-M3` seams + in: + - `UHyperTwistMemoryCoreLibrary` +- current bounded cognitive coverage for: + - review pressure + - follow-up posture + - carry-forward posture + - archive posture + - persistent weak-case pressure + - dominant guidance-lane posture +- current bounded contradiction and supersession coverage that preserves both + sides of contested derived conclusions and keeps stale conclusions explicit + instead of silently overwriting them +- current bounded confidence-decay coverage for: + - no-direct-authoritative-lineage cases + - contradiction-review cases + - superseded derived conclusions +- sample contract helpers in: + - `UHyperTwistContractLibrary::MakeSampleTrainingMemoryCognitiveConsolidationState()` + - `UHyperTwistContractLibrary::SerializeMemoryCognitiveConsolidationStateToJson(...)` + - `UHyperTwistContractLibrary::DeserializeMemoryCognitiveConsolidationStateFromJson(...)` +- focused automation coverage in: + - `HyperTwistMemoryPhase6RM4CognitiveConsolidationContractTest.cpp` + +## Why this is still intentionally bounded + +This packet lands cognitive consolidation only. + +Still deferred: + +- curated knowledge objects and reviewable promotion flows +- user-authored notes +- broad long-form summaries or compact digests +- reducer packets or reduced-context federation + +## Validation + +Build validation: + +- `UnrealHyperTwistEditor Win64 Development` + +Focused automation validation: + +- `HyperTwist.FirstParty.Memory.Phase6R.M4.FactExtraction` +- `HyperTwist.FirstParty.Memory.Phase6R.M4.ContradictionSupersession` +- `HyperTwist.FirstParty.Memory.Phase6R.M4.SerializationRoundTrip` + +Observed: + +- `3` focused `Phase 6R-M4` automation tests succeeded + +Non-blocking warnings stayed limited to the existing Unreal headless/editor +noise, expected Python-stub regeneration noise, headless CEF/web-browser +warnings, and benign asset-registry/cache journal chatter during editor +startup. + +## Queue effect + +This packet consumes the current `Phase 6R-M4` implementation slice. + +Memory implementation is now live at the provenance-backed cognitive +consolidation layer through bounded cognitive facts, contradiction records, +supersession links, and confidence-decay entries over the landed `6R-M1` +ledger, `6R-M2` chronicle/continuity, and `6R-M3` recall/shared-context seams. + +If later memory implementation continues: + +- the next clean move is `Phase 6R-M5` +- do not reopen `6R-M4` as one broad "memory packet" diff --git a/docs/arch/HYPERTWIST_PHASE6R_M4_FIRST_PARTY_COGNITIVE_CONSOLIDATION_PREPARATION_PACKET_2026-05-28.md b/docs/arch/HYPERTWIST_PHASE6R_M4_FIRST_PARTY_COGNITIVE_CONSOLIDATION_PREPARATION_PACKET_2026-05-28.md new file mode 100644 index 0000000..62a08dd --- /dev/null +++ b/docs/arch/HYPERTWIST_PHASE6R_M4_FIRST_PARTY_COGNITIVE_CONSOLIDATION_PREPARATION_PACKET_2026-05-28.md @@ -0,0 +1,122 @@ +# HyperTwist Phase 6R-M4 first-party cognitive consolidation preparation packet + +Created on `2026-05-28` + +## Status + +- first-party HyperTwist packet +- source-backed `Phase 6R-M4` preparation/control slice + +## Purpose + +This packet scopes the fourth bounded first-party memory implementation slice +under the canonical `Memory Lanes` doctrine. + +The granted slice is: + +- provenance-backed cognitive facts +- contradiction handling +- supersession links +- confidence decay + +It is not: + +- a broad memory federation packet +- a replay of `6R-M1`, `6R-M2`, or `6R-M3` +- a curated knowledge-promotion packet +- a user-notes packet +- a compact reducer/digest packet + +## Current authority basis + +This control pass stands on: + +- `docs/ops/HYPERTWIST_MEMORY_LANE_AUTHORITY_AND_PHASE_IMPLEMENTATION_DOCTRINE_2026-05-21.md` +- `docs/ops/HYPERTWIST_CONTINUITY_LATTICE_AND_CONTEXT_ASSEMBLY_PROFILE_DOCTRINE_2026-05-23.md` +- `docs/ops/HYPERTWIST_IMPLEMENTATION_PHASE_1_KICKOFF.md` +- `docs/v6_5_deep_manual_pack/HyperTwist/ARCHITECTURE.md` +- `docs/v6_5_deep_manual_pack/HyperTwist/FEATURE_REGISTRY.md` +- `docs/v6_5_deep_manual_pack/HyperTwist/PROVENANCE_AND_TRUST_MODEL.md` +- `docs/arch/HYPERTWIST_PHASE6R_M1_FIRST_PARTY_MEMORY_CONTRACTS_AND_LEDGER_IMPLEMENTATION_PACKET_2026-05-28.md` +- `docs/arch/HYPERTWIST_PHASE6R_M2_FIRST_PARTY_CHRONICLE_AND_CONTINUITY_IMPLEMENTATION_PACKET_2026-05-28.md` +- `docs/arch/HYPERTWIST_PHASE6R_M3_FIRST_PARTY_RECALL_AND_SHARED_CONTEXT_IMPLEMENTATION_PACKET_2026-05-28.md` +- `docs/VECTORSHELL_MEMORY_SYSTEM_IMPORT_AUTHORITY_FOR_HYPERTWIST_2026-05-25.md` + +The preserved owners do not change here: + +- first-party HyperTwist remains the live owner for current cognitive + consolidation product seams +- the landed `Phase 6R-M1` ledger remains the provenance substrate beneath this + packet +- the landed `Phase 6R-M2` chronicle/continuity layer remains the current + open-work and history substrate beneath this packet +- the landed `Phase 6R-M3` recall/shared-context layer remains the current + explicit retrieval and scoped-sharing substrate beneath this packet +- current training, replay, coaching, and repository code remains the raw + evidence substrate beneath this packet +- the VectorShell memory doctrine remains the external synchronization + entrypoint and authority map, not a frozen imported implementation + +## Granted family + +The bounded `Phase 6R-M4` slice may land: + +1. provenance-backed cognitive fact extraction over current repository-backed + memory evidence +2. contradiction records that preserve both sides of contested derived + conclusions +3. explicit supersession links rather than silent overwrite +4. confidence-decay entries over contradicted, stale, or less-authoritative + derived conclusions +5. sample contract and JSON round-trip coverage for the `6R-M4` state + +The packet must stay out of: + +- curated knowledge objects and promotion flows +- user-authored notes +- broad long-form summaries or compact digests +- reducer packets or reduced-context federation + +## Proposed implementation shape + +Land the narrower first-party boundary through: + +- new memory types for: + - cognitive facts + - contradiction records + - supersession records + - confidence-decay entries + - bounded cognitive-consolidation state +- a memory-core derivation function over: + - current repository state + - the landed `6R-M1` ledger + - the landed `6R-M2` chronicle/continuity layer + - the landed `6R-M3` recall/shared-context layer +- sample-contract helpers for: + - sample cognitive-consolidation derivation + - JSON serialization + - JSON deserialization +- focused automation in: + - `HyperTwistMemoryPhase6RM4CognitiveConsolidationContractTest.cpp` + +## Validation target + +Validate with: + +- Unreal build for `UnrealHyperTwistEditor Win64 Development` +- focused automation: + - `HyperTwist.FirstParty.Memory.Phase6R.M4.FactExtraction` + - `HyperTwist.FirstParty.Memory.Phase6R.M4.ContradictionSupersession` + - `HyperTwist.FirstParty.Memory.Phase6R.M4.SerializationRoundTrip` + +## Queue effect + +If this packet lands cleanly, HyperTwist memory no longer stops at explicit +recall and revocable shared-context. The bounded first-party cognitive +consolidation layer becomes current product truth above `6R-M1`, `6R-M2`, and +`6R-M3`. + +If later memory implementation continues: + +- the next clean move is `Phase 6R-M5` +- do not reopen `6R-M4` as one broad memory packet diff --git a/docs/ops/HYPERTWIST_IMPLEMENTATION_PHASE_1_KICKOFF.md b/docs/ops/HYPERTWIST_IMPLEMENTATION_PHASE_1_KICKOFF.md index 674cef5..edae78b 100644 --- a/docs/ops/HYPERTWIST_IMPLEMENTATION_PHASE_1_KICKOFF.md +++ b/docs/ops/HYPERTWIST_IMPLEMENTATION_PHASE_1_KICKOFF.md @@ -228,7 +228,9 @@ When HyperTwist later returns to memory implementation: landed in current code - the bounded first-party `Phase 6R-M3` recall and shared-context packet is now landed in current code -- if memory implementation continues, the next clean move is `Phase 6R-M4` +- the bounded first-party `Phase 6R-M4` cognitive consolidation packet is now + landed in current code +- if memory implementation continues, the next clean move is `Phase 6R-M5` - do not open one broad "memory packet" - follow the lane map and packet order in `C:\HyperTwist\docs\ops\HYPERTWIST_MEMORY_LANE_AUTHORITY_AND_PHASE_IMPLEMENTATION_DOCTRINE_2026-05-21.md` diff --git a/docs/ops/HYPERTWIST_MEMORY_LANE_AUTHORITY_AND_PHASE_IMPLEMENTATION_DOCTRINE_2026-05-21.md b/docs/ops/HYPERTWIST_MEMORY_LANE_AUTHORITY_AND_PHASE_IMPLEMENTATION_DOCTRINE_2026-05-21.md index 351fec0..c3615af 100644 --- a/docs/ops/HYPERTWIST_MEMORY_LANE_AUTHORITY_AND_PHASE_IMPLEMENTATION_DOCTRINE_2026-05-21.md +++ b/docs/ops/HYPERTWIST_MEMORY_LANE_AUTHORITY_AND_PHASE_IMPLEMENTATION_DOCTRINE_2026-05-21.md @@ -660,7 +660,12 @@ Current standing: - current live `6R-M3` surfaces cover explicit recall matches, history search, provenance drill-down, and revocable shared-context projections over the landed `6R-M1` and `6R-M2` seams -- if memory implementation continues, the next clean move is `6R-M4` +- the bounded first-party `Phase 6R-M4` cognitive consolidation packet is now + landed in current code +- current live `6R-M4` surfaces cover provenance-backed cognitive facts, + contradiction records, supersession links, and confidence-decay entries over + the landed `6R-M1`, `6R-M2`, and `6R-M3` seams +- if memory implementation continues, the next clean move is `6R-M5` ### `6R-M2` - chronicle and continuity packet diff --git a/docs/v6_5_deep_manual_pack/HyperTwist/ARCHITECTURE.md b/docs/v6_5_deep_manual_pack/HyperTwist/ARCHITECTURE.md index 239db9b..827d86f 100644 --- a/docs/v6_5_deep_manual_pack/HyperTwist/ARCHITECTURE.md +++ b/docs/v6_5_deep_manual_pack/HyperTwist/ARCHITECTURE.md @@ -185,6 +185,8 @@ That means: ledger seam - a live first-party `Phase 6R-M3` recall/shared-context layer over those landed seams +- a live first-party `Phase 6R-M4` cognitive-consolidation layer over those + landed seams - explicit provenance - explicit custody - two context-assembly profiles: diff --git a/docs/v6_5_deep_manual_pack/HyperTwist/FEATURE_REGISTRY.md b/docs/v6_5_deep_manual_pack/HyperTwist/FEATURE_REGISTRY.md index 1ebd3f8..4a51b66 100644 --- a/docs/v6_5_deep_manual_pack/HyperTwist/FEATURE_REGISTRY.md +++ b/docs/v6_5_deep_manual_pack/HyperTwist/FEATURE_REGISTRY.md @@ -291,6 +291,7 @@ repo. | First-party memory contracts and ledger | Implemented now | landed first-party `Phase 6R-M1` packet | Current bounded memory lane ids, entity ids, provenance links, authority flags, feature gates, retention profiles, and ledger JSON round-trip are live. Chronicle/resume, recall/shared context, cognitive extraction, knowledge/notes, and compact reducers stay deferred to later memory packets. | | First-party chronicle and continuity | Implemented now | landed first-party `Phase 6R-M2` packet | Current bounded chronicle events, grouped continuity sessions, resume packs, and repo-aware continuity guards are live above the landed `Phase 6R-M1` ledger seam. Recall/history search, scoped shared-context, cognitive extraction, knowledge/notes, and compact reducers stay deferred to later memory packets. | | First-party recall and shared context | Implemented now | landed first-party `Phase 6R-M3` packet | Current bounded explicit recall matches, history search, provenance drill-down, and revocable shared-context projections are live above the landed `Phase 6R-M1` ledger and `Phase 6R-M2` chronicle/continuity seams. Cognitive extraction, knowledge/notes, and compact reducers stay deferred to later memory packets. | +| First-party cognitive consolidation | Implemented now | landed first-party `Phase 6R-M4` packet | Current bounded provenance-backed cognitive facts, contradiction records, supersession links, and confidence-decay entries are live above the landed `Phase 6R-M1`, `Phase 6R-M2`, and `Phase 6R-M3` seams. Knowledge/notes and compact reducers stay deferred to later memory packets. | | Control-plane telemetry, replay-diagnostic, and rollout-governance reference grounding | Implemented now | `PostHog/posthog` retained boundary-sensitive lane + first-party current code | Current live `Control-Plane Telemetry and Replay Governance` reference side includes six rewritten first-party contract/reference targets grounded in `PostHog/posthog`: replay diagnostics, replay segmentation, feature governance, scheduled changes, early-access lifecycle, and explicit `MIT`-outside-`ee/` compliance-boundary notes. This does not displace the landed `Phase 4R-D` first-party owner lane, any replay-shell owner family, or the explicit enterprise-subtree exclusion boundary. | | Capture-history, vault, and replay-inspection reference grounding | Implemented now | `screenpipe/screenpipe` retained boundary-sensitive lane + first-party current code | Current live `Capture History, Replay, and Vault Support` reference side includes six rewritten first-party contract/reference targets grounded in `screenpipe/screenpipe`: event-capture, pipe-permission, persistence, vault-lifecycle, timeline-review, and explicit permissive-core-versus-`ee/` compliance-boundary notes. This does not displace the landed `Phase 4R-E` first-party owner lane, the broader replay shell, or the explicit enterprise-subtree exclusion boundary. | | Layered memory federation | Deep-source grounded retained | memory doctrine + VectorShell import entrypoint | Governing taxonomy exists; HyperTwist uses pointer-based synchronization to the current VectorShell memory canon rather than a frozen local fork. Lane widening remains future work and later superior evidence may revise only the exact affected lane or sub-slice. | diff --git a/docs/v6_5_deep_manual_pack/HyperTwist/PROVENANCE_AND_TRUST_MODEL.md b/docs/v6_5_deep_manual_pack/HyperTwist/PROVENANCE_AND_TRUST_MODEL.md index 3fed91d..f84abad 100644 --- a/docs/v6_5_deep_manual_pack/HyperTwist/PROVENANCE_AND_TRUST_MODEL.md +++ b/docs/v6_5_deep_manual_pack/HyperTwist/PROVENANCE_AND_TRUST_MODEL.md @@ -101,11 +101,11 @@ and requires provenance to survive: packet - the landed bounded first-party `Phase 6R-M3` recall and shared-context packet +- the landed bounded first-party `Phase 6R-M4` cognitive consolidation packet - chronicle capture - continuity/resume packets - explicit recall and provenance drill-down -- cognitive coach-state consolidation -- knowledge promotion +- broader knowledge promotion and note review beyond the landed `6R-M4` seam - derived compact views Important continuity-profile reading: diff --git a/docs/v6_5_deep_manual_pack/HyperTwist/ROADMAP.md b/docs/v6_5_deep_manual_pack/HyperTwist/ROADMAP.md index abffff4..e657066 100644 --- a/docs/v6_5_deep_manual_pack/HyperTwist/ROADMAP.md +++ b/docs/v6_5_deep_manual_pack/HyperTwist/ROADMAP.md @@ -143,8 +143,12 @@ Canonical discovery surfaces for roadmap interpretation: consumed - the bounded first-party `Phase 6R-M3` recall and shared-context packet is now landed in current code -- if memory implementation continues, the next clean move is `Phase 6R-M4` cognitive - consolidation rather than reopening `6R-M1`, `6R-M2`, or `6R-M3` as broad memory packets +- the generic first-party `Phase 6R-M4` cognitive consolidation control pass is now + consumed +- the bounded first-party `Phase 6R-M4` cognitive consolidation packet is now landed in + current code +- if memory implementation continues, the next clean move is `Phase 6R-M5` knowledge and + notes rather than reopening `6R-M1`, `6R-M2`, `6R-M3`, or `6R-M4` as broad memory packets - the generic source-backed `Phase 6R-R` shared classic-cube recognition multi-face correction/explanation control pass is now consumed - the bounded permissive `Phase 6R-R` shared classic-cube recognition multi-face