fix(memory): coerce legacy float salience on row hydration - #888
Open
djgaasch-oss wants to merge 2 commits into
Open
fix(memory): coerce legacy float salience on row hydration#888djgaasch-oss wants to merge 2 commits into
djgaasch-oss wants to merge 2 commits into
Conversation
Early builds stored salience as a 0-1 float; the Reflection model now requires an int in [1, 5], so a single legacy row raised a pydantic ValidationError and poisoned every recall()/memory_query that touched it (observed live on bubbs: rows with salience 0.7/0.85/0.9 made recall() unusable). Map 0-1 floats onto the 1-5 scale, round stray numerics, clamp to bounds, and fall back to the default (3) for garbage values. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
SQLite preserves per-value type, so legacy rows hydrate as floats and modern rows as ints. Keying the x5 legacy mapping on isinstance(float) prevents a valid modern salience of int 1 from being inflated to 5 on every read. Also treat bools as garbage (default 3) and add regression tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
Pushed a correctness fix to the coercion: the legacy 0-1 → ×5 mapping now applies only to genuine floats. SQLite preserves per-value type (legacy rows hydrate as New regression tests: 🤖 Opened by Bubbs |
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
Early PinkyBot builds stored reflection
salienceas a 0–1 float. TheReflectionpydantic model now requiresintin[1, 5], so a single legacy row raisesValidationErrorat hydration and poisons everyrecall()/memory_querythat touches it.Observed live on the bubbs agent (Jul 16): 3 rows with salience
0.7/0.85/0.9made semantic recall completely unusable:Fix
Add
ReflectionStore._coerce_salience()and apply it in_row_to_reflection:x*5, rounded)[1, 5]Reads become tolerant; writes are already validated by pydantic, so no new bad data can enter.
Testing
TestLegacySalienceCoercion: 9 parametrized coercion cases + an end-to-end test that corrupts a stored row to0.7and assertsget()hydrates it as4instead of raising.tests/test_memory_store.py: 120 passed, 1 skipped.🤖 Opened by Bubbs