Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
6.4 KB
Raw Blame

version: 0.32.2 feature_pitch: headline: "Facts join the system-of-record — your hot memory now lives in markdown" description: "Backfills eligible legacy facts to existing canonical entity-page fences. Facts without a verified page or file remain in the database and need a database backup. Includes a 3-layer privacy strip and a CI gate for canonical write paths." recipe: null tiers: null

v0.32.2 Migration: facts join the system-of-record

What this is

This guide describes the current v0.32.2 orchestrator, including its safety checks in v0.50.2.0. Eligible legacy facts are copied into a ## Facts fence on an existing canonical entity page. Unresolved facts and other DB-only knowledge are not reconstructible from Markdown alone; preserve a restorable database backup as well as source files.

What the agent needs to do

For hosts with pending legacy facts:

  1. If upgrading from before v0.50.0.0, complete the coordinated authorization cutover first. On a compatible host, inspect gbrain apply-migrations --list and preview the plan with gbrain apply-migrations --migration 0.32.2 --dry-run. After reviewing backups and affected sources, run gbrain apply-migrations --migration 0.32.2 --yes.
  2. The orchestrator checks the schema, fences eligible facts, then verifies that each page's fence and its indexed facts carry the same row numbers (a duplicate active fence row may be indexed once; a page deleted after all of its fenced rows expired is reported as skipped_expired_no_page, not as drift, while a missing page with a live row still fails). Only live legacy rows with an existing source-scoped page and canonical file are eligible; on a brain without managed persistence, a database-only page (no recorded origin and no file at its slug path) is fenced in its database body when that write is database-only, and a source with a checkout but no owner and persistence.unbound_write unset leaves its rows as skipped_unbound_source. Missing targets are reported as skipped_no_page; no stub is created. Existing fence and database row numbers remain reserved. Row-number verification is not full content parity. --dry-run previews the migration plan; there is no --write flag.
  3. Dirty-tree refusal applies only to the source subtrees receiving writes. If verification fails, inspect the reported drift before retrying. For a wedged orchestrator, gbrain apply-migrations --force-retry 0.32.2 resets its retry marker; rerun the selected migration afterward. 51 is a schema migration number, not the orchestrator version accepted by --force-retry.
  4. After completion: git diff shows the new fences; user can commit them and the facts now live in git alongside the rest of the brain.

For brand-new v0.32.2 installs (rare):

The schema migration v51 creates the columns from the start (fresh-install parity via the v40 CREATE TABLE block). The v0_32_2 orchestrator has nothing to backfill (no legacy rows). Its schema, fencing, and verification phases complete without creating fact rows.

For thin-client installs:

Run migrations on the brain host, not the thin client. Host sources without a local path are counted as skipped_no_local_path; their facts remain in the database. Do not invent entity pages or delete unmatched facts to make the migration appear complete.

Things that changed for the agent

  1. gbrain forget <id> now rewrites markdown. Previously gbrain forget called engine.expireFact(id) which UPDATEd the DB only. After a rebuild of the database from the repo the forget would evaporate. v0.32.2 makes forget rewrite the fence: strikethrough the claim, set valid_until=today, append forgotten: <reason> to the context cell. New optional --reason <text> flag.

  2. MCP get_page strips private fact rows for remote callers. Previously the strip fired only when the caller carried a takes- holders allow-list (a subagent privacy hole). v0.32.2 fires the strip whenever ctx.remote === true. Local CLI sees the full fence; subagent / remote MCP see world-only facts.

  3. The chunker strips private fact text. chunkText calls stripFactsFence({keepVisibility:['world']}) alongside the existing stripTakesFence before chunking. Private fact text never reaches content_chunks.chunk_text, never gets embedded, never returned by search.

  4. CI invariant gate. scripts/check-system-of-record.sh is wired into bun run verify. It bans direct calls to engine.insertFact, addLink, addLinksBatch, addTimelineEntry, upsertTake, insertFacts, expireFact in src/ + scripts/. Legitimate sites carry // gbrain-allow-direct-insert: <reason> comments on the same line. New code that tries to bypass the reconcile layer fails the build.

  5. New cycle phase extract_facts runs between extract and recompute_emotional_weight. Reconciles the DB facts index from the fence on every affected entity page. Empty-fence guard refuses to run while v0.31 legacy rows are pending the backfill (a belt to the orchestrator's suspenders).

Verification

After the agent runs the migration:

# Inspect migration status without applying other pending work
gbrain apply-migrations --list

# No fence write failures
test ! -f ~/.gbrain/facts.write_failures.jsonl || echo "WARN: some failures recorded"

# Each entity page with v0.31 facts now has a fence
ls people/ companies/ | head -5
grep -l 'gbrain:facts:begin' people/*.md | head -5

# Doctor passes
gbrain doctor

Things to NOT do

  • Don't manually edit the v51 columns. row_num and source_markdown_slug are managed by the fence-write path. Edit the markdown fence instead; the cycle phase reconciles.
  • Don't call engine.insertFact / expireFact from new code paths. The CI gate blocks it. If you genuinely need a direct write (e.g., for a new reconciler), add the // gbrain-allow-direct-insert: <reason> comment with a justification.
  • Don't delete the facts.write_failures.jsonl log without reading it. It records pages where the fence parse-validate failed during a write; the .tmp file remains as quarantine evidence.

See also

  • docs/architecture/system-of-record.md — the canonical contract doc + the 3-layer privacy boundary
  • CHANGELOG.md v0.32.2 entry — the release manifesto + numbers
  • scripts/check-system-of-record.sh — the CI gate enforcing the rule going forward