Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
6.6 KB
Raw Blame

Upgrade to v0.60.102.0: malformed facts and takes fences repair themselves

Since v0.60.98.0 a facts or takes fence gbrain cannot import is held instead of blocking a sync, and since v0.60.99.0 a fence with one exact meaning is rewritten in the same write. This release repairs the rest: the maintenance run's new fence_repair phase repairs held files and stored pages by itself, and gbrain repair fences previews and applies the same repair on demand. No schema migration.

The repairs need no extra consent, but they rewrite the user's files: tell the user what the first maintenance run will change (step 2) before it runs, and leave spend decisions to them (step 3).

  1. Finish the upgrade. gbrain upgrade runs it. To be sure, on the brain host:

    gbrain apply-migrations --yes --no-autopilot-install
    

    No schema migration and no rows are rewritten by the upgrade itself. Restart every gbrain serve, autopilot and worker so the maintenance run picks up the fence_repair phase.

  2. Tell the user what the first maintenance run rewrites. The first maintenance run after the upgrade repairs every malformed fence it finds across each source (held files, stored pages and checkout files not yet synced), rewriting those files and committing each one (a legacy source's files are backed up and left for the user to commit). Show the user the count and the plan first:

    gbrain doctor --only fence_integrity      # malformed fences per source, by the tier that fixes them
    gbrain repair fences --source <id>        # preview: read-only, no model call
    

    If the user wants to review before anything is rewritten, pause the automatic repair first:

    gbrain config set fences.repair.enabled false
    

    Then apply what they approve with the preview's printed gbrain repair fences --source <id> --apply --expect <hash> (select files with --only / --skip, stored pages with --slug), and resume with gbrain config set fences.repair.enabled true. Syncs and writes keep rewriting fixable fences inline either way; gbrain config set fences.normalize false makes them hold such a fence instead.

  3. Spend and what leaves the machine. Most repairs are free rules. A fence only a rewrite can realign goes to the repair model: only the fence header and the rows it must realign are sent, never valid rows and never the rest of the page, and the model answers HOLD instead of guessing when a row has two readings. With models.fence_repair unset, the repair model is the first model the fence-repair eval measured as accurate enough whose provider key the brain has: openai:gpt-6.1-sol (OpenAI key), else anthropic:claude-opus-5-5 (Anthropic key). With neither key, model repair stays off and those fences wait as no_measured_model; which model to trust is the user's call (gbrain config set models.fence_repair <provider:model>; a model set there always runs). Spend is capped at $0.30 per page (fences.repair.max_usd_per_page) and $1.00 per UTC day (fences.repair.max_usd_per_day) across every process, through a durable ledger; each call reserves its worst case (the prompt plus the full output ceiling, with room for a reasoning model to think) and settles what it really cost. A repair model gbrain has no price for still runs under these default caps, metered at an estimated ceiling (the highest chat rate gbrain knows); under a cap the user set it waits until its price is registered with gbrain pricing set. Every proposed rewrite passes the validation gates before it is written. To keep fence rows away from the model:

    gbrain config set fences.repair.llm false
    

    The free tiers keep running. Raising a cap or turning model repair back on is the user's call.

  4. Tell the user what stays held.

    gbrain sources status <id>      # each fence hold: reason, fence, section, rows, next attempt
    

    A hold whose reason is manual is something gbrain never guesses (a stray end marker, an unknown takes kind, a weight out of range, extra cells that removing empty cells cannot line up, a sentence in the facts kind column: often a claim cut in two by an unescaped |). Show the user the location, edit only that fence in the file, commit, then gbrain sync --source <id> --no-pull. A hold waiting on the daily cap (budget_exhausted) resumes after 00:00 UTC. Each reason's fix: docs/guides/write-refusals.md#invalid_fence; the format: docs/guides/fence-format.md.

  5. Inspect or undo a repair.

    • Managed sources: each repaired file is committed with the subject gbrain: repair fence in <path> (<classes>). git log --grep 'repair fence in' lists them, git show <commit> shows the change, and git revert <commit> undoes it (for one file of a commit that lists several, git checkout <commit>^ -- <path> and commit).
    • Database-only pages: gbrain history <slug> shows every version, including the one before the repair, and gbrain revert <slug> <version_id> restores it. A managed brain refuses a version whose fence it cannot import; then read the old rows from the history and write them again with remember or takes_add.
    • Legacy (unmanaged) sources: the original file is backed up under ~/.gbrain/backups/ (the repair output names the path); copy it back and sync.

    Turning the settings off stops future repairs and does not undo past ones. A restored malformed fence is held again on the next sync and repaired again by the next maintenance run, so pause first (gbrain config set fences.repair.enabled false) if the user wants to keep the original.

  6. Which steps need the user.

    • Nothing to approve for the repairs themselves: the maintenance run and gbrain repair fences --apply need no extra consent.
    • Tell the user before the first maintenance run (step 2); pausing is their choice.
    • Raising a cap (fences.repair.max_usd_per_day, fences.repair.max_usd_per_page), turning model repair back on (fences.repair.llm true), choosing a repair model (models.fence_repair), registering a model price, the content of every manual edit, and undoing a repair are the user's calls.
    • Relay the one-time behavior_changes notice when gbrain prints it (gbrain doctor --only behavior_changes shows it again).
  7. Verify:

    gbrain doctor --only fence_integrity,git_held_files --json
    gbrain sources status --json
    

    fence_integrity is ok when no malformed fence is left; it never reports ok while a scan is partial.