Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs: chronicle event cap and purge-slug-stores key-file entry
garrytand44e14aee1af
diff --git a/docs/architecture/key-files/memory-purge.md b/docs/architecture/key-files/memory-purge.mdindex 36ccf5fbb9..677e56762c 100644--- a/docs/architecture/key-files/memory-purge.md+++ b/docs/architecture/key-files/memory-purge.md@@ -27,6 +27,7 @@ User-facing contract: [expire versus purge](../../guides/memory-boundaries.md#pu- `src/core/persistence/derived-retirement-hold.ts` — GBRA-161: the purge hold for every derived retirement. `DERIVED_RETIRED_BY` lists the `retired_by` stamps derived writers put on the pages they retire (extract-atoms, managed-reextract, stale-atoms, life-chronicle); `derivedRetirementPurgeHold(alias)` keeps a stamped page out of every purge route (engine bulk purge and its preview, the coordinated selection and delete) until `DERIVED_RETIREMENT_HOLD_DAYS` (30) after `deleted_at` (the database clock, never the `retired_at` text); `retireDerivedPages` versions, soft-deletes and stamps a batch in one attributed transaction (unmanaged extract_atoms). `assertRetirementStampUnchanged` is the page preparer's refusal (`reserved_frontmatter_key`) of a remote write that adds or changes one of `RESERVED_RETIREMENT_KEYS`. The hold length follows `generations.restore_days` (`RESTORE_DAYS_SQL`, read inside the purge statement; 30 by default) and `retireDerivedPagesInTransaction` is the in-transaction form generation adapters retire through. An explicit `gbrain delete --purge` is not held.- `src/core/generations/ledger-scrub.ts` — GBRA-161: purge reaches the generation ledger. A page purge (`page-purge.ts`) nulls the purged item's preimages in `derived_generation_items` and every held proposal in `derived_generations` naming it, and deletes the page's fence holds (`FENCE_GENERATION_KINDS` under `page:<slug>`, whose rows the purge deletes; `test/generations-purge-fence-hold-7774.test.ts`); a fact purge (`facts/purge.ts`) nulls every preimage, proposal and held context carrying the claim. Both are `swept` (`generation_ledger`) in the deletion inventory, so the verification probes them; `gbrain repair generations` then refuses a scrubbed item with `no_preimage`.- `src/core/persistence/purge-name-stores.ts` — #9068: `scrubPurgedNameStores(engine, sourceId, slugs)` deletes the source's `context_volunteer_events` rows (whose rationale quotes the matched name) and `mention_gazetteer_entries` rows (`name_norm -> target_slug`) for purged slugs. Every hard delete of a page calls it inside its transaction (`purgePageInTransaction`, `purgeDeletedPages`, `expireRecordedTombstones`, the restore purge replay in `belief/purge-mirror.ts`, and the engines' batch `deletePages`); removing a source deletes the source's volunteer rows (`removedSourceScrubCtes` in `source-delete.ts`) and its gazetteer rows by cascade; a soft delete keeps both. Both tables are `swept` (`page_names`) in the deletion inventory; the page receipt checks them by slug, and the fact receipt probes them (rationale, name_norm) and reports a match as `probed_reported`, because a fact purge sweeps neither.+- `src/core/persistence/purge-slug-stores.ts` — #9146: `scrubPurgedSlugStores(engine, sourceId, slugs, { ifPresent })` deletes the six stores keyed to a page by source and slug with no foreign key to pages (`take_proposals`, `open_loops`, `core_edit_notices`, `page_aliases`, `slug_aliases` by `canonical_slug`, `slug_rename_history` by `new_slug`) and returns rows removed per store; `scrubPurgedSlugHolds` deletes the slug's `write_gate_holds` and their `write_gate_receipts`, and on a tombstone expiry (`deletedAt` given) keeps a hold created or last seen after the soft delete. Every hard delete calls them inside its transaction (`purgePageInTransaction` for the stores, `expireRecordedTombstones`, the engines' batch `deletePages` and purge path, the restore purge replay in `belief/purge-mirror.ts` with `ifPresent`); a soft delete keeps them. Source removal deletes `core_edit_notices` and the holds with their receipts in `removedSourceScrubCtes`; the other five cascade from sources. Test: `test/purge-slug-stores-9146.test.ts`.- `src/core/persistence/atom-retirement-hold.ts` — #7013: the one SQL rule for atoms `gbrain repair atoms-restore` restores. `atomRetirementsSql(scope)` is set-based (CTEs over `pages` joined on source and origin key, linear in the atoms in scope) and returns every non-imported atom soft-deleted with `retired_by: managed-reextract` with `origin_live` (a live page origin in its source, or a transcript), `replaced` (a live atom of the same origin carries another stripped source hash), `latest` (its hash is the hash of the origin's latest `managed-reextract` retirement) and `restorable` (all three right); `atomOriginScopeSql` narrows it to one atom's source and origin through the frontmatter GIN index for the apply recheck; `atomRetirementPurgeHold`, which keeps such an atom out of every batch purge selection (engine `purgeDeletedPages` preview and delete, the belief-ledger expiry, `selectPurgeCandidates`) for `ATOM_RESTORE_HOLD_DAYS` (30) after `deleted_at`, next to the #6729 `identityDowngradePurgeHold`. An explicit `delete --purge` is not held. Static strings only, so `engine-sql/pages.ts` imports it.- `src/core/repair/atoms-restore.ts` — `gbrain repair atoms-restore` (#7013), explicit-only and preview-bound: lists atoms an empty managed re-extraction retired (`retired_by: managed-reextract`) that `atomRetirementsSql` (`persistence/atom-retirement-hold.ts`) marks `restorable`, each with origin, stripped source hash and `retired_at`, and residuals `restorable`, `origins`, `origin_gone`, `replaced`, `older_generation`; `--apply --expect <hash>` restores the approved set, rechecking each atom (id, incarnation, revision, origin, hash, `retired_at`, rule match) and reporting `changed_since_preview` otherwise. Managed: one `managed_maintenance_restore_reextract_atom` request per atom (`deleted_page: true`, bound to the deleted revision, request id in the outcome detail); `prepareAtomRestore` (dispatched from `prepared-maintenance.ts`) rechecks the rule under the atom and origin page locks and publishes a revision-bound `revert_version` to `version_id`, the newest live version of the atom at its source hash without `retired_by` (the one the coordinated delete archived; file written back, `allowMissingFile`); none is `no_version`, lowered to the `derive:atoms` tier of its origin with taint edges. Unmanaged: `createVersion`, `restorePage` and the two keys dropped in one `maintenanceTransaction`. Extraction state is not touched. Test: `test/pathological/h5-atoms-restore.test.ts`.- `src/core/repair/atom-fence-rows.ts` — `gbrain repair atom-fence-rows`, explicit-only and preview-bound: `findAtomFenceRows` lists live page-bound `visibility: world` atoms whose title, body or `source_quote` contains (case and whitespace folded, claims of at least `MIN_CLAIM_CHARS`) the claim of a facts row of their live source page whose visibility is not world or a takes row whose holder is not world, absent from the page's `publicBody`; keyset pages of 500 atoms whose source page names a facts or takes fence, each source page read once, segmented source pages counted `origin_unread`. The preview lists atom, source page and row kinds and numbers (never row text) under a saved hash; `--apply --expect <hash>` rechecks each atom and sets `visibility: private` through a revision-bound put_page (`narrowed`), else `changed_since_preview`. Doctor `atom_fence_rows` shares the scan. Test: `test/repair-atom-fence-rows.test.ts` (unmanaged and managed, PGLite and Postgres).diff --git a/docs/guides/memory-trust.md b/docs/guides/memory-trust.mdindex 9e71f8c724..437ed99f97 100644--- a/docs/guides/memory-trust.md+++ b/docs/guides/memory-trust.md@@ -224,8 +224,16 @@ lowers them. It only lowers: it never raises a row, it touches only rows with`write_origin.channel = "trust_claim"`, rows on a lowered page follow it, andeach lowered row records `write_origin.channel = "trust_relower"`.+Legacy Life Chronicle event pages (`captured_via: life-chronicle:auto`) are+model summaries of another page (#9284). A claim caps them at "written by an+agent" and never above the tier of the page they summarise. Events an earlier+claim lifted change only when you run `--relower`.+`gbrain sources set-trust <id> <lower tier>` or `--clear` ends a claim. Rows-it already lifted keep their tier.+it already lifted keep their tier. To lower them anyway, name the source:+`gbrain trust claim-sources --relower --dry-run --source <id>`, then the same+command without `--dry-run`. Doctor names the `--source` flags when it finds+such rows.## Repair unknown markers