Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/writer-terminal-visibility-6650
garrytan0e63f1f7b56b
diff --cc CHANGELOG.mdindex 0787ff3b24,f98be86348..c6f54dae60--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,21 -10,33 +10,48 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).- ## [0.60.219.0] - 2026-10-14++## [0.60.220.0] - 2026-10-14++**Writes that ended without committing are now summarized and explained, and the few that block work are named (#6650).** Every write leaves a receipt, and receipts that ended `failed`, `conflict` or `cancelled` used to pile up with no summary: an agent couldn't tell the one that holds a root from hundreds a later write already superseded or an older build left behind. gbrain now classifies each such receipt at read time (category, class, safe actions, whether a person decides, a structured fix) and stores nothing new. A new doctor check, `persistence_terminal_failures`, warns when a receipt blocks work now (a publication recovery record or a sync checkpoint blocker) or when an unresolved receipt is a gbrain-defect class. A 24-hour spike warns only when nothing else does, and a spike written by builds older than the fix says so, names the build and points at the write owner to upgrade or restart. Superseded rows and rows from builds older than their fixing release count as historical and never warn.++### Itemized changes++- **Classifier** (`src/core/persistence/terminal-classify.ts`): `classifyTerminal` routes each receipt by its recovery record, its typed knock-on marker, and the origin or cause it recorded. A receipt whose code and origin don't say what happened is `diagnosis_required`, and its fix is read-only writer status, never a guess. It also owns the supersession rule `gbrain repair failed-writes` uses.+- **Bounded readers** (`src/core/persistence/terminal-failures.ts`): one set-based aggregate with a 5 s statement deadline and a 2 s connection deadline; past either the result is `unknown`, never an empty pile. The drill-down scans at most 2,000 receipts per call and pages with a cursor. Thresholds: `persistence.terminal_failures.window_days` (default 7, clamped to `persistence.receipt_retention_days`), `spike_factor` (3) and `spike_min` (25).+- **`gbrain write-request <id>`** adds `write_error_reason`, `suggestion` and a `diagnosis` with a rendered `fix` for such receipts.+- **`gbrain sync status`** adds `terminal_failures` (active blockers, unresolved, historical, the drill-down command) and names a recovery record as `next` when nothing else is.+- **`gbrain sources writer failures <source>`** (read-only) lists the receipts or groups them (`--group-by category`), each group with an exact drill-down filter; a table by default, JSON with `--json`. A resident owner advertises the operation in a new `administration_extensions` capability key, so older clients and owners interoperate.+- **`/metrics`** (admin only) adds per-source gauges `gbrain_writer_terminal_failures_{active_blockers,unresolved,historical,new_24h,defects}` and `_known`, from one aggregate shared by every scrape for 60 s. `/health` is unchanged.+- **Fact-fence step** (`src/core/facts/unfenced-facts.ts`): the up-front lifetime-ID check counts only pages that will submit, so a page suppressed by a recent identical refusal, or one with nothing adoptable, no longer pushes the whole step to the cap and refuses it.+- Docs: [terminal write failures](docs/guides/troubleshooting.md#terminal-write-failures), the troubleshooting row, write-refusals and the maintain skill.++ ## [0.60.219.0] - 2026-10-14++ **A new brain made by `gbrain setup` is finished when setup ends, and a plain-English question to `gbrain recall` now finds facts on a brain without embeddings.** Before, `gbrain setup claude-code` (or `codex`) created a brain and then printed a line telling you to run `gbrain apply-migrations --yes --no-autopilot-install` yourself, so a fresh install still had setup migrations pending and `gbrain doctor` said so. Setup now runs those migrations itself, on the brain it just created, and says which ones it ran. Separately, on a brain with no embeddings, `gbrain recall "how does the user take their coffee"` printed "No matching facts." even when a fact about coffee existed, because recall looked for an entity with that whole sentence as its name. Now it ranks the facts against the sentence as a question and tells you it did.++ ### What you'd see++ | You run | Before | Now |+ |---|---|---|+ | `gbrain setup claude-code` on a new machine | `[init] Migrations: ...` plus a hand-off command to run | `[setup] Migrations: 14 recorded as not needed on a new brain; 5 setup migration(s) applied by setup without installing services (0.11.0, 0.14.0, 0.22.4, 0.28.0, 0.53.0); none pending.` |+ | `gbrain setup claude-code` on a brain that already exists | the hand-off line | the same hand-off line, nothing run |+ | `gbrain recall "how does the user take their coffee"` on a brain without embeddings | `No matching facts.` | the coffee fact, ranked first, with a note on stderr |+ | the same on a brain with embeddings | `No matching facts.` | `No matching facts.`, plus a stderr hint naming `gbrain recall --question "<q>"` |+ | `gbrain recall --help` | the generic one-line stub | recall's own usage, including `--question` |++ ### What to watch for after you upgrade++ - On a brain without embeddings, a multi-word `gbrain recall "<text>"` that matches no entity and no fact text now prints ranked facts instead of "No matching facts." Scripts that relied on the empty result should pass `--grep` or check the stderr note. Brains with embeddings return exactly what they did before.+ - If `~/.claude/AGENTS.md`, `~/.openclaw/AGENTS.md` or an OpenClaw cron manifest already exists, setup does not run v0.11.0 (which would edit that file). It leaves that one migration pending and names the file and the command to run it.+ - `gbrain init` on its own is unchanged and still prints the hand-off line.++ ### Itemized changes++ - **Setup finishes a brain it created** (`src/commands/setup-migrations.ts`, called from `src/commands/setup.ts` only when this run created the brain): one `gbrain apply-migrations --yes --no-autopilot-install --json` child, bounded at 60 s, with `GBRAIN_NO_AUTOPILOT_INSTALL=1`. These migrations are local ledger, schema and file work: no provider calls, no paid work, no services installed, and they run offline. The summary line replaces init's `[init] Migrations:` line. If the run fails, init's line stays with `(setup ran it and it failed: <code>)` appended. Verify output is unchanged.+ - **Host files are never edited silently** (`src/commands/migrations/v0_11_0.ts` `hostRewriteTargets`): setup holds back v0.11.0 when any file its host phase would rewrite already exists.+ - **Keyless question fallback** (`src/commands/recall.ts`, `src/core/facts/keyword-only.ts` `factRecallIsKeywordOnly`): applies only when fact recall is keyword-only (embedding opted out or no provider configured) and the positional has several words and matched nothing. It ranks with the same path as `recall --question` and writes `[recall] no entity or fact text matched '<q>'; ranked facts by relevance to it as a question (keyword-only: this brain has no embeddings).` to stderr.+ - **`gbrain recall --help`** prints `Usage: gbrain recall [<entity>] [options]` with every option, and works without a configured brain.+## [0.60.218.0] - 2026-10-14**Fencing legacy facts no longer leaks, loops or blocks.** When a legacy fact is adopted into a fence row that an earlier, interrupted run left behind, the row is now rebuilt from the stored fact, so the fact's own kind, dates, confidence, visibility and speaker attribution are kept. Before, a leftover row with a different visibility made the adoption refuse every time, and one with the same visibility overwrote the fact's metadata. A managed adoption that gbrain refused as a planning defect is no longer resubmitted every cycle, so the writer stops collecting one identical failed request per page per cycle. And one fact that can't be fenced now holds up only its own page: the phantom-redirect pass runs for the rest of the source.diff --cc src/core/behavior-change-notice.tsindex e96c7490a8,3c30a028bd..ac71541d34--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -550,9 -550,9 +550,12 @@@ export const BEHAVIOR_CHANGES: Readonly{ since: '0.60.218.0', text: 'Fencing a legacy fact into a fence row a partial earlier run left behind now rebuilds that row from the stored fact: the published row carries the fact\'s own visibility, kind, validity, confidence and speaker attribution instead of the leftover cell\'s, a leftover private row is never reused for a world fact (the world fact gets its own row), and a newly fenced fact keeps its `attributed_to`. Before, a leftover row with a different visibility made the adoption refuse every time, a leftover row with the same visibility overwrote the fact\'s kind, dates and confidence, and every adoption cleared the fact\'s speaker attribution.' },{ since: '0.60.218.0', text: 'A managed fact-fence adoption refused as a planning defect (`fence_unrenderable`) is no longer resubmitted every cycle: for a day after the refusal the page is reported as unadoptable (`prior_refusal`), then it gets one more try, or right away once the adoption planner changes. The writer stops collecting one identical failed request per page per cycle.' },{ since: '0.60.218.0', text: 'The `extract_facts` phantom-redirect pass no longer waits for the whole source to have no unfenced legacy fact rows: it holds only the top-level pages that own such rows or are the provenance page of an ontology observation (`phantoms_held_legacy_rows` in the cycle report), and redirects the rest.' },+ // Cat 41 run 4 (GBRA-60). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.+ { since: '0.60.219.0', text: 'When `gbrain setup claude-code` or `gbrain setup codex` creates a new brain, it now runs the setup migrations `gbrain init` leaves pending (the same `gbrain apply-migrations` run, without installing services) and prints `[setup] Migrations: ... none pending.` in place of init\'s "Finish setup" line, so there is nothing left to run. If an existing ~/.claude/AGENTS.md, ~/.openclaw/AGENTS.md or OpenClaw cron manifest would be edited by v0.11.0, setup leaves v0.11.0 pending and names the file and the command. A brain that already existed is not touched, and `gbrain init` on its own still prints the hand-off line.' },+ { since: '0.60.219.0', text: 'On a brain without embeddings, `gbrain recall "<a question>"` (several words that match no entity and no fact text) now ranks facts by relevance to the question, as recall\'s question option does there, with a note, instead of printing "No matching facts." On a brain with embeddings the output is unchanged apart from a hint naming the question command. Recall\'s help now prints its own usage, including the question option.' },+ // #6650 (writer terminal-state visibility). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.- { since: '0.60.218.0', text: 'Writes that ended `failed`, `conflict` or `cancelled` are now summarized instead of only piling up as receipts. A new doctor check, `persistence_terminal_failures`, warns when a receipt blocks work now (a publication recovery record or a sync checkpoint blocker) or when an unresolved receipt is a gbrain-defect class, and on a 24-hour spike only secondarily, naming the build when an older write owner is producing them (`persistence.terminal_failures.window_days`, `spike_factor`, `spike_min`; defaults 7, 3, 25); rows a later write superseded, or from a build older than the release that fixed their cause, count as historical and never warn. `gbrain sync status` adds `terminal_failures` and names a recovery record as `next` when nothing else is. `gbrain write-request` adds `write_error_reason`, `suggestion` and a `diagnosis` with a structured fix for such receipts. New read-only `gbrain sources writer failures <source>` lists or groups them (`--group-by category`). The admin-only `/metrics` adds per-source counts; `/health` does not change. Nothing new is stored.' },- { since: '0.60.218.0', text: 'The managed fact-fence step (`extract_facts`, the v0.32.2 adoption) now checks the permanent request-ID caps against only the pages that will submit an adoption. A page suppressed by an identical refusal in the last day, or one with nothing adoptable, no longer counts, so it can no longer push the whole step to the cap and get it refused.' },++ { since: '0.60.219.0', text: 'Writes that ended `failed`, `conflict` or `cancelled` are now summarized instead of only piling up as receipts. A new doctor check, `persistence_terminal_failures`, warns when a receipt blocks work now (a publication recovery record or a sync checkpoint blocker) or when an unresolved receipt is a gbrain-defect class, and on a 24-hour spike only secondarily, naming the build when an older write owner is producing them (`persistence.terminal_failures.window_days`, `spike_factor`, `spike_min`; defaults 7, 3, 25); rows a later write superseded, or from a build older than the release that fixed their cause, count as historical and never warn. `gbrain sync status` adds `terminal_failures` and names a recovery record as `next` when nothing else is. `gbrain write-request` adds `write_error_reason`, `suggestion` and a `diagnosis` with a structured fix for such receipts. New read-only `gbrain sources writer failures <source>` lists or groups them (`--group-by category`). The admin-only `/metrics` adds per-source counts; `/health` does not change. Nothing new is stored.' },++ { since: '0.60.219.0', text: 'The managed fact-fence step (`extract_facts`, the v0.32.2 adoption) now checks the permanent request-ID caps against only the pages that will submit an adoption. A page suppressed by an identical refusal in the last day, or one with nothing adoptable, no longer counts, so it can no longer push the whole step to the cap and get it refused.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */