feat(core): wire durable self learning evidence

This commit is contained in:
m
2026-08-30 22:48:46 +03:00
parent b4c3479614
commit 75fa8477d8
8 changed files with 155 additions and 2 deletions
+37
View File
@@ -8,6 +8,7 @@ import (
"git.cin.su/m/Assistant/contracts/capability"
"git.cin.su/m/Assistant/contracts/epistemics"
"git.cin.su/m/Assistant/contracts/interaction"
selfcontract "git.cin.su/m/Assistant/contracts/self"
)
type learningEpistemicsStub struct {
@@ -31,6 +32,25 @@ type learningCapabilityStub struct {
saved []capability.SkillProfile
}
type learningSelfStub struct {
signals int
needs int
ledgers int
}
func (s *learningSelfStub) SaveLearningSignal(context.Context, selfcontract.LearningSignal) error {
s.signals++
return nil
}
func (s *learningSelfStub) SaveImprovementNeed(context.Context, selfcontract.ImprovementNeed) error {
s.needs++
return nil
}
func (s *learningSelfStub) SaveLearningLedger(context.Context, selfcontract.LearningLedgerEntry) error {
s.ledgers++
return nil
}
func (s *learningCapabilityStub) LoadSkillProfile(context.Context, capability.SkillProfileID) (capability.SkillProfile, error) {
s.loadCalls++
return capability.SkillProfile{}, nil
@@ -67,3 +87,20 @@ func TestGenericCorrectionDoesNotDegradeReminderSkill(t *testing.T) {
t.Fatalf("generic correction must remain evidence without a reminder skill reference: %#v", epistemicsStore.experiences)
}
}
func TestCorrectionWritesBoundedSelfEvidenceWithoutChangingResponsePath(t *testing.T) {
epistemicsStore := &learningEpistemicsStub{}
selfStore := &learningSelfStub{}
recorder := learningRecorder{epistemics: epistemicsStore, self: selfStore}
recorder.recordCorrection(context.Background(), correctionLearningInput{
Intent: interaction.OriginalHumanIntent{ID: "intent-2"},
Utterance: interaction.HumanUtterance{ID: "utterance-2", PrincipalID: "principal-2"},
At: time.UnixMilli(2000),
})
if selfStore.signals != 1 || selfStore.needs != 1 || selfStore.ledgers != 1 {
t.Fatalf("self evidence counts: signals=%d needs=%d ledgers=%d", selfStore.signals, selfStore.needs, selfStore.ledgers)
}
if len(epistemicsStore.experiences) != 1 {
t.Fatalf("completed learning path was changed")
}
}