Skip to content

fix(import): keep row ids and fields, do not resurrect soft-deleted rows (#1633) - #1636

Merged
ajianaz merged 3 commits into
developfrom
fix/import-identity-1633
Nov 2, 2026
Merged

ajianaz merged 3 commits into
developfrom
fix/import-identity-1633

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

What

Closes #1633, including both items of the owner's comment.

  • The JSONL importer (Uteke::import / import_with) stores a row under its id (a UUID, canonical lowercase form; anything else is dropped and a new id is generated, as for old files). A stored id is never overwritten: the same content counts as a duplicate, other content as an id conflict. Ids are unique across the store, so when the id is stored in another namespace than the row's target (a copy with --namespace), the row gets a new id and the content checks of the target namespace (Cora finding on the first push).
  • memory_type, importance, pinned, content_type and slug are carried through and validated (unknown type, importance outside 0..1, malformed content type, blank slug fall back to today's defaults: fact, 0.5, false, text, none).
  • Soft-delete is honoured: before insert, every row is checked against the exact content of all rows in the target namespace, deprecated ones included (Store::content_hashes_with_state). Content (or an id) that was forgotten in the target is skipped, not resurrected. A row marked deprecated (Cloud export rows) is stored deprecated with deprecated_at, without a vector.
  • Rows without an id keep the cosine dedup (feat: import pipeline missing dedup, retry, and auto_link — inconsistent with remember path #1005); rows with an id are matched on id and exact content only.
  • uteke export now writes id, memory_type, importance, pinned, content_type, slug, so OSS → OSS round-trips keep identity.
  • import_full reads deprecated (bool or 0/1) and deprecated_at from the bundle row instead of the literal 0.
  • ImportResult and the POST /import response add duplicates_skipped, id_conflicts_skipped, soft_deleted_skipped (names follow the Cloud importer). skipped keeps its meaning (invalid / rejected rows); the CLI prints the new counts.

Why

An export → import round-trip changed every id and flattened every typed memory to fact / 0.5, so anything holding memory ids (room links, timeline, external references) dangled after a restore, and re-importing an old export brought deliberately deleted memories back (hit in production on 2026-11-02). import_full un-deleted every forgotten row whose id a bundle carried.

CORE contract: POST /import changes are additive (three new response keys, the request is unchanged). The new id/dedup semantics converge on what the Cloud importer already does (duplicates_skipped / id_conflicts_skipped on POST /api/v2/import), so Cloud needs no change.

Testing

Tests written first (they failed to compile against develop), in import_export::fidelity_tests and structural_export::column_roundtrip_tests:

  • fixture with ids and mixed type/importance/pinned/content type/slug: all preserved; re-import → imported 0, duplicates_skipped 3, no new rows
  • old plain export without ids → generated UUID, today's defaults
  • existing id with other content → id_conflicts_skipped 1, stored row unchanged
  • a row with an id whose exact content is stored under another id → duplicate, no copy
  • soft-deleted in target (by content without id, and by id) → soft_deleted_skipped, nothing comes back live
  • deprecated: true row → stored deprecated with its deprecated_at; re-import is a duplicate
  • invalid id/type/importance/content type/slug → defaults
  • OSS export → import keeps ids and fields
  • a row without an id still goes through the cosine dedup
  • importing a store's own export with --namespace other copies the rows under new ids (and links their rooms); a second copy is a duplicate
  • import_full: deprecated: true and deprecated: 1 rows stay deprecated, rows without the key stay live

cargo fmt --all, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace pass locally.

…ows (#1633)

The JSONL importer stores a row under its id (skip and count on an id
conflict), carries memory_type, importance, pinned, content_type, slug and
deprecated through with validation, and skips content that is soft-deleted
in the target. Rows without an id keep the cosine dedup (#1005). export
writes the fields; import_full reads deprecated from the bundle row. The
result and POST /import add duplicates_skipped, id_conflicts_skipped and
soft_deleted_skipped.
Comment thread crates/uteke-core/src/import_export.rs Outdated
// same content is a duplicate, other content an id conflict, and
// a live row whose stored copy was forgotten stays forgotten.
if let Some(id) = &row_id
&& let Some((stored, stored_deprecated)) = self.store.content_and_state(id)?
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

…1633)

An import into another namespace (--namespace) of a store's own export
counted every row as a duplicate. Ids are unique across the store, so such
a row now gets a new id and the content checks of the target namespace.
@ajianaz
ajianaz merged commit 71f955c into develop Nov 2, 2026
15 checks passed
@ajianaz
ajianaz deleted the fix/import-identity-1633 branch November 4, 2026 06:46
ajianaz added a commit that referenced this pull request Nov 8, 2026
… (#1690)

* fix(import): import a live row whose content was only forgotten (#1689)

A plain forget soft-deletes (deprecated=1) and is recoverable; only
forget --reason writes rejected_values and rejects (#1627, untouched).
#1633/#1636 made import skip any row whose content matched a soft-deleted
one, so re-importing after a forget (restored backup, the LongMemEval
harness forgetting after each question) dropped the rows.

An anonymous live row over a forgotten copy now inserts as a new live row.
Still skipped: a row carrying the forgotten memory's own id, a row marked
deprecated in the file, and exact duplicates of live rows.

* bench: LongMemEval-S 500Q receipts for the import tombstone-skip fix (#1689)

Full 500-question run on Modal (10 shards, strategy default, binary built
from 32a5cf3, ORT lib from v0.23.0), app ap-HNerZq2X0lO17WJ0CytCfb, 28129s
wall clock. any@5 0.9820, strict@5 0.8800, misses@50 0, strict@5 flips
-0/+0 vs the committed v0.20.0 baseline - all audit gates of #1689 pass.

---------

Co-authored-by: ajianaz <[email protected]>
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.

bug(import): JSONL importer discards original ids and hardcodes type/importance — round-trip loses identity

2 participants