feat(rag,kg): time-decay recency scoring + wire contradiction invalidation (Wave 4)#43
Closed
urmzd wants to merge 1 commit into
Closed
feat(rag,kg): time-decay recency scoring + wire contradiction invalidation (Wave 4)#43urmzd wants to merge 1 commit into
urmzd wants to merge 1 commit into
Conversation
839e059 to
6e7dca3
Compare
…ation RAG: add WithRecency(halfLife, weight) SearchOption that blends an exponential time-decay factor exp(-ln2*age/halfLife) into each hit's fused score after RRF. Opt-in (non-positive half-life is a no-op). SearchHit gains a Timestamp populated from the document UpdatedAt (fallback CreatedAt) in memstore and pgstore. KG: wire the previously-unused Store.InvalidateRelation into the engine ingestion path. A new relation for an existing (source,target,type) rule-based supersedes active prior relation(s) of the same type, setting their InvalidAt to the new relation's ValidAt.
6e7dca3 to
eeed3fe
Compare
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wave 4 — Temporal differentiators
Bounded slice landed; green on
go build ./...,go vet ./rag/... ./knowledge/..., andgo testfor every changed package.What landed
(a) RAG time-decay / recency scoring
types.WithRecency(halfLife time.Duration, weight float64) SearchOption.rag/internal/pipeline, each hit's fused score is blended with an exponential recency factorexp(-ln2 * age / halfLife):score = (1-weight)*score + weight*score*recencyFactor.types.SearchHitgains aTimestamp time.Timefield, populated from the document'sUpdatedAt(fallbackCreatedAt) by bothrag/memstoreandrag/pgstoreduring search. A zero timestamp means "unknown age" → no decay (factor 1.0).rag/memstore:TestSearchByEmbeddingPopulatesTimestamp(UpdatedAt preferred, CreatedAt fallback).rag/internal/pipeline:TestPipelineRecencyTieBreak(two equally-relevant docs of different ages indexed in memstore; the recent doc outranks the older one only withWithRecency) andTestPipelineRecencyDisabledByDefault.(b) KG contradiction invalidation
Store.InvalidateRelationinto the engine ingestion path.(source, target, type),invalidateSupersededRelationsfinds active prior relation(s) of the same type and callsInvalidateRelation(old, newValidAt), setting the old edge'sInvalidAt.knowledge/internal/engine:TestIngestEpisode_SupersededRelationInvalidated(prior invalidated exactly once at the new relation's ValidAt; new relation not invalidated).TestIngestEpisode_DifferentTypePriorNotInvalidated.TestIngestEpisode_AlreadyInvalidatedPriorSkipped.Deferred (TODO)
WithAsOf(validTime, txTime)read path.SearchFacts) path.Notes
gofmt -w .reports pre-existing formatting drift across many unrelated files on the foundation branch; this PR deliberately commits only the 8 files it changed (all gofmt-clean) to keep the diff focused.Stacked on #38 (foundation) — merge after #38.