sweep --once fails every pass on a managed Postgres brain served by serve --http
Environment: gbrain 0.57.0.0 (467ff67), macOS, bun 1.3.14, Postgres 17, installed via clone + bun link, managed persistence and shared skills activated, serve --http via mcp expose.
Expected
INSTALL_FOR_AGENTS.md:286-289:
Stdio
gbrain serveruns bounded startup/idle sweeps;gbrain serve --httpdoes not self-sweep. For HTTP, arrange explicit host-sidegbrain sweep --onceor extraction; use authorizedadd_linkcalls for edges needed immediately.
So on an HTTP-served brain, a host cron running gbrain sweep --once is the documented way to get fence reconcile, link/timeline extraction and corpus ingest.
Observed
GBRAIN_HOOKS=0 gbrain sweep --once --json, run from ~ while serve --http is live. It exits 1 on every run:
{
"corpusIngested": 0,
"factsReconciled": 0,
"linksExtracted": 0,
"linksRemoved": 0,
"timelineExtracted": 0,
"skipped": [
{ "reason": "facts_fence_error", "count": 1 },
{ "reason": "links_timeline_error", "count": 1 },
{ "reason": "already_ingested", "count": 31 },
{ "reason": "corpus_file_error", "count": 20 }
],
"durationMs": 377
}stderr (corpus lines collapsed, file names replaced with <file>):
[sweep] facts-fence pass failed: legacy fact-fence reconciliation cannot mutate a managed brain through the legacy writer.
[sweep] links/timeline pass failed: writer_coordinator_required: canonical writer must use the persistence coordinator
[sweep] corpus ingest failed for <file>.txt: The canonical fact writer is busy; extraction has not started. (x20)A smaller point: the --json report carries only reason codes. The underlying error text goes to stderr only, so a host job that keeps just the JSON cannot tell a managed-mode refusal from any other failure.
Code-level cause
- Pass 1, facts fence reconcile.
src/core/sweep.ts:187callsrunExtractFacts, which starts withassertUnmanagedCanonicalWriter(engine, 'legacy fact-fence reconciliation')(src/core/cycle/extract-facts.ts:362). That function (src/core/persistence/maintenance.ts:11-15) throwswriter_coordinator_requiredwheneverpersistence_brain.enabledis true. Caught atsrc/core/sweep.ts:200-201asfacts_fence_error. - Pass 2, link/timeline extraction.
runLinksTimelinePasswrites throughengine.addLinksBatch(src/core/sweep.ts:449) andengine.addTimelineEntriesBatch(src/core/sweep.ts:452) without agbrain.write_sourcesbinding. Themanaged_writer_guardtrigger (src/schema.sql:1883-1885, attached at:1895) raiseswriter_coordinator_required: canonical writer must use the persistence coordinator. Caught atsrc/core/sweep.ts:219-220aslinks_timeline_error. This is the same write path as theextract --stalerefusal in #5280. - Pass 3, corpus ingest. Per file, fact extraction goes through
src/core/persistence/facts-maintenance.ts:152-156: the binding's owner is this host,acquireWorktree(binding)returns null, and it throwswriter_lock_unavailable("The canonical fact writer is busy"). My reading, not verified: the runningserve --httpholds the worktree lock as owner, so a separate CLI process can never take it while the serve is up. Every file then counts ascorpus_file_error(src/core/sweep.ts:816).
isTotalFailure (src/commands/sweep.ts:58-66) then sees all three pass errors, prints a total-failure line and sets exit 1.
Serve delegation does not help here. maybeDelegateSweepToServe only delegates when a live serve holds a PGLite data dir (src/commands/sweep-delegate.ts:102-103, probeLivePgliteHolder). On Postgres it falls through to the local run above, and I found no idle sweep in the --http lane.
Consequence
On a managed brain served by serve --http, there is no documented way to run the sweep passes: serve --http does not self-sweep, and sweep --once, the documented host-side substitute, is refused in every pass. Pages written by remote put_page keep their links and timeline unextracted, fact fences stay unreconciled, and transcript corpus files stay unprocessed until something else picks them up.
Question
Should the sweep passes route through the persistence coordinator on a managed brain (or be delegated to the owner serve over IPC, as on PGLite)? If sweep --once is not meant to be supported on managed brains, could INSTALL_FOR_AGENTS.md name the supported alternative for HTTP-served managed brains?
Related: #5280 (managed-mode refusals of extract --stale, same write path as pass 2).
Source: garrytan/gbrain