Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(changelog): fix wave 16 entry (header provisional until the merge slot)
garrytan55c0dac6a2ac
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d6da2a2361..da71182350 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,76 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.186.0] - 2026-10-12++**Fix wave 16: a page purge no longer holds its source hostage, duplicate-origin twins can be retired, managed sync's leftover bookkeeping has a repair instead of a permanent red doctor, fact extraction stops refusing whole entities for one forgotten claim, long items are no longer certified complete when the model read only their head, four community CLI and platform fixes land, the three test files failing CI without a product bug are fixed at the root, and the nightly routing eval is green again (#6511, #6517, #6518, #6513 follow-ups, #6506, #6523, #6503, #6333, #6521, #6512, #6514, #6510, #5312 in part, #6040, #6495 in part).** `gbrain delete <slug> --purge` searched the source's whole write journal inside its 5-second publication transaction and a timeout there was requeued forever, blocking every later write to the source; the search now runs at preparation under the preparation budget and the in-transaction lookups fail terminally. Two live pages recording one file had no supported exit short of raw SQL; a soft delete now keeps the file and hides the page. On a managed brain one forgotten claim refused the entity's whole fact group; the claim is skipped and counted. `extract_atoms` stamped an item complete after reading a 50,000-character head and could later retire the atoms a larger cap had produced from the tail; it now records the item as partial. Two additive migrations (v240 online index, v241 nullable column), no paid model call added, no change to any weights file. Plan reviewed by three voices and approved by Garry on 2026-10-12.++### Itemized changes++**Persistence: purge, origins, request indexes (#6511, #6517)**++- **Page purge journal sweep at preparation (#6511).** `preparePagePurge` (`src/core/persistence/page-purge.ts`) reads the page's claims (fact rows and takes filed on the page, trimmed, 8 characters or longer, at most 32 needles) and runs `sweepRequestsCarrying` (`intent-redaction.ts`) at claim steps `purge_claims` / `purge_journal_sweep`: a keyset walk of the source's journal in 2,000-row chunks, every needle in raw and JSON-escaped form against intent, outcome, error detail and error message, compacted rows included, stopped by the claim clock between chunks and at the 10,000-match cap. The sweep records the `sequence` ceiling and the rows pending at the scan; the publication transaction re-checks only the tail past the ceiling and those rows, so a carrying request admitted-then-cancelled or settled after the scan is still redacted and a request still queued at publication is left in place. The committed receipt reports `journal_sweep` (`ceiling`, `scanned`, `tail`, `pending_rechecked`, `complete`); `complete: false` means a cap was hit and is never swallowed. A sweep that outruns the preparation budget is a charged `preparation_deadline` release and `preparation_stalled` at the attempt limit, never a transaction timeout.+- **`purge_lookup_timeout` (#6511).** The lookups that stay inside the transaction (the slug lookup, the tail and pending re-checks, the locking read of `redactRequestIntents`) map a 57014 statement timeout to the terminal, non-retryable `purge_lookup_timeout` on the first claim: nothing removed, tombstoned or redacted, the failed receipt retained, a following write to the source commits, a same-id retry returns the failure and a new `request_id` is admitted. The message names `gbrain repair request-indexes --apply` only when the slug index is missing or INVALID. Registry row (`class: caller`, `actor: host_admin`), `docs/guides/write-refusals.md#purge_lookup_timeout`. `purge_fact` (`src/core/facts/purge.ts`) maps the same timeout of its planning read to the same code.+- **Migration v240 `persistence_request_slug_intent_index` (#6511).** Partial index `persistence_requests_slug_intent ON persistence_requests(source_id,slug,sequence) WHERE intent IS NOT NULL AND NOT compacted`, built online in the `v179` shape (`transaction: false`, CONCURRENTLY on Postgres after dropping an INVALID leftover, inline on PGLite). `readRequestIndexStates`, doctor `persistence_request_indexes` and `gbrain repair request-indexes` cover it through `PERSISTENCE_REQUEST_ONLINE_INDEXES`. DDL only: no column, no backfill.+- **Fault seams (#6511).** `purge:slug_lookup`, `purge:tail_recheck`, `purge:pending_recheck`, `purge:redaction_read`, `purge:sweep_chunk`, `purge:carrying_lookup` in `fault-points.ts`; production never installs a hook; the tests inject a 57014 or a stall at these seams, never through an SQL substring.+- **One origin rule (#6517).** `selectOriginClaimant` (`src/core/persistence/sync-origin.ts`) decides which page an origin file identifies when several pages record it: a live page wins over tombstones; several live pages refuse; a single tombstone may be reused; several tombstones stay ambiguous. Discovery's census (`sync-discovery.ts`, the one-statement identity snapshot now carries `deleted_at`) and `assertSyncPageOrigin` both apply it, so a soft-deleted twin no longer blocks the survivor's imports; the `page_identity_changed` refusals for several live claimants name the soft-delete exit. `assertSoleFileClaim` (`reconcile-state.ts`) uses the same census.+- **Shared-origin soft delete (#6517).** `delete_page` of a page whose file another live page of the source records (`findLiveFileClaimants`, new `src/core/persistence/file-claims.ts`) keeps the file and publishes database-only before any byte comparison: receipt `write_through.skipped: 'shared_origin'` with the warning "The selected database page is hidden; the file and the surviving page remain. This does not erase that file's contents." and the `gbrain sync --source <id> --no-pull --full` that imports the kept file into the surviving page. The survivor is revalidated under the publication guards; the file moved or removed, or a different set of claimants, refuses `source_changed` and never removes the file as a fallback. A purge of a shared-origin page refuses and names the soft delete. The receipt names the surviving slug to the trusted local owner and to a remote writer whose grant, delegated namespace and page visibility independently cover it (`slugDisclosable`, `authority.ts`); every other remote writer reads "Another page of this source records the same file." with no slug and no path.++**Managed sync bookkeeping and diagnostics (#6518, #6513 follow-ups)**++- **Stale bookkeeping of a source incarnation the source no longer has is retirable; `doctor --fast` no longer reports a vanished failure as FAIL (#6518).** A source re-pointed at a new checkout, or removed and added again, left its old cursor, failure row and local-ledger mirror under the previous incarnation: `gbrain sync status` named a cursor no current sync could select, `readManagedSyncFailures` saw nothing while `doctor --fast` still failed on the mirrored row. `gbrain repair managed-sync-orphans --source <id>` now lists such rows as `incarnation_retired` and ledger rows whose durable failure row is gone as `mirror_only`, and applies them under the printed hash; a successful sync prunes a source's stale mirror rows. `gbrain doctor` (with a database) classifies the orphans and names the repair even when no current failure is visible; a classification that fails names its code and is never reported healthy. `gbrain doctor --fast` (no database) reports mirrored managed rows as `warn` "could not be verified without a database connection" instead of `fail`, while old unmanaged file failures keep their severity. `gbrain sync status --source <id> --json` reports an old-incarnation cursor as `cursor: null` with `last_error.code: cursor_incarnation_retired` and the repair preview as `next`.+- **A checkpoint whose cursor another run of the same source replaced is superseded, not failed (#6513 comments).** When a `--retry-failed` rediscovery or a newer sync replaced the cursor while an older run's final checkpoint was in flight, the loser's checkpoint refused `revision_conflict`, its run recorded a managed-sync failure, `gbrain doctor` reported it as unresolved and `--retry-failed` treated the receipt as a page fault. The refusal is now `sync_cursor_replaced` (receipt state `conflict`; new `sync-checkpoint-replaced.ts`), nothing is recorded for the superseded checkpoint, the run that awaited it goes on with the cursor that now covers the source, and `--retry-failed` converts nothing. A same-run index lag still reports `revision_conflict`; a missing manifest still reports `storage_error`.+- **A publication a database trigger refuses names the trigger, its table and a closed reason wherever the failure is shown (#6513 comments).** A managed sync blocked by a trigger gbrain does not know said only `storage_error: Publication failed (P0001 in <raiser>). Inspect owner diagnostics.`; the receipt's `write_error_detail` was the one place that named the raiser and table. The failure the run records, the failure ledger, `gbrain doctor` and `gbrain sync status --json` (`last_error.write_error_detail`, `last_error.detail`) now carry `raiser`, `table` and a `reason` from a closed set (`PUBLICATION_REASONS`): `attribution_unclassified_table` or `trust_unclassified_table` (a gbrain stamp trigger met a table it is not built for: a version mismatch between processes sharing the database), `graduation_in_progress` (the engine-graduation fence, SQLSTATE 55000, now recognized with a retry-later message instead of an owner-exception `storage_error`, and classified retry / no human in `sync status` and `sync unblock`), or `unknown`. The trigger's message text is kept nowhere: not on the receipt, not on the brain host.++**Facts and extraction (#6506, #6523, #6503, #6333, PR #6515)**++- **Managed automatic fact extraction skips a forgotten claim instead of refusing the entity (#6506; supersedes #6507, contributed by @BichengWang).** Sync import, `put_page`, `extract_facts` and the sweep skip a candidate whose exact claim was forgotten in that source and visibility and publish the entity's other facts, counting the skips as `withdrawn_skipped` on the entity and completion receipts and the extraction result; before, one forgotten claim refused the whole group with `fact_withdrawn`. `remember` of the forgotten claim and a purge tombstone still refuse. A claim forgotten between preparation and publication refuses that entity's write with `revision_conflict` and a detail naming the withdrawal. An input-keyed extraction recovers from such a refusal, and from a batch an older release refused for a forgotten claim, on its next run: the retained facts are re-admitted as a follow-up batch with no model call (`followWithdrawalRefusals`), at most three times per batch, historical receipts untouched.+- **The claude-cli provider maps Claude Code's output-cap envelope to `finishReason: 'length'` (#6523; supersedes #6525, contributed by @javieraldape).** "API Error: Claude's response exceeded the N output token maximum…" (any cap, any exit code, no `api_error_status`) becomes a length-limited answer with empty text and the usage as reported, so the escalation ladders fire again: `loops_extract` 2048 → 8192 and the facts extractor 1× → 2×. Every other error envelope stays a typed `ClaudeCliProcessError`.+- **`extract_atoms` no longer certifies an item complete when its text was cut at `cycle.extract_atoms.max_input_chars` (#6503; report and first visibility slice by @herman6888).** The head is extracted once and its atoms kept, but no completion stamp is written, no earlier atom is retired, the phase result and `gbrain dream --drain` count the item under `input_truncated` with a stderr line naming the knob, and the item is skipped with no model call until the cap rises or its content changes. Migration v241 adds nullable `partial_input_chars` to the two extract_atoms state tables; a managed brain records `partial` on the item's checkpoint and the completion receipt reads `status: 'partial'`. The cut moves to new `src/core/cycle/extract-atoms-input.ts`. #6503 stays open for the chunk+overlap feature.+- **The #6333 same-page rewording shadow counter also fires on a managed brain.** New `src/core/facts/same-page-shadow.ts` is shared by the backstop and `facts-prepare.ts`; managed extraction counts `would_dedup_same_page` on the entity and completion receipts and the `extract_facts` result and prints the same stderr line; nothing is dropped; the measurement can now accumulate on a managed brain (#6334 stays open).+- **Two managed enumeration regressions for the #6500 contract**, carried as already-green tests in `test/conversation-facts-managed.test.ts` (the production fix landed in #6516): a slug keyset drains a 23-page timestamp tie without crossing source, type or soft-deletion fences, and a 13-page extraction walk survives a mid-run edit of its oldest unvisited page (supersedes #6515, contributed by @javieraldape).+- #6508 (conversation segment tail clip) was already fixed by v0.60.177.0's window bounding; closed with that pointer.++**CLI and platform (#6521, #6512, #6510, #5312 in part)**++- **`gbrain core <sub> --help` and `gbrain loops <sub> --help` answer before any engine access (#6521, reported by @benswinney).** `core` and `loops` are routers in `src/cli/subcommands.ts` and `src/cli/router-help.ts`; `src/commands/core.ts` and `src/commands/loops.ts` export their `SUBCOMMANDS` and `printUsage`, and `gbrain transcripts status --help` answers the help flag instead of opening the brain. A 14-row table in `test/cli-help-without-brain.test.ts` runs each subcommand's `--help` with no brain configured (on master `internal_error: null is not an object`).+- **A compiled binary installed from a hoisted `node_modules` reaches its PGLite diagnostic (#6512, contributed by @tarush1989).** `src/core/pglite-embedded-assets.ts` imports `@electric-sql/pglite` lazily inside `build()`, so loading the module no longer needs the package and the tier-3 "PGLite assets missing" message is the one the user sees.+- **The Git-scope manifest refuses symlinks, not a filesystem's spelling of a tracked path (#6510; supersedes #6520, contributed by @javieraldape).** `trackedBytes` in `src/core/persistence/worktree-manifest.ts` `lstat`s every directory component and the leaf of each tracked path through Git's own spelling, so a path whose on-disk spelling differs (NFD on macOS, a case-folding volume) reads as the tracked file it is while a symlinked component or leaf is still refused.+- **Backup data-dir sweep on Windows: an owned socket the runtime cannot inspect is probed and claimed, removed only through the native tag check, otherwise kept and named (#5312, part A; native re-test by @xiaopeng6390).** `entryStat` in `src/core/backup/runtime-artefacts.ts` returns `Stats | 'missing' | 'unreadable'`; an unreadable owned entry is removed only via `removeStaleWindowsSocket`, anything nothing can verify is kept as `unreadable` and the refusal says `cannot inspect`. The `windows-latest` row of `test.yml` runs the test natively. The `private_backup_path_unavailable` text names the inherited-permissions cause and the fix (`docs/guides/in-agent-setup.md`).++**Search operations (#6495 in part, #6040)**++- **Postgres keyword search has an operator time bound, `search.keyword_statement_timeout_ms` (Refs #6495).** The keyword, keyword-count, keyword-page, title and CJK search statements used to run under a fixed 8 s `statement_timeout`; they now share one knob (integer milliseconds, default 8000, range 1000–60000; `gbrain config set search.keyword_statement_timeout_ms 20000`, then restart the serving process). It is resolved once per connection by the first keyword statement and never from a request, so a remote caller cannot widen it; `config set` refuses a value outside the range and writes nothing, and a stored value outside it reads as the default. `gbrain doctor` gains `keyword_plan`, a read-only canary that takes the brain's commonest keyword term from the planner's statistics, EXPLAINs the strict count statement and times the engine's own bounded count, warning when it times out or spends more than half the bound; it names the knob, says one canary term is not workload coverage, and never reports a timed-out count as "no matches". A longer bound buys time, not a cheaper statement: the bounded candidate set for broad terms stays open on #6495. PGLite is unchanged. Guide: `docs/guides/troubleshooting.md#keyword-search-times-out-on-a-large-postgres-brain`.+- **`query` and `search` route "all the people/companies/projects that do X" to `query` again (Refs #6040).** The search description rewrite that taught agents keyword OR lists also told Haiku 4.5 that `search` lists every matching page, and the nightly LLM routing eval has been red since (18/20; 28 of 80 concept phrasings misrouted at temperature 1 against 3 of 80 before). Both descriptions now say that people/companies/projects by topic are `query` work, the exact wording that measured 1/80; the batching sentence stays, so `search`'s per-tool budget grows 1800 → 1830. The description-edit checklist in KEY_FILES names the live test (`GBRAIN_TEST_KEEP_PROVIDER_KEYS=1 bun test test/e2e/salience-llm-routing.test.ts`), 20/20 on this head.+- **The served starter tool list keeps 200 characters of headroom under its 25,000-character ceiling** (it sat at 24,998). Redundant words in tool text no other wave owns are gone (`Optional;` on the shared `request_id` parameter, examples and clauses that repeated the description on `capture.type`, `edit_page.expected_revision`, `get_recent_salience.slugPrefix`, `resolve_slugs.partial`, `mute_notice`, the write-receipt tools, `request_tools`, `list_pages`, `traverse_graph.link_type`, `get_skill`). Every pinned phrase is kept and every description stays at or above 60 characters; `test/mcp-schema-budget.test.ts` asserts the floor through the served list with `publish_skills` on and off (measured 24,796). The entity card, the `MEMORY VERB (v1)` labels and the rest of the query/search text belong to other waves and are untouched.++**CI, flakes, tooling (#6514, #6040 item 4, #6534)**++- **The unconfigured-gateway fixtures stop reaching the provider; lint R7 guards the restore (#6514, contributed by @tarush1989).** `test/think-gateway-adapter.test.ts` uses `__unconfigureGatewayForTests()` and asserts `AIConfigError` at the adapter fork and the backstop, restoring in `afterEach`. `scripts/check-test-isolation.sh` rule R7: `__unconfigureGatewayForTests(`/`_clearGatewayForTests(` without `resetGateway(` in an `afterEach`/`afterAll` hook fails the lint; `test/chronicle-upgrade-notice-5876.test.ts` was the one offender and gets its hook. No allowlist row added.+- **Secret scanner: one-pass `correctedEntropy`, `ScanWork` counters, allowlist in its own module.** `src/core/secret-scan.ts` computes the entropy histogram in one pass (about 80 → 25 ms per 250 × 4096-char segment on a 4-core box; `test/secret-scan-entropy-equivalence.test.ts` pins `Object.is` equality with the former function over 561 samples), counts candidates, gated characters, pattern execs and claims through an optional `ScanWork` (`src/core/secret-scan-work.ts`, pinned at the measured counts, two mutants fail), and the workspace allowlist moves to `src/core/secret-scan-allowlist.ts`. The 300 ms perf bound is unchanged.+- **Three deterministic test suites.** `test/migrate-retry.test.ts` runs its poll cases on a fake clock through the `_hooks.now/sleep` seam (exact pins: 30 iterations / 31 calls, `race_resolved` at t=15; the `> 5` assertion stays) (#6534). `test/helpers/managed-atoms-contract.ts` waits for the deferred batch to settle before asserting (forced probe with a 1 ms maintenance wait: 3/3 fail before, 6/6 pass after, both engines). `test/helpers/managed-facts-embedding-contract.ts` restores the 250 ms publish-wait override right after the `write_pending` assertion so replays wait under the product's deadline (forced 600 ms claim stall: `write_pending` before, `committed` after, both engines).+- **5530 Git-coalescing files.** Setup seeds go through `put_pages`; the `#6210` durability-probe cases move to `test/persistence-git-durability-probe-6210.slow.test.ts` with its Postgres wrapper; both share `test/helpers/git-coalescing-fixture.ts`. A new case asserts the batch seed leaves the same Git effect rows, page hashes, queued count and commit count as the per-page seed. Postgres file 74 → 45 s; PGLite 116 → 90 s. `BACKLOG = 600 × 1 s` unchanged.+- **Tier 2 OpenClaw install waits out a registry race.** `scripts/ci-install-openclaw.sh` (from the inline loop in `e2e.yml`): an attempt failing with npm `code ETARGET`/`E404` (a dependency version published but not yet visible everywhere, the 2026-10-12 master red) is retried up to 4 times 20/40/80 s apart; any other failure keeps 3 attempts 10 s apart. `test/scripts/ci-install-openclaw.test.ts` installs a one-file package from a loopback registry that answers ETARGET or E404 three times, forever, or with `EBADPLATFORM`.+- Docs: `docs/TESTING.md` (R7 row; back under its byte cap), new `docs/architecture/key-files/{secret-scan,core-persistence-request-indexes,core-persistence-facts,managed-sync-bookkeeping}.md`, `KEY_FILES.md` rows trimmed under the 10,000-byte cap, `docs/guides/{write-refusals,error-codes,repair,sync-unblock-runbook,memory-boundaries,troubleshooting,in-agent-setup}.md`, `docs/operations/spend-controls.md`; `llms-full.txt`, `scripts/structural-suites.tsv`, manifests and goldens regenerated.++### Things to watch++- `readRequestIndexStates(engine)` lists three indexes by default (`PERSISTENCE_REQUEST_ONLINE_INDEXES`); callers that need the checkpoint pair alone pass `PERSISTENCE_SYNC_RUN_INDEXES`. Doctor `persistence_request_indexes.details.indexes` gains the third row. A committed page purge's receipt gains `journal_sweep`.+- A soft delete can now commit with `write_through.skipped: 'shared_origin'` and a `write_through.warning`. Discovery's identity snapshot and the origin-check statement now select `deleted_at`; tests that match either statement by text were updated.+- New error codes `purge_lookup_timeout`, `cursor_incarnation_retired`, `sync_cursor_replaced` (`gbrain errors <code>`); new `gbrain repair managed-sync-orphans` reasons `incarnation_retired` / `mirror_only` and a `source_incarnation` field on each listed orphan. A `revision_conflict` checkpoint receipt is now only a same-run index lag.+- `ManagedSyncFailure` / `sync status --json last_error` gain `write_error_detail`; `last_error.detail` can now be a publication `reason`. Stored receipt messages for untyped trigger refusals read `Publication failed (P0001 in <raiser>: <reason>). Inspect owner diagnostics.`+- `gbrain doctor --fast` can score higher than before on a brain with stale mirrored managed rows: that is less certainty, not recovery; the engine-backed check stays authoritative.+- Managed facts: under the automatic-extraction flag, locked validation runs the per-entry purge and withdrawal checks before the page's fence re-validation; a purge written between preparation and publication refuses `purged_content`, a withdrawal in that window refuses `revision_conflict` with `error.withdrawn` set. Receipts and the `extract_facts` result gain `withdrawn_skipped` and `would_dedup_same_page`.+- The `extract_atoms` phase result and the drain result carry a new `input_truncated` count; a managed completion receipt for a cut item has `outcome.status: 'partial'` (+ `partial_input_chars`); discovery and the doctor backlog count exclude partial items until the cap rises.+- `search.keyword_statement_timeout_ms` takes effect on the next connection: the next CLI command picks it up, a running `gbrain serve`, autopilot or job worker needs a restart. `gbrain doctor --only keyword_plan --json` shows `details.timeout_ms`.+- `search`'s per-tool description budget is 1830 (was 1800), with the reason in `TOOL_BUDGETS`.+- Weights: `test/persistence-git-durability-probe-6210.slow.test.ts` (≈35 s PGLite) and `test/e2e/persistence-git-durability-probe-6210-postgres.test.ts` (≈18 s) are new and unweighted; the 5530 rows measured 90 s / 45 s. Weights files are not edited in this release.++### Migrations++- v240 `persistence_request_slug_intent_index`: online partial index on `persistence_requests(source_id, slug, sequence)`, `transaction: false`, CONCURRENTLY on Postgres, inline on PGLite. DDL only.+- v241 `extract_atoms_partial_input`: `ADD COLUMN IF NOT EXISTS partial_input_chars INTEGER` on `extract_atoms_page_state` and `extract_atoms_transcript_state`. Metadata-only, no backfill.+## [0.60.185.0] - 2026-10-12**Agents that share one brain checkout no longer stash, revert or ship each other's half-written files when they commit and push (#6530).** Skills and the committed `scripts/brain-commit-push.sh` used to run `git pull --rebase --autostash` and repo-wide adds in the shared working tree. A rebase that crashed or conflicted left `.git/rebase-merge` holding another agent's edits in its autostash, and a later "repair" could silently revert them. New `gbrain git commit-push` commits only the paths you name, merges a rejected push with the remote in memory, and moves the checkout fast-forward only. Run `gbrain sources harden <id>` once per hardened brain to switch its helper and post-commit hook to it. Brain history now gets merge commits instead of rebased linear history. Guide: `docs/guides/shared-checkout-git.md`.