Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge commit 'e95b858ffbbbc49304d2da2498eefb56ac931b96' into fix/8819-first-fence-generation
garrytand8ea2f67ddce
diff --cc CHANGELOG.mdindex 3288192ca6,f722e0705a..ae13ffb24b--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,18 -10,15 +10,27 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased]++**A page write or a managed `extract_facts` run no longer retires facts that the page's `## Facts` fence never held, and `gbrain repair unwithdrawn-facts` restores the ones earlier releases retired.** A fact a `put_page` writer attached to a page with a row number, but that was never in the page's fence, used to be expired by any later write that projected the fence. That included a write that changed nothing in the fence, often the page's first facts-fence generation, which `gbrain repair generations` cannot undo because it has no earlier generation. Now a row retires only when a fence held it: a facts-fence generation recorded it, the page as the writer read it carried it, or a stored version of the page did. Every other row stays active with its id. Removing a row from the fence still retires it, as before. Doctor `unwithdrawn_facts` counts the facts that were already retired and points to the new repair, which previews first and restores the original fact ids and lifecycle from the generation ledger. It works on brains with and without a repository.++### Itemized changes++- `src/core/generations/fence-evidence.ts` (new): `factsFenceHeld` decides whether a fence ever held a fact row, from the facts-fence ledger, the replaced body and the page's stored versions. `moveKeptRows` moves a kept row whose number an incoming fence row claims above the page's rows.+- `src/core/generations/adapters/fact-rows.ts`, `src/core/persistence/canonical-projections.ts`, `src/core/trust/fence-guard.ts`: the page projection's fact generation retires only held rows. Conversation-extractor rows still give up a number a fence row claims. Its expire statement and the trust guard leave kept rows alone.+- `src/core/cycle/extract-facts.ts`: on a managed brain the reconcile keeps stale rows no fence held, and moves one whose number a new fence row needs. An unmanaged brain's reconcile is unchanged.+- `src/core/repair/unwithdrawn-facts.ts` and `src/commands/doctor/checks/unwithdrawn-facts.ts` (new): `gbrain repair unwithdrawn-facts [--include-ambiguous] [--apply --expect <hash>]`, bound to each page's revision at preview. Managed brains apply it through a database-only `managed_maintenance_restore_unwithdrawn_facts` request; unmanaged brains apply it under the page lock. A fact a fence held, a withdrawn, superseded or duplicated fact, and a page written since the preview are refused. Doctor check `unwithdrawn_facts`.+- Tests: `test/fence-first-generation-8819.test.ts` and `test/repair-unwithdrawn-facts-8819.test.ts`, on PGLite and Postgres.++ ## [0.60.610.0] - 2026-11-08++ **A client that retries a `POST /ingest` capture accepted before v0.60.609.0 no longer queues a second job that writes the old body over the page's newer edit.** v0.60.609.0 added the target slug to the capture's queue key, and nothing looked up the old key form, so a retry of a capture that had already landed was taken as a new one. The route now also looks up a capture's pre-v0.60.609.0 key and answers 202 with that job when it was queued for the same target slug, so the retry is the same request again and nothing is queued.++ ### Itemized changes++ - `src/commands/serve-http-webhooks.ts` (`POST /ingest`): before queueing, the route looks up the capture's legacy key (client, write source and content hash, no slug part). A row queued for the same normalized target slug (or with no slug, for a slug-less capture) answers the request; a row for another slug never does, so one body sent to two slugs still queues two captures. A dead or cancelled legacy row frees its key, as under the current key. A legacy row still waiting or running with no recorded submitter (left by an upgrade across v0.50) answers 409 `legacy_job_authority` with its recovery hint instead of queueing a second job. The 429 at the waiting cap, the 400 for slugs over 1024 bytes and the webhook HMAC are unchanged.+ - Tests: `test/serve-http-ingest-legacy-key-retry.test.ts` (PGLite) and `test/e2e/serve-http-ingest-legacy-key-retry-postgres.test.ts` (Postgres) drive the real route: a retry of a completed legacy capture gets its job back, queues nothing and leaves the newer edit in place, and a legacy row with no recorded submitter gets its job back when completed or a 409 while still waiting.+## [0.60.609.0] - 2026-11-07**`POST /ingest` no longer answers 202 for a capture it drops, and an unsigned GitHub webhook can no longer tell from response time which repositories a brain syncs.** The same body sent to two slugs now queues two captures, where the second caller used to get the first job back and nothing written to its slug. A capture over the 50-capture waiting cap now gets 429 `ingest_backlog_full` with `Retry-After: 30` and nothing queued, where it used to get another capture's job id. A slug over 1024 bytes gets 400 `invalid_slug` before anything is queued, well short of the roughly 2.7 KB where no page can be stored under it. Every webhook request now computes the HMAC over its body, whether the repository is unknown, has no secret or is covered by a source, so a 401 takes the same work either way.