Skip to content

fix(core): repair and report entities missing search rows - #1954

Merged
phernandez merged 10 commits into
mainfrom
fix/1826-entities-missing-search-rows
Oct 29, 2026
Merged

phernandez merged 10 commits into
mainfrom
fix/1826-entities-missing-search-rows

Conversation

@phernandez

Copy link
Copy Markdown
Member

Why

bm cloud sync made Cloud match the local folder with rclone sync --delete-excluded. It deleted cloud-only notes, including notes that people and managed agents created in Cloud. bm cloud bisync mirrored both ways and could delete or overwrite files on either side. #1596 deprecated both. For 1.0, bm cloud push / bm cloud pull replace them on Personal and Team workspaces. They never delete on the destination and stop on differing files until the user chooses a conflict strategy.

What changed

Removed

  • project_sync, project_bisync, get_project_bisync_state, bisync_initialized, get_rclone_version, supports_create_empty_src_dirs, and MIN_RCLONE_VERSION_EMPTY_DIRS from rclone_commands.py.
  • The sync / bisync / bisync-reset implementations, MirrorCommand, _warn_mirror_deprecated, and the Team-refusal messages for the mirrors from project_sync.py.
  • The force / fail_on_read_error options of the .bmignore converter. Only the destructive sync used them. The test file that covered them is deleted.
  • bm project remove no longer deletes bisync-state/<project>. Nothing reads that state now, and the migration contract says old state directories are left for the user.

Kept as migration stubs (cloud/removed_mirror_commands.py)

  • sync, bisync, and bisync-reset are hidden from bm cloud --help. They accept any of the old arguments and print pull/push commands for the named project (shell-quoted, with <project> when no name was given). The output also covers the deletion, rename, and conflict differences. Each stub then exits 1.
  • The stubs read no config or credentials, call no API, and touch no files. They do not forward to push or pull.

Kept and moved (the old bisync_commands.py holds no bisync code now)

  • mount_api.py: get_mount_info (used by push/pull, prune, check, and project ls --cloud) and generate_mount_credentials (used by cloud setup). BisyncError is renamed MountApiError.
  • rclone_filters.py: convert_bmignore_to_rclone_filters (used by the push/pull diff and copy, and by check) and convert_bmignore_to_rclone_prune_filters (used by prune). rclone_commands.py now imports them at the top; the earlier lazy import was not needed to avoid a cycle.
  • _require_personal_workspace now serves only prune, so its message parameter is gone.

Unchanged: push/pull (dry-run, --workspace routing, --on-conflict choices, destination-only preservation), Team WebDAV transfer, cloud setup, sync-setup, prune, and check. The bisync_initialized / last_sync config fields stay so existing config files still load.

Docs: docs/1.0.md (status, stub behavior, state-directory note, checklist), docs/cloud-cli.md (the deprecated section is replaced by "Removed in 1.0" with a migration table; the limitations now cover renames and reverse-transfer resurrection), bm(1), AGENTS.md, and the Hermes README.

Verification

  • just fast-check: lint, format, and ty pass. (This worktree needed uv sync --extra milvus first so ty could resolve pymilvus.)
  • Issue baseline: BASIC_MEMORY_TESTMON_SELECT_FLAGS="--import-mode=importlib" just fast-test tests/cli/cloud/test_project_sync_command.py tests/cli/cloud/test_webdav_transfer.py tests/test_rclone_commands.py passes 136 tests. The original baseline was 194; the difference is the deleted mirror tests.
  • Targeted run: tests/cli/cloud, tests/test_rclone_commands.py, tests/cli/test_project_remove_cloud_stub.py, tests/test_remedy_emission_sites.py, tests/test_config.py, tests/cli/test_project_set_cloud_local.py, tests/cli/test_project_add_with_local_path.py, tests/cli/test_project_list_and_ls.py, tests/test_man_pages.py, and tests/cli/test_man_command.py pass 529 tests.
  • All of tests/cli: 1262 passed, 7 skipped.
  • New tests/cli/cloud/test_removed_mirror_commands.py runs the real CLI against a logged-in config with a synced project and old bisync state. It asserts exit 1, guidance text, and that no user file, config, or bisync state changes. It also blocks every httpx request.

Note: test_project_add_remedy_matrix.py's cloud rows can fail depending on test order when run in one session after the cloud test files. I reproduced the same 4 failures on unmodified main, so this PR did not cause them. The file passes when run alone and in the full tests/cli run.

Fixes #1845

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8

An entity with no search_index row was unsearchable in every mode and
could never get a vector, because vectors are cut from search rows. Change
detection compares checksums only, so an unchanged file whose rows were
dropped (by the migrations that recreated search_index) was never re-read.
`bm reindex --full --embeddings` runs no search pass, so it skipped those
entities and still reported success. `bm project info` counted coverage
from search_index, so the gap read as full coverage.

The fix adds one query that finds entities without their entity-type
search row, and uses it in three places:

- The local project-index pass rebuilds search rows for those entities
  after its file batches and embeds them with the pass's other targets.
  Every install repairs itself on its next index pass.
- SearchService.reindex_vectors restores missing rows before embedding,
  so `--embeddings` without a search pass no longer skips them. The CLI
  prints how many entities each phase restored.
