#5770·gbrain

Managed atom re-extraction does not retire stale atoms after source edits

Author: cmontemuinoCreated Sep 30, 2026Updated Sep 30, 2026
Labelsbug

What happened?

After source pages are edited and extract_atoms runs again under managed persistence, atoms from older source revisions can remain active.

On one brain, gbrain doctor found 1,021 drifted atoms out of 2,559. 1,007 pointed to source pages that still existed but had changed. 14 pointed to source pages that no longer existed.

The stale atoms still appeared in search with quotes that were no longer present in current source pages.

A minimal regression reproduced the same behavior. The first extraction created two atoms. After editing the source and changing one extracted title, the second extraction left three active atoms instead of replacing the stale one.

If a generated atom file was already missing, managed publication could also fail with:

The canonical file was removed outside coordinated publication.

The request then surfaced as:

Publication failed. Inspect owner diagnostics.

What did you expect?

A successful managed re-extraction should retire atoms from older source revisions that were not reproduced.

Replacement writes and stale-atom retirements should belong to one durable batch. The completion checkpoint should advance only after both have committed.

A reviewed retry should reuse retained extraction output without calling the model again.

Missing files for derived atom pages should not block regeneration or retirement. Ordinary page writes should keep their existing missing-file safeguards.

Steps to reproduce

  1. Configure managed persistence with write-through enabled and an active local owner for a source.
  2. Create a source page and run atom extraction with output containing two atoms.
  3. Remove the generated atom files to simulate an interrupted or older publication state.
  4. Edit the source page so its content hash changes.
  5. Run extraction again with one atom title changed and one title retained.
  6. Query active atom pages for that source page, or run gbrain doctor .

Environment

  • gbrain version: 0.60.10.0
  • OS: macOS arm64
  • Bun version: 1.4.0
  • Database: self-hosted PostgreSQL with pgvector

gbrain doctor --json output

json
{
 "name": "atom_provenance_drift",
 "status": "warn",
 "message": "1021/2559 atom(s) (39.9%) reference a source_hash no live page carries; 1007 source pages still exist but were edited, and 14 source p
ages are gone."
}