You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Redesign bm doctor: report on real projects and suggest fixes #1798
People want a doctor command. They run it when something looks wrong and expect it to tell them what is wrong with their project and what to do about it. bm doctor does neither.
Today it is a smoke test. It registers a throwaway project in the user's real config and database, writes a note through the API and one through the filesystem, indexes them, searches, checks status, then deletes the project. It passes on an install whose real projects have duplicate search rows, orphaned rows or unindexed files (#1773), because it never looks at them.
The throwaway project is also why doctor keeps breaking. It is a real project, so it runs into every policy a real project is subject to, and each one has produced a bug and a special case:
The next policy change will produce the next doctor bug.
Goal
bm doctor produces a report on the user's actual projects and, for each problem it finds, suggests an action the user or their agent can take to fix it.
Proposed design
1. Inspect real projects (read-only)
Doctor checks the projects that exist and never writes to them. Each check produces findings, and each finding carries a suggested action. A first set of checks:
rename the listed folders, or resolve the reserved-path conflict
Config
project path missing or not absolute; config and database disagree on a path
bm project ... commands that fix it
Frontmatter and parse errors
notes that failed to parse
the file and line to fix
Two rules:
Severity follows the consistency model in AGENTS.md. Derived state (search rows, vectors, materialization status, Wiki output) is eventually consistent. A lag while indexing is running is reported as info, not as a failure. A finding is an error only when nothing will repair it without action: a real duplicate, a missing file, a parse error, a conflict.
Actions are concrete commands or edits, not "wait and rerun". If doctor cannot name an action, the finding says so and shows the evidence.
2. Pipeline self-test, sandboxed
Keep the write, index, search and status round trip. It catches broken installs, missing dependencies and migration failures. But run it in-process against a temporary home, config, SQLite database and project directory, the way just doctor already does, and never register anything in the user's real config or database. That removes the project-root, default-project, config-mutation and cleanup bugs as a class. It needs ConfigManager to be injectable at the composition root (the open half of #1109).
3. Output for people and agents
Human output: a short summary per project, then findings grouped by severity, each with its action.
--json: a stable, typed report (checks, findings, severity, evidence, suggested action) that an agent can act on without parsing prose.
Exit codes: 0 when there are no errors; nonzero when there is at least one error. Info and warnings never fail the run.
Scoping: --project X, with every project by default.
Doctor reports and suggests. It does not repair. A separate --fix that runs the suggested safe actions could come later; it is out of scope here.
Open questions
Cloud. Should bm doctor --cloud run the read-only inspection against cloud projects only, with no self-test? Today it would create a real cloud project.
MCP. Should the report also be exposed as an MCP tool, or a memory://doctor resource, so an agent can run it directly?
Type: Enhancement (redesign of bm doctor). Labeled enhancement.
Component: CLI (bm doctor). It also touches the indexing/DB and config layers, and possibly MCP if the open question about exposing the report is accepted. No Cloud label, since cloud is only an open question here.
Split this into an umbrella issue with three sub-issues: the finding/report schema with the integrity check, the sandboxed self-test, and the --json output with exit codes. Each can ship alone.
Fix the report schema first. Checks, MCP exposure and a later --fix all build on it.
The open questions (--cloud behavior, an MCP tool or memory://doctor resource, a bm status summary line) can wait until the local read-only path ships. I'd suggest --cloud run inspection only, with no self-test, as the issue proposes.
Activity
claude commentedon Oct 20, 2026
Claude finished @phernandez's task in 28s —— View job
Triage
bm doctor). Labeledenhancement.bm doctor). It also touches the indexing/DB and config layers, and possibly MCP if the open question about exposing the report is accepted. No Cloud label, since cloud is only an open question here.bm doctormisses real index problems today ([BUG] bm statusandbm doctor` don't surface index inconsistencies (duplicate rows, orphans, inverted timestamps) #1773), and its throwaway project keeps producing bugs (bm doctorfalse failure whenproject_rootis configured #665, bm doctor fails when BASIC_MEMORY_PROJECT_ROOT equals the project directory #1323, [BUG] basic-memory doctor always fails with "API note file missing" outside test mode #1315, doctor: API round-trip check fails against 202 materialization (file_write_status: pending) — and the run mutates config.json #1666). No data loss is involved.ConfigManagerinjectable (Consolidate _v2/_v2_external DI provider triplication; stop reading ConfigManager below the composition root #1109).--jsonschema plus exit-code semantics.Related issues (not duplicates)
andbm doctor` don't surface index inconsistencies (duplicate rows, orphans, inverted timestamps) #1773 is the bug report that motivated this, and PR fix(cli): surface existing project index integrity in doctor #1792 is the first check. The issue proposes folding that PR in with severity changes, so the two should be coordinated.search_indexon the SQLite backend — no uniqueness guard, non-atomic reindex, and the stale-row purge cannot remove duplicates #1771 covers the duplicatesearch_indexrows, which the integrity check would detect.ConfigManager) blocks the sandboxed self-test.Suggestions
--jsonoutput with exit codes. Each can ship alone.--fixall build on it.--cloudbehavior, an MCP tool ormemory://doctorresource, abm statussummary line) can wait until the local read-only path ships. I'd suggest--cloudrun inspection only, with no self-test, as the issue proposes.This was triage only, so I made no code changes.
fix(cli): skip config-only cloud projects in doctor
fix(cli): sandbox-only self-test; full reindex for orphaned rows
fix(cli): report a cloud project named by external ID as skipped
docs(cli): state doctor's read-only guarantee precisely
fix(cli): grade duplicate search rows by indexing state
fix(cli): report lagging search-row anomalies as warnings
fix(cli): offer recovery for abandoned in-flight note saves