Reject nonfinite Q updates before persistence - #14
Draft
Frankie-Xu wants to merge 2 commits into
Draft
Frankie-Xu wants to merge 2 commits into
Frankie-Xu wants to merge 2 commits into
Conversation
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.
QValueUpdater.update currently writes NaN/Infinity into memory metadata when a reward, bootstrap value, configuration value, or stored Q/EMA is nonfinite. Finite arithmetic can also overflow before persistence. For example, calling update with reward=float('nan') writes a NaN q_value and reward_ma.
Validate the numerical inputs and computed target, Q, and reward EMA before calling text_mem.update. Validate the optional floor before applying it, so it cannot conceal invalid arithmetic. Invalid values raise ValueError and perform no persistence write; valid scalar updates retain the existing formula and floor behavior.
Validation:
python3 -m unittest discover -s tests -p test_q_value_finite.py -qpasses 3 tests (24 invalid input/overflow cases plus repeated valid updates). These regressions produced 24 failures against main c1b322c.git diff --checkpasses. Tests load the actual service module and replace only its MemOS type import and persistence boundary; no external MemOS service or end-to-end suite was run.