Repository navigation
fix(transfer): remap mental-model evidence on documents import - #5657
Merged
Merged
Conversation
A documents import replays facts and observations under fresh ids and records the mapping, but restored the carried mental models' reflect_response.based_on verbatim, so their evidence kept naming source-bank ids. Apply the same _remap_mental_model_evidence the whole-bank restore already uses. System story 52 now checks that an imported mental model's cited ids exist in the destination bank; it fails without the fix.
Review fix: assert the model cites exactly the two facts and the observation, by text, instead of only checking its ids are a subset of the destination's.
This was referenced Oct 20, 2026
Merged
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.
Fixes #5298.
Bug: importing a documents archive into a bank gives every fact and observation a new id, but the mental models in the archive kept citing the old (source-bank) ids in
reflect_response.based_on. Their evidence pointed at nothing in the new bank.Fix: call
_remap_mental_model_evidencebefore restoring the models, the same step the whole-bank restore already runs.Test: new system story in
test_52_transfer.py: a mental model cites real facts and an observation, gets exported with the documents, imported into a new bank, and every id it cites must exist there. Fails without the fix (cites memory ids that do not exist in this bank), passes with it.Note: an api-slim DB test for the same thing was flaky locally (the import sometimes reported a fact id that wasn't in the target bank). I dropped it in favour of the system story; that mismatch may be worth its own look.