Skip to content

fix(core): documents has_children, legacy-path move, tag rename dupes, empty index rebuild, recompute_importance - #1375

Merged
ajianaz merged 1 commit into
developfrom
fix/core-medium-findings
Oct 8, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/core-medium-findings

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

What

Core part of #1332 (validated Cora-scan findings, medium):

  • documents.rs: upsert_document (update branch) and delete_document refresh the parent's denormalized has_children via one helper; a re-parenting upsert fixes both the old and the new parent.
  • documents.rs: move_document on a legacy row with an empty path (pre-v12, never backfilled) no longer uses old_prefix = "/%", which matched every document and rewrote all paths/depths; such a document is moved on its own.
  • tags.rs: rename_tag onto a tag the memory already carries no longer leaves it twice in the JSON tags column.
  • vector.rs: VectorIndex::build(&[]) keeps the current dimensionality (it reset to 768, so repair() on an empty store broke the next insert of a non-768 embedder).
  • store.rs: recompute_importance selects only the columns it needs (it loaded every embedding blob) and runs in one transaction instead of one autocommit per row. Formula unchanged.
  • Already done elsewhere: "doc upsert holds the index write lock across embedding" (fix: make document upsert atomic and embed outside the index lock #1323, refactor(core): document upsert/update as embed-then-commit #1350).

Why

Findings from the v0.19.1 review, re-verified against the code before touching it (see #1332).

Testing

  • 5 new tests; 4 of them fail on the old code (has_children on delete, on re-parent, empty-path move corrupting a bystander and its child, tag duplicate, empty-build dims). The recompute_importance test pins the formula (hot/cold/pinned) so the rewrite cannot change values.
  • cargo fmt --check, cargo clippy --workspace --all-targets clean; cargo test --workspace green (core 648); vecq-only core build green (645).
  • Not covered: a timing measurement for recompute_importance on a large store; an upsert that moves a document does not rewrite its descendants' paths (separate, not in fix: remaining medium findings from Cora scan (documents, tags, CLI routing/export) #1332).

Refs #1332

🤖 Generated with Claude Code

…cates, empty index rebuild, recompute_importance

- upsert_document / delete_document keep the parent's has_children flag in step (old and new parent on re-parenting)
- move_document: a legacy row with an empty path no longer matches every document (old_prefix '/%')
- rename_tag onto a tag the memory already has no longer duplicates it in the JSON column
- VectorIndex::build(&[]) keeps the current dimensionality instead of resetting to 768
- recompute_importance reads only the columns it needs and runs in one transaction

Refs #1332

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@ajianaz ajianaz added bug Something isn't working scope:core Core engine work labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working scope:core Core engine work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant