fix(cli): surface existing project index integrity in doctor by TPSJASPER · Pull Request #1792 · basicmachines-co/basic-memory · GitHub
Skip to content

fix(cli): surface existing project index integrity in doctor - #1792

Closed
TPSJASPER wants to merge 1 commit into
basicmachines-co:mainfrom
TPSJASPER:fix/1773-index-integrity-diagnostics
Closed

TPSJASPER wants to merge 1 commit into
basicmachines-co:mainfrom
TPSJASPER:fix/1773-index-integrity-diagnostics

Conversation

@TPSJASPER

Copy link
Copy Markdown
Contributor

Summary

  • Add a read-only, project-scoped integrity report at GET /v2/projects/{project_id}/integrity and ProjectClient.get_integrity().
  • bm doctor now inspects existing projects before its disposable smoke test and reports duplicate search rows, orphaned rows, entities missing their search projection, and informational inverted timestamps.
  • --project limits the integrity inspection to one project; cloud routing follows the named project's workspace.
  • Inverted timestamps stay informational because file ctime/mtime fallbacks can legitimately put updated_at before created_at; they never mark the index as damaged.

Tests

  • New repository/API/CLI tests: 59 related tests pass, 1 skipped.
  • New modules at 100% line coverage.
  • ruff check, ruff format --check, and ty check pass.
  • Postgres coverage is left to CI (local Docker unavailable).

Fixes #1773

🤖 Generated with Claude Code

Add a read-only, project-scoped integrity report for duplicate search
rows, orphaned rows, entities missing their search projection, and
informational inverted timestamps. `bm doctor` inspects existing
projects before its disposable smoke test and reports anomalies after
it, while `--project` limits the inspection to one project. The same
report is available at GET /v2/projects/{project_id}/integrity and
through ProjectClient.get_integrity().

Inverted timestamps stay informational because file-time fallbacks can
legitimately put updated_at before created_at. Drive the cloud client
through the named project so multi-workspace routing stays correct.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Signed-off-by: TPSJASPER <592827953@qq.com>
@chatgpt-codex-connector

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

Copy link
Copy Markdown

@TPSJASPER

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

An unknown error occurred
ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@phernandez

Copy link
Copy Markdown
Member

@phernandez phernandez closed this Oct 20, 2026
phernandez added a commit that referenced this pull request Oct 23, 2026
bm doctor now reports problems in the user's real projects and, for each
one it can repair, the command that repairs it. It only reads; it never
changes a project, the config, or the database.

- GET /v2/projects/{id}/doctor returns a typed ProjectDoctorReport. Checks:
  project path, index readiness, search index integrity (duplicate,
  orphaned and missing rows) and note materialization (failed saves,
  external-change holds).
- Findings carry a typed action (index_project, reindex_search[full]);
  the CLI renders it as a quoted command. The API never hardcodes CLI
  strings, because a cloud project cannot run a local command.
- Severity follows the consistency model: missing and orphaned rows are
  info while file indexing has work owed, and errors once it settles.
  Duplicates are always errors. Exit 1 only on errors.
- --json prints the whole report for agents and scripts.
- The write/index/search self-test runs in a child process with its own
  temporary home, config, database and temp dir and no BASIC_MEMORY_*
  variables. The disposable-project endpoint, its service method and the
  allow_nested escape hatch existed only for the old in-place self-test
  and are removed.
- --cloud is refused for now; cloud projects are listed as skipped.

The search index check builds on TPSJASPER's read-only integrity report
from #1792 (the previous commit), reshaped to keep separate examples per
anomaly and to count notes missing their search row directly.

Refs #1798
Refs #1773

Co-authored-by: TPSJASPER <592827953@qq.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KjsDUcHANBa17M84sKxFG3
Signed-off-by: phernandez <paul@basicmachines.co>
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] bm status and bm doctor` don't surface index inconsistencies (duplicate rows, orphans, inverted timestamps)

2 participants