- project info reports entities_missing_search_rows, recommends
  `bm reindex` when it is non-zero, and counts those entities in the
  embedding coverage bar.

The i2c3d4e5f6g7 migration claimed run_migrations() runs an embedding
backfill. No such hook exists; the docstring now says so instead of
adding migration-time work.

Reported by SWSAmor in #1826.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T07:47:55.528954Z cfc2fc3 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8ef88c6efc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

get_embedding_status returned early on a keyword-only host and when the
vector manifest or storage was missing, before it counted entities with no
search_index row. Those paths reported zero, so a keyword-only install
with an unsearchable entity showed "Up to date".

The count now runs once before any vector checks. When it is non-zero,
every returned status carries it and recommends `bm reindex`, which runs
the search pass that restores the rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3e771483b1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

A migration that recreated search_index can leave every entity without
search rows. restore_missing_search_rows loaded all of them at once, with
observations and relations eagerly loaded, before indexing any. On a
large project that can exhaust memory during the pass meant to repair it.

The repair now loads and indexes one batch of entity ids at a time and
keeps only an id and checksum per restored entity, so each batch's entity
graph can be released. The local index pass uses its file batch size;
reindex_vectors uses the vector sync chunk size. Result counts are
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 91c5657bd2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Search keys an entity's projection row by the entity's id, and the
integrity checker requires s.id = e.id. Matching on entity_id let a stale
entity row carrying the right entity_id under another id count as
present, so project info stayed healthy and no index pass rebuilt it.
Match on id, as the integrity checker does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4feb6fe96c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

total_indexed_entities counted distinct entity_id over every search row,
so an entity that kept observation or relation rows but lost its entity
row was counted as indexed and as missing, and the coverage total could
exceed the entity count. Count entities that have their canonical row
(type 'entity', keyed by the entity's own id), the complement of the
missing-rows query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e8e35ff56

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

A missing-row repair candidate whose file cannot be read or parsed (for
example invalid UTF-8) raised out of the batch and aborted the pass, so
every retry stopped at the same file and later entities never converged.
Index each candidate on its own, log and count a failure, and leave it
out of the restored and vector targets, as file batches already do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9caf0f447

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

restore_missing_search_rows now returns a SearchRowRepair with the
restored entities and the ones whose file could not be read or parsed.
reindex_vectors leaves the failed ones out of vector sync and counts
them as errors with a sample message, instead of embedding an entity
with no source rows and reporting success. project info no longer draws
a vector coverage bar when the host has no vector runtime; the
search-index gap stays in the status line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2c5ce38b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Duplicate canonical (type 'entity', id) rows are a corruption index
integrity tracks; COUNT(DISTINCT id) keeps them from inflating the
indexed-entity count and the coverage total.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 82c0cf316a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Failed repairs were added to errors but not to total_entities, so the
CLI's errors-versus-total check misread the run: a sole failure looked
like success and one failure beside one success looked like total
failure. Include them in the total.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9615a99395

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Vectors can outlive their search rows when a migration recreates
search_index, and the entities-with-chunks count included them, so
project info could show full coverage while every entity was
unsearchable. Count chunked entities that also have their canonical
search row, the same set the indexed count uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8
Signed-off-by: phernandez <paul@basicmachines.co>
@phernandez

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cfc2fc3c24

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/basic_memory/index/local_project.py Resolved
@phernandez
phernandez merged commit 5b1d843 into main Oct 29, 2026
57 checks passed
@phernandez
phernandez deleted the fix/1826-entities-missing-search-rows branch October 29, 2026 08:04
phernandez added a commit that referenced this pull request Oct 29, 2026
## Why

`just release v1.0.0` pre-flight-checks for a `## v1.0.0` heading on
`main`, so the changelog has to land first.

## What changed

`CHANGELOG.md`: the Unreleased section becomes `## v1.0.0 (2026-10-29)`.
Its existing items are kept, and the 60 or so commits since #1871 are
added:

- **Breaking:**
- the MCP surface is only `bm_*`, with the old tools deleted (#1944,
#1947, #1959, #1962–#1964)
  - `project` is required (#1934)
  - the ChatGPT adapters moved to Cloud
  - `bm tool` mirrors the tools (#1943)
  - the POSIX verbs are rebuilt and `bm tail` is removed (#1960)
  - cloud sync/bisync are removed (#1953)
  - `bm schema` project resolution (#1959)
  - LiteLLM is an optional extra
- **Features:** text-file line ranges in `bm_read`; chat imports return
their file paths.
- **Bug fixes:** including the three found in the 1.0 live test (#1971,
#1972, #1974), with contributor credits for @Flynn-Kawolsky (#1957),
@SWSAmor (#1951) and @MbappeWU (#1948).
- **Security:** the CodeRabbit deep-scan hardening batch.

I checked the entries against PR bodies rather than titles, and
corrected #1954, #1948 and #1967 to describe what they actually fixed.

The date is today; change it if the tag lands tomorrow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8

Signed-off-by: phernandez <paul@basicmachines.co>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

feat(cli)!: remove legacy cloud sync and bisync in v1.0

1 participant