fix(dream): reconcile snapshot state after supersedes reclassification - #44
Open
TurgutKural wants to merge 3 commits into
Open
TurgutKural wants to merge 3 commits into
TurgutKural wants to merge 3 commits into
Conversation
added 3 commits
September 19, 2026 16:04
WriteLinks can reclassify an existing source-target pair from supersedes to topical or recurrent through ON CONFLICT DO UPDATE without reverting the supersedes snapshot side-effect. replaceStaleLinks only restores state for physical stale-link removal, leaving orphan snapshot state. Reconcile target lifecycle state from the current eligible supersedes set, preserve a snapshot when another valid superseder remains, and reuse the existing knowledge/superseded_by=NULL restore semantics. Keep existing weighted-confidence behavior and do not introduce new lifecycle semantics or thresholds.
TurgutKural
marked this pull request as ready for review
September 19, 2026 15:26
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.
Problem
WriteLinkscan update an existing(source_block_id, target_block_id)relation fromsupersedesto another relationship viaON CONFLICT DO UPDATE.A high-confidence
supersedesrelation marks the target as:lifecycle_state='snapshot'superseded_by=<source>When that same pair is later reclassified to
topicalorrecurrent, the relation changes but the lifecycle side effect is not reverted.replaceStaleLinksdoes not catch this because the target is still part of the kept pair set.A read-only production audit found 21 active snapshot blocks without a current matching supersedes relation; 18/21 currently have the same source-target pair reclassified as
topicalorrecurrent.Fix
knowledge/superseded_by=NULLsemantics when none remain.REAL confidencerepresentation (>= 0.7::real).Tests added
TestWriteLinks_SupersedesReclassification_RestoresSnapshotTestWriteLinks_SupersedesToRecurrent_RestoresSnapshotTestWriteLinks_Reclassification_PreservesOtherSupersederTestWriteLinks_StaleSupersedesRemoval_RestoresSnapshotTestWriteLinks_ValidSupersedesRewrite_PreservesSnapshotTestCleanupDanglingLinks_ArchivedTargetDoesNotResurrectTestWriteLinks_SupersedesConfidenceDowngrade_RestoresSnapshotTestWriteLinks_PersistsWeightedAndRawConfidenceSeparatelyTestWriteLinks_SupersedesBoundaryConfidence_PreservesSnapshotCorpus impact
A read-only preview indicates that 21 current orphan snapshots would be restored under the fixed invariant, while 14 valid supersedes relation targets would remain snapshot/current; one multi-superseder pointer would be realigned.
This PR performs no production data repair, UPDATE, migration, cleanup, or container change.