Skip to content

fix(doctor): eliminate false positives on PGLite and project/repo name collisions#25

Merged
joedanz merged 1 commit intomasterfrom
fix/doctor-false-positives
Apr 17, 2026
Merged

fix(doctor): eliminate false positives on PGLite and project/repo name collisions#25
joedanz merged 1 commit intomasterfrom
fix/doctor-false-positives

Conversation

@joedanz
Copy link
Copy Markdown
Owner

@joedanz joedanz commented Apr 17, 2026

Summary

Two doctor false-positives that made pbrain doctor noisy for every user, fixed:

  1. DUPLICATE_SLUG fired on every project whose repo name matches its product name. projects/pbrain + repos/joedanz/pbrain collide on the tail pbrain — but path-qualified wikilinks (which is what project-onboard always emits per Contract rule 2) resolve unambiguously. The check now fires only when a bare-slug [[tail]] wikilink actually references the ambiguous tail, and the detail names the referring page so you can fix it in one edit.
  2. pgvector and rls checks warned "Could not check ..." on every PGLite doctor run. Both used db.getConnection() (the postgres npm driver), which is uninitialized in PGLite mode. Gated on engine type: PGLite reports Bundled with PGLite runtime and N/A for PGLite (local embedded DB). Postgres path is byte-identical.

Plus the ## pbrain self-install section in this repo's CLAUDE.md — the project-onboard Phase 8 artifact produced when onboarding pbrain itself.

Test plan

  • bun test test/doctor-integrations.test.ts test/doctor.test.ts — 16 pass, 0 fail
  • Full unit suite: 977 pass, 0 non-E2E fail (30 E2E failures require Docker Postgres per CLAUDE.md lifecycle; this PR touches no DB code paths on the Postgres branch)
  • Live pbrain doctor --integrations on a real brain with projects/pbrain + repos/joedanz/pbrain: green (15 pages, 30 wikilinks, 0 issues)
  • Live pbrain doctor on PGLite: pgvector + rls now report [OK] instead of [WARN]; health score up to 85/100
  • New test coverage: tail-collision-with-path-qualified-refs (green) + tail-collision-with-bare-ref (flagged, with referring page in detail)

What this PR does NOT fix (deliberate)

  • resolver_health MECE_OVERLAP / DRY_VIOLATION — real skill-content cleanup, separate concern
  • skill_symlinks shadowed — real install-state notice, already actionable via pbrain install-skills

…e collisions

DUPLICATE_SLUG in doctor --integrations was firing whenever two pages shared
a tail — including the common case where a project's display name matches
its repo name (projects/pbrain + repos/joedanz/pbrain). Per Contract rule 2
of project-onboard, path-qualified wikilinks resolve unambiguously, so the
collision is only a real problem when a bare-slug [[tail]] reference exists
somewhere in the brain. The check now defers emission until the wikilink
scan has confirmed a bare-slug reference, and the detail points at the
referring page so users can fix it in one edit.

pgvector and RLS checks in doctor both called db.getConnection() (the
postgres npm driver), which is uninitialized on PGLite, so PGLite users got
"[WARN] Could not check pgvector extension" and "[WARN] Could not check RLS
status" on every doctor run. Both are gated on engine type now: PGLite
reports "Bundled with PGLite runtime" and "N/A for PGLite (local embedded
DB)". Postgres path is byte-identical.

Also installs the project-onboard `## pbrain` self-declaration section into
this repo's CLAUDE.md, which is the idempotency-gate artifact produced when
running project-onboard on pbrain itself.
@joedanz joedanz merged commit 3311d4e into master Apr 17, 2026
3 checks passed
@joedanz joedanz deleted the fix/doctor-false-positives branch April 17, 2026 15:58
joedanz added a commit that referenced this pull request Apr 17, 2026
…k checks

Three more classes of doctor noise cleared after PR #25:

1. skill_symlinks shadowed dump — the check classifies any symlink that
   doesn't resolve into the current repo as foreign, so users with a global
   install at ~/.pbrain-repo who also have a dev clone elsewhere saw all
   26×3 = 78 skills flagged as "shadowed by other plugins" on every
   doctor run. Added an `ours-elsewhere` state that walks up from the
   resolved symlink target looking for package.json with name: "pbrain" —
   deterministic detection, works for any pbrain checkout location.
   Doctor now reports `installed — claude: 26, cursor: 26, windsurf: 26
   (symlinks resolve to sibling checkout at <path>)` instead.

2. mece_overlap between maintain and citation-fixer on trigger
   "citation audit" — removed from maintain since citation-fixer is the
   specialized skill for that phrase. maintain still handles citation
   audits as part of broader health runs via its description.

3. dry_violation warnings on 7 brain-writing skills (ingest, enrich,
   setup, signal-detector, idea-ingest, media-ingest, meeting-ingestion)
   that inlined citation/Iron-Law rules without referencing the
   canonical skills/conventions/quality.md. Added a single `> **Quality
   rules:**` line next to each skill's existing filing-rule reference.
   The inline recap stays (it's useful local guidance); the convention
   file is marked as the source of truth.

Health score on a fresh install goes from 80 → 95. The only remaining
[WARN] on this brain is `embeddings` (real, user-actionable via
`pbrain embed --stale`).

Test coverage: two new cases for scanTargets — symlink into sibling
pbrain checkout (ours-elsewhere) and symlink into non-pbrain tree
(still foreign-symlink). Full unit suite: 979 pass, 0 fail.
joedanz added a commit that referenced this pull request Apr 17, 2026
…k checks (#26)

Three more classes of doctor noise cleared after PR #25:

1. skill_symlinks shadowed dump — the check classifies any symlink that
   doesn't resolve into the current repo as foreign, so users with a global
   install at ~/.pbrain-repo who also have a dev clone elsewhere saw all
   26×3 = 78 skills flagged as "shadowed by other plugins" on every
   doctor run. Added an `ours-elsewhere` state that walks up from the
   resolved symlink target looking for package.json with name: "pbrain" —
   deterministic detection, works for any pbrain checkout location.
   Doctor now reports `installed — claude: 26, cursor: 26, windsurf: 26
   (symlinks resolve to sibling checkout at <path>)` instead.

2. mece_overlap between maintain and citation-fixer on trigger
   "citation audit" — removed from maintain since citation-fixer is the
   specialized skill for that phrase. maintain still handles citation
   audits as part of broader health runs via its description.

3. dry_violation warnings on 7 brain-writing skills (ingest, enrich,
   setup, signal-detector, idea-ingest, media-ingest, meeting-ingestion)
   that inlined citation/Iron-Law rules without referencing the
   canonical skills/conventions/quality.md. Added a single `> **Quality
   rules:**` line next to each skill's existing filing-rule reference.
   The inline recap stays (it's useful local guidance); the convention
   file is marked as the source of truth.

Health score on a fresh install goes from 80 → 95. The only remaining
[WARN] on this brain is `embeddings` (real, user-actionable via
`pbrain embed --stale`).

Test coverage: two new cases for scanTargets — symlink into sibling
pbrain checkout (ours-elsewhere) and symlink into non-pbrain tree
(still foreign-symlink). Full unit suite: 979 pass, 0 fail.
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.

1 participant