Skip to content

fix(transfer): remap whole-bank mental model evidence - #3883

Closed
PaleRoses wants to merge 1 commit into
vectorize-io:mainfrom
PaleRoses:upstream/transfer-remap-followup
Closed

fix(transfer): remap whole-bank mental model evidence#3883
PaleRoses wants to merge 1 commit into
vectorize-io:mainfrom
PaleRoses:upstream/transfer-remap-followup

Conversation

@PaleRoses

Copy link
Copy Markdown

Problem

Whole-bank import restores mental-model rows twice: once through the embedded document archive before regenerated fact IDs are known, then again through the bank-level restore after remapping. The second insert loses to ON CONFLICT, leaving current evidence pointed at source-bank fact UUIDs. Historical evidence also stores its prior reflect response inside mental_model_history.content, which the existing remapper does not descend into.

This is a follow-up to #3833.

Change

  • Skip document-level mental-model/page restoration for whole-bank archives; the bank importer remains the sole owner of those rows.
  • Remap content.previous_reflect_response.based_on in mental-model history alongside current evidence.
  • Preserve document-archive behavior unchanged.

Verification

Before the patch:

test_bank_roundtrip_remaps_mental_model_based_on_ids: FAILED
restored_ids contained the deleted source fact UUID

After the patch:

PYTHONPATH=<worktree>/hindsight-api-slim .venv/bin/pytest -q \
  hindsight-api-slim/tests/test_document_transfer.py::test_bank_roundtrip_remaps_mental_model_based_on_ids
1 passed

.venv/bin/ruff check hindsight-api-slim/hindsight_api/engine/transfer/importer.py
All checks passed!

@strix-security

strix-security Bot commented Aug 29, 2026

Copy link
Copy Markdown

Strix Security Review

No security issues found.

Updated for 62829df.


Reviewed by Strix
Re-run review · Configure security review settings

@PaleRoses PaleRoses closed this Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant