You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(memory): retain schema fields omitted from updates - #7318
A content-only extraction update to an existing typed memory drops schema fields from MEMORY_FIELDS. The merge loop only handles supplied fields, while the old preservation loop excludes every schema field, including omitted ones.
Backfill an old field only when it is absent from both resolved_op.memory_fields and the final metadata. Supplied fields retain their configured merge behavior, and metadata generated during this update, including trace and extraction IDs, keeps its new value. This preserves entity/preference identity for filename and embedding template rendering.
Human Involvement
A human participated in the implementation or review loop
This PR was generated entirely by AI agents without human participation in the loop
Related Issue
Fixes#7317. The explicit-replacement behavior addressed by #4193 remains covered.
Type of Change
Bug fix (non-breaking change that fixes an issue)
Test update
Changes Made
Extend the existing preservation pass to omitted schema fields, with both operation-membership and final-metadata guards.
Extend the existing updater/rename contract with an in-place content-only update. Both paths verify serialized identity, version, custom metadata, links and fresh trace/extraction IDs; the rename also verifies explicit replacement.
Testing
python -m pytest tests/session/memory/test_memory_updater.py tests/session/memory/test_merge_ops.py tests/session/memory/test_replace_string_edits.py tests/session/memory/test_schema_models.py tests/session/memory/test_streaming_memory_updater.py --no-cov -q: 279 passed, 1 failed. The remaining failure, test_apply_operations_skips_link_updates_for_deleted_uris, is the pre-existing fixture that rejects the deleted-file read required by link migration. Reproduced that failure on the previous PR head 504f8c96 in the same environment; both extended update/rename cases pass there too.
Six existing temporary apply_operations/serializer probes pass: entity/preference identity, explicit replacement, immutable fields, falsy values, numeric addition and fresh reads.
Eight additional apply_operations/serializer cases pass on both the previous and revised heads with identical serialized output: omission, replacement, supplied None and empty strings, custom-field null/empty values, a real failing merge, and supplied old provenance overridden by the new operation source.
Ruff lint, test formatting, changed-source-block formatting and git diff --check pass. mypy --no-incremental --follow-imports=silent openviking/session/memory/memory_updater.py tests/session/memory/test_memory_updater.py reports the same 419 existing diagnostics on both heads; none added.
macOS arm64, Python 3.14.10, the same pinned dependency environment used for the original PR. No model calls, HTTP/native storage integration, full repository suite or other OS run.
Checklist
My code follows the project coding style
I have performed a self-review of my code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation
My changes generate no new warnings
Any dependent changes have been merged and published
Additional Notes
This preserves omitted fields on future updates; it does not reconstruct identity fields already lost from existing cards. Source-file formatting is limited to the changed block to avoid unrelated cleanup.
Could we add key not in resolved_op.memory_fields alongside key not in metadata in the backfill condition? Checking the operation makes the omission rule explicit and prevents backfill from restoring a supplied field if a future merge operation removes its key.
The metadata guard also protects values generated during this update, such as source_extraction_id and last_update_trace_id. I tested _apply_upsert() with mocked storage. Replacing the existing check caused the old trace and extraction IDs to overwrite the new ones. Keeping both checks produced identical serialized output to the current PR for omitted fields, explicit replacements, None, empty strings, and merge failures.
Added key not in resolved_op.memory_fields in d0f5641164c6a19fc5079a78125bea63ed006d37, alongside the existing key not in metadata guard.
The existing update/rename contract now starts with old source_extraction_id and last_update_trace_id values and verifies that the newly generated IDs survive serialization, together with omitted identity fields, explicit replacement and links.
Eight additional cases through apply_operations and the real serializer produce identical output on 504f8c96 and this revision: omitted fields, replacement, supplied None/empty strings, custom-field null/empty values, a failing merge, and old provenance supplied in the operation. The six original built-in-schema probes pass too.
The five focused memory modules return 279 passed, 1 failed. The failure is the same deleted-file-read fixture already documented in the PR, reproduced on 504f8c96 in the same environment. Ruff and formatting checks pass; isolated mypy has the same 419 existing diagnostics and no additions. The PR description has the exact commands and limits.
AI-only verification on macOS arm64 / Python 3.14.10. No model, HTTP/native storage integration, full-suite or other OS run.
This branch has not been deployed
No deployments
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
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.
Description
A content-only extraction update to an existing typed memory drops schema fields from
MEMORY_FIELDS. The merge loop only handles supplied fields, while the old preservation loop excludes every schema field, including omitted ones.Backfill an old field only when it is absent from both
resolved_op.memory_fieldsand the finalmetadata. Supplied fields retain their configured merge behavior, and metadata generated during this update, including trace and extraction IDs, keeps its new value. This preserves entity/preference identity for filename and embedding template rendering.Human Involvement
Related Issue
Fixes #7317. The explicit-replacement behavior addressed by #4193 remains covered.
Type of Change
Changes Made
Testing
python -m pytest tests/session/memory/test_memory_updater.py tests/session/memory/test_merge_ops.py tests/session/memory/test_replace_string_edits.py tests/session/memory/test_schema_models.py tests/session/memory/test_streaming_memory_updater.py --no-cov -q: 279 passed, 1 failed. The remaining failure,test_apply_operations_skips_link_updates_for_deleted_uris, is the pre-existing fixture that rejects the deleted-file read required by link migration. Reproduced that failure on the previous PR head504f8c96in the same environment; both extended update/rename cases pass there too.apply_operations/serializer probes pass: entity/preference identity, explicit replacement, immutable fields, falsy values, numeric addition and fresh reads.apply_operations/serializer cases pass on both the previous and revised heads with identical serialized output: omission, replacement, suppliedNoneand empty strings, custom-field null/empty values, a real failing merge, and supplied old provenance overridden by the new operation source.git diff --checkpass.mypy --no-incremental --follow-imports=silent openviking/session/memory/memory_updater.py tests/session/memory/test_memory_updater.pyreports the same 419 existing diagnostics on both heads; none added.Checklist
Additional Notes
This preserves omitted fields on future updates; it does not reconstruct identity fields already lost from existing cards. Source-file formatting is limited to the changed block to avoid unrelated cleanup.