Bug Report
gbrain version: 0.33.1.0
Engine: PGLite
Problem
gbrain orphans counts soft-deleted pages in its orphan scan. When you soft-delete a page with gbrain delete <slug>, the row remains in the pages table (recoverable for 72h), and the orphan query:
SELECT p.slug, ...
FROM pages p
WHERE NOT EXISTS (
SELECT 1 FROM links l WHERE l.to_page_id = p.id
)
...does not filter out soft-deleted rows (p.deleted_at IS NULL missing). This means:
- Soft-deleted orphan pages still inflate the orphan count.
- Soft-deleting pages that linked to other pages can cause previously non-orphaned pages to appear orphaned (their inbound links disappear).
Reproduction
# Create a page and link it to another
gbrain put test-page < <(echo '# Test')
gbrain link test-page some-other-page
# Orphan count — some-other-page should not be orphaned (has inbound link)
gbrain orphans --count # e.g., 100
# Soft-delete test-page
gbrain delete test-page
# Orphan count — some-other-page is now orphaned (inbound link gone)
# AND deleted test-page is still counted as orphan
gbrain orphans --count # e.g., 101 or higher
Expected Behavior
gbrain orphans should filter out soft-deleted pages:
WHERE p.deleted_at IS NULL
AND NOT EXISTS (SELECT 1 FROM links l WHERE l.to_page_id = p.id)
Impact
In multi-source setups where the same page slugs exist in both default and another source (e.g., after gbrain sync --repo imports into default while the same files are also managed by a named source), soft-deleting the duplicates to clean up does not reduce the orphan count until the 72h hard-purge window expires. The doctor's sources purge-orphan-clones command (tracked for v0.32.0) would help here.
Workaround
Wait 72h for the autopilot hard-purge phase to remove soft-deleted rows. No immediate fix available.
Bug Report
gbrain version: 0.33.1.0
Engine: PGLite
Problem
gbrain orphanscounts soft-deleted pages in its orphan scan. When you soft-delete a page withgbrain delete <slug>, the row remains in thepagestable (recoverable for 72h), and the orphan query:...does not filter out soft-deleted rows (
p.deleted_at IS NULLmissing). This means:Reproduction
Expected Behavior
gbrain orphansshould filter out soft-deleted pages:Impact
In multi-source setups where the same page slugs exist in both
defaultand another source (e.g., aftergbrain sync --repoimports intodefaultwhile the same files are also managed by a named source), soft-deleting the duplicates to clean up does not reduce the orphan count until the 72h hard-purge window expires. The doctor'ssources purge-orphan-clonescommand (tracked for v0.32.0) would help here.Workaround
Wait 72h for the autopilot hard-purge phase to remove soft-deleted rows. No immediate fix available.