Managed brains: repair visibility (and any managed write) refuses legacy file-less atoms as "canonical file removed"
What happened?
On a managed brain, gbrain repair visibility --apply (new in v0.60.5.0) stops with The canonical file was removed outside coordinated publication. on legacy atoms, so they stay unstamped and remote reads keep hiding them. Nothing was removed: those atoms never had a file.
The chain:
- Before managed persistence is activated,
extract_atomswrites atoms throughimportFromContent: database-only, no file,source_pathandsource_urinull.atoms/is inDERIVE_PHASE_DB_ONLY_DEFAULTS, anddocs/storage-tiering.mdsays derive-phase prefixes need nogbrain.ymldeclaration (they are deliberately kept out ofloadStorageConfigso they are never auto-gitignored). - Activating managed persistence leaves those atoms as they are, and doctor's
undeclared_db_only_pagesreports them as healthy. - v0.60.5.0 (#5525) treats unstamped atoms as private for remote reads and ships
gbrain repair visibilityto stamp them. - The repair publishes each atom with
submitPageMutation(put_page).prepareFileTargetfinds no file for an existing page and accepts that only whenisSourceDbOnlySlugputs the slug under a declareddb_onlydir; otherwise it throwssource_changed. Derive-phase defaults are never declared, so every legacy atom is refused.
So a brain that extracted atoms before switching to managed persistence ends up with legacy atoms that remote readers cannot see and the repair cannot stamp, and the error tells the operator a file was deleted. test/derived-visibility-repair.test.ts runs the repair without the coordinator, which is why this does not show there. Atoms extracted after activation are file-backed (managed atom writes go through preparePageMutation), so this hits legacy atoms and any other never-filed page under the derive-phase prefixes (synthesized concepts/, extracts/).
What did you expect?
The repair stamps legacy atoms from their origin (world, when the origin page is public), with gbrain.yml untouched, since the docs say derive-phase prefixes need no declaration. Declaring atoms/ under storage.db_only does make the repair pass, but it contradicts the documented design (it gitignores atoms/, which breaks brains that do file-back atoms).
Steps to reproduce
- On a non-managed brain, extract atoms (
gbrain dream --phase extract_atoms), or import an atom page withimportFromContent, so atoms exist database-only. - Activate managed persistence.
- Upgrade to v0.60.5.0: doctor shows
derived_visibilitywarn with the unstamped atoms. gbrain repair visibility --apply→The canonical file was removed outside coordinated publication.
A minimal repro is in the linked PR (test/grandfather-managed.test.ts).
Environment
- gbrain version: 0.60.5.0 (same code in 0.60.6.0), managed persistence, writer claimed
- OS: Linux
- Bun version: 1.4.2
- Database: self-hosted Postgres 17
gbrain doctor --json output (relevant checks)
derived_visibility: warn — N derived page(s) have no explicit visibility (N atoms, 0 concepts) and 0 are stored looser than their origin; remote reads treat the unstamped ones as private.
undeclared_db_only_pages: ok — Every DB page is file-backed or under a declared/default db_only path (derive-phase defaults: life/events/ atoms/ concepts/ extracts/ dream-cycle-summaries/)Proposed fix
PR to follow: in prepareFileTarget, a page under a derive-phase default prefix that never recorded a canonical file (no source_path, no source_uri) publishes database-only, like a declared db_only page; a page whose recorded file went missing still refuses. If you would rather keep prepareFileTarget strict, the alternatives are to have the visibility repair (and other maintenance writers of derived pages) publish database-only for never-filed derived pages, or to file-back legacy derived pages at managed activation.
Source: garrytan/gbrain