Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/gbra161-pr2-facts-takes
garrytanfb72694a2b2b
diff --cc docs/architecture/canonical-writers.tsvindex 0d339b7de0,2aa84ac41b..51e70003c8--- a/docs/architecture/canonical-writers.tsv+++ b/docs/architecture/canonical-writers.tsv@@@ -5,8 -5,8 +5,10 @@@ src/core/persistence/canonical-projectisrc/core/persistence/derived-retirement-hold.ts 2 contract retireDerivedPages versions, soft-deletes and stamps retired_by/retired_at on derived pages (unmanaged extract_atoms retirement) inside maintenanceTransaction behind the canonical table trigger; it never revives or rewrites content, and the purge hold it defines only keeps rows longer.src/core/generations/adapters/page.ts 1 contract GBRA-161: importPageItem writes a derived page item through importFromContent inside the generation activation's maintenanceTransaction (publish.ts), behind the canonical table trigger; managed brains keep the coordinator path.src/core/generations/adapters/atoms.ts 1 contract GBRA-161: the unmanaged atom completion flip (source_hash) runs in the generation activation's maintenanceTransaction after every atom and provenance edge was written and before the items are rechecked live; managed brains keep the coordinator path.+ src/core/generations/adapters/chronicle-events.ts 4 contract GBRA-161 PR 3: the Life Chronicle event adapter writes event pages and their depth timeline projection rows, and removes a retired event's projection row, only inside publishGeneration's maintenanceTransaction or the coordinated managed_generation_activate/_restore request, under the depth and event page keys; managed event pages keep the managed_maintenance_chronicle_event request.+ src/core/generations/managed-retire.ts 1 coordinator GBRA-161 PR 4: a managed synthesis generation retires each matched earlier output through one managed_generation_retire request, whose preparer runs the versioned page delete and stamps retired_by/retired_at inside the coordinated write, refusing unless the item is pending on the live generation its activation made+src/core/generations/adapters/fact-rows.ts 1 contract GBRA-161 PR 2: restoreFactRow puts a recorded fact before-state back (lifecycle, consolidation marks, fence row number) only inside a generation restore maintenanceTransaction, matched on id, claim and visibility; managed brains refuse generation restores.+src/core/generations/adapters/extracted-facts.ts 2 contract GBRA-161 PR 2: the extracted-facts adapter inserts a page's new extracted rows and expires the ones a whole-body result dropped, only inside publishGeneration's maintenanceTransaction under the page key; the ownership rule detaches non-user facts before anything is written.src/core/persistence/links-maintenance.ts 1 coordinator Managed extract --stale and post-sync extraction add only the coordinator's unrecorded canonical timeline tuples inside a revision-bound withCoordinatedWrite transaction that also replaces the page's derived links and stamps its watermark.src/core/extract-takes-from-pages.ts 0 coordinator Managed bootstrap submits one revision-checked put_page per source page so its complete takes fence and projected rows commit together; unmanaged writes retain the md-first helper.src/core/persistence/origin-guard.ts 2 engine_guard #6948 bindOrigin records a page origin (and drops an origin_twin marker) only after assertOriginUnclaimed holds the origin advisory lock inside the caller's engine.transaction(); callers are the guarded publication applies and repairs.diff --cc docs/architecture/generations.mdindex 33d44b7630,a34e3c12fa..37b0d10d96--- a/docs/architecture/generations.md+++ b/docs/architecture/generations.md@@@ -54,34 -54,49 +54,77 @@@ Adapters (`contract.ts`) own one kind erelease. An atom's identity leaves out the provenance a managed writer stamps (`source_kind`, `ingested_via`,`ingested_at`, `trust_tier` and the other content-hash ephemeral keys), so a managed write never reads as an edit.+### Facts and takes (PR 2)++A page's `## Facts` and takes fences are canonical, so their kinds (`fact_fence`, `take_fence`, one key `page:<slug>`+each, `generations/fence.ts`) have no shrink floor, valve or item cap: a fence read whole and valid is complete whatever+its row count, and an empty one retires every row (`fenceParsedEmpty`). Every writer that would retire fence rows (the+page publication's projection, `extract_facts`, `gbrain extract takes`) calls `publishFenceGeneration` in its own+transaction, under the page key, before it writes. A fence that is absent, unread or on a segmented page holds+(`fence_absent`): nothing retires, and doctor `generation_held`, `gbrain sync status` (`fence_holds`) and+`get_page` (`fence_held`) list the page with an `ask_user` fix naming both outcomes (restore the section to keep the+rows, or write the exact empty fence it prints to retire them; never a default). The rows of a deleted page expire only+on `originGone`: the page is gone under its key and the rows came from a fence (a live generation, or a fence in the+deleted page's stored body); otherwise they are held `no_proof`. Each retired or replaced row's before-state is on the+ledger. A fence restore (`fence-restore.ts`) writes the earlier generation's fence block into the page as it is now+through a guarded `put_page` bound to its revision, leaving the body, timeline, tags and the other fence alone, and+refuses a fence edited since (`edited_since`, `section_moved`).++The dream consolidate phase records each cluster (`consolidation`, key `entity:<slug>:cluster:<ids>`,+`adapters/fact-rows.ts`): a strict chain records each member's `valid_until`, `consolidated_at` and+`consolidated_into` before it closes them (unmanaged and managed), a same-instant tie (#6023) is held `tie` with nothing+written, and `--mode restore` reopens a chain, which the phase then leaves open.++Model-extracted facts publish through `publishExtractedFacts` (`adapters/extracted-facts.ts`, kind `extracted_facts`,+key `page:<slug>:<writer>`), the path the conversation lane and the facts backstop move onto: a `whole_body` result+retires what it dropped under the model floor and valve, an `appended_range` result is additive, and an+assistant-attributed or third-party fact is stored on its source page with no entity, never attached to an entity page+as an owner fact. `deleteFactsForPage`, `expireFact` and `insertFacts({ deleteForPageFirst })` are deprecated; no+production code calls them (`test/generations-deprecated-fact-writers.test.ts`).++ Life Chronicle events publish through `publishChronicleGeneration` (`adapters/chronicle-events.ts`, kind+ `chronicle_event`, key `depth:<slug>`, GBRA-161 PR 3). Each judged revision of a depth page (meeting, conversation,+ calendar page) is a generation of event pages; each event's timeline projection row on the depth page belongs to its+ item. A complete re-judgment retires the events it dropped together with their projection rows in the activation+ (versioned, `retired_by: life-chronicle`); a result below the model floor is held `shrunk`, and an empty or partial one+ (#7013) retires nothing. An empty generation retires only with a proof: `originIneligible` (the revision became+ ineligible: `not_chronicle_shaped`, `dream_generated` or `too_short`, rechecked against the chronicle ledger by the+ adapter's `proofHolds`) or `originGone` (the chronicle phase retires the events of a deleted depth page). Ownership+ stays content-addressed: an event is the extractor's while its content hash is on the chronicle ledger, its identity is+ the one the live generation recorded, or it is exactly what this publication proposed; an operator-edited or+ operator-deleted event is never an item, so nothing overwrites, retires or revives it.+ `gbrain repair generations --kind chronicle-event --mode restore` brings retired events and their rows back.++ ### Synthesis++ Dream synthesis outputs (kind `synthesis`, one key per transcript: the PR 1b transcript key, `transcript:<root>/<path>`;+ `adapters/synthesis.ts`, GBRA-161 PR 4, #7065) publish in place (`publishesInPlace`): the synthesize phase's children+ write the reflection and original pages as they always did, and after postprocess and the provenance stamp+ `cycle/synthesize-generations.ts` records each synthesized transcript's outputs as its new generation. The decision is+ the plan approved on Oct 21: replace only on a complete, non-empty result, always version first, always reversible.++ - An earlier output retires at activation (versioned, `retired_by: synthesis-resynthesis`, its file removed when the+ database holds everything in it) only when it is matched (`generations/synthesis-coverage.ts`): an exact duplicate of a+ new page, or a page of the new generation with the same subject (slug without its hash suffix and date, or the same+ lowercased title tokens) while every claim unit (each sentence outside a quote), every verbatim quote (a `>` block or a+ quoted span of three or more words) and every citation (wikilink or link target) of the earlier page appears in the new+ generation.+ - Every other earlier output is carried into the new generation, stays live and is recorded on it as an unmatched+ predecessor (why, and how many claims, quotes and citations it holds alone; a segmented page is never compared and is+ listed `unreadable`). `gbrain repair generations --kind synthesis --mode cleanup --since 30d` lists them and+ `--apply --expect <hash> --yes` retires exactly the previewed ones (`retired_by: synthesis-cleanup`).+ - A transcript is complete only when every child of every chunk completed and nothing of the run is deferred or still+ pending publication. Otherwise, or with `generations.synthesis.retire_previous` set to false, the generation is+ partial: the new outputs are recorded and nothing retires.+ - An output from before the ledger is never adopted as an earlier output (no legacy evidence), so the duplicate backlog+ an upgraded brain already holds is untouched. The shrink floor applies, measured against the live generation's items+ (an in-place kind's new outputs carry new keys), and so does the valve: a mass re-synthesis retires at most its share+ per run window and holds the rest (`valve`).+ - `--mode restore` brings a retired earlier output back from its ledger preimage, retires the outputs that replaced it+ and puts the files back the same way (unmanaged brains). A managed brain admits the activation and one versioned+ delete per retirement (`managed_generation_retire`, `generations/managed-retire.ts`) in one transaction; the next run+ resumes a retirement left behind.+### Managed sourcesA managed source (`generations/managed.ts`) never composes a generation in one transaction: every page write is its own@@@ -114,8 -134,9 +162,9 @@@ doctor `atom_retirements_restorable` le`gbrain repair generations --kind <kind>` is explicit-only and preview-bound (docs/guides/repair.md#generations):`--mode restore` (the default) republishes the item set the selected live generation replaced, `--mode release-held`publishes a held result once (a managed source releases an atom page key through its writer), and `--mode cleanup` lists- pending members and orphan candidates, read-only. A managed source restores retired atoms with `gbrain repair+ pending members and orphan candidates, read-only (for `synthesis` it also lists unmatched predecessors, which its+ `--apply` retires; see [Synthesis](#synthesis)). A managed source restores retired atoms with `gbrain repair-atoms-restore`; `--mode restore` refuses there. Doctor reports `generation_retirements` (ok, with the restorable+atoms-restore`; `--mode restore` refuses there for every kind but the fence kinds, whose restore is a guarded page write. Doctor reports `generation_retirements` (ok, with the restorablecount), `generation_held` (warn) and `generation_pending` (warn).## Purgediff --cc docs/architecture/system-of-record.mdindex 1b7dfe7bfc,c7eec7131d..103cd84419--- a/docs/architecture/system-of-record.md+++ b/docs/architecture/system-of-record.md@@@ -259,8 -259,8 +259,10 @@@ or a physical projection that leaves at- `src/core/trust/timeline-projection.ts` (2): `gbrain extract` timeline walks (file, incremental, stale) and the per-entry fallback write through it: one `maintenanceTransaction` per page tier.- `src/core/facts/write-single.ts` (2): the legacy single-fact insert and its supersession link each run in `maintenanceTransaction`; managed brains publish through the fact request.- `src/core/generations/adapters/atoms.ts` (1): the unmanaged atom completion stamp (`source_hash`) runs inside the generation activation's `maintenanceTransaction` (`publish.ts`, GBRA-161).+ - `src/core/generations/adapters/chronicle-events.ts` (3): Life Chronicle event writes, their timeline projection rows and the retirement of dropped events run inside the generation activation's `maintenanceTransaction` (`publish.ts`) on unmanaged brains and inside the coordinated `managed_generation_activate` / `managed_generation_restore` requests on managed brains (GBRA-161 PR 3); a restore runs in the restore runner's (`repair.ts`).+ - `src/core/generations/managed-retire.ts` (1): the retirement stamp (`retired_by`, `retired_at`) of one synthesis output a managed generation retires runs inside its `managed_generation_retire` request's coordinated write, after the versioned page delete (GBRA-161 PR 4).+- `src/core/generations/adapters/extracted-facts.ts` (2): the extracted-facts generation's row inserts and retirements (`publishExtractedFacts`, GBRA-161 PR 2) run inside the generation activation's `maintenanceTransaction` (`publish.ts`); its restore runs in the restore runner's (`repair.ts`).+- `src/core/generations/adapters/fact-rows.ts` (1): putting a fact's recorded before-state back (`restoreFactRow`) runs only inside a generation restore's `maintenanceTransaction` (`repair.ts`, GBRA-161 PR 2).- `src/core/import-file.ts` (12): direct markdown, code and image imports, the moved-file rename (`updateSlug`) and the #3694 legacy-hash re-stamp run in `maintenanceTransaction`; managed imports go through the page request preparer.- `src/core/minions/handlers/ingest-capture.ts` (1): the capture ingest tombstone soft delete runs in `maintenanceTransaction`.- `src/core/ops/extraction.ts` (2): extraction review promote (frontmatter) and reject (soft delete) each run in `maintenanceTransaction`.diff --cc docs/guides/repair.mdindex d17b45d659,e764a8b661..cdb632e1ec--- a/docs/guides/repair.md+++ b/docs/guides/repair.md@@@ -1528,42 -1572,28 +1572,64 @@@ held result waits, with the read-only r`generation_retirements` reports what is restorable. Show the user the previewbefore running the apply. Managed brains keep their coordinator path for now.+Facts and takes fences, consolidation chains and extracted facts publish the+same way (`--kind fact_fence`, `take_fence`, `consolidation`,+`extracted_facts`; key `page:<slug>` for a fence). A fence restore writes the+earlier fence block into the page as it is now, through a guarded page write+that leaves the rest of the page alone; it works on managed brains too, and a+fence edited since is refused. A consolidation restore reopens the chain's+`valid_until` and consolidation marks.++ Life Chronicle events publish the same way (`--kind chronicle-event`, key+ `depth:<slug>`): a restore brings back the events a re-judgment or a deleted+ depth page retired, with their timeline rows on the depth page, and it runs on+ managed brains as one coordinated request.++ Dream synthesis outputs publish as a generation per transcript (`--kind+ synthesis`, key `transcript:<root>/<path>`): a complete re-synthesis retires an+ earlier output it matched (an exact duplicate, or the same subject with every+ claim, quote and citation covered; `retired_by: synthesis-resynthesis`) and+ keeps every other one live. `--mode cleanup` lists those unmatched+ predecessors with why and what each holds alone; show the user the preview, and+ `--apply --expect <hash> --yes` retires exactly the listed ones+ (`retired_by: synthesis-cleanup`). `--mode restore` brings a retired output back+ and puts its file back (unmanaged brains). `gbrain config set+ generations.synthesis.retire_previous false` stops automatic retirement.++ ```bash+ gbrain repair generations --kind synthesis --mode cleanup --since 30d --json+ gbrain repair generations --kind synthesis --mode cleanup --since <ISO-8601> --apply --expect <hash> --yes+ gbrain repair generations --kind synthesis --mode restore --since 30d --json+ ```++#### Fence absent++A page written without its `## Facts` (or takes) section keeps its rows: the+fact or take generation is held `fence_absent` and nothing is retired. Doctor+`generation_held`, `gbrain sync status` (`fence_holds`) and `get_page`+(`fence_held`) list the page with an ask-the-user fix. The user may have deleted+the whole section on purpose, or an edit may have lost it: ask which.++- To keep the rows, restore the section (from the page's history or the+ previous version of its file).+- To retire them, write the empty fence the fix prints into the page; the next+ write retires every row on it. For facts it is:++```markdown+## Facts++<!--- gbrain:facts:begin -->++| # | claim | kind | confidence | visibility | notability | valid_from | valid_until | source | context |+|---|-------|------|------------|------------|------------|------------|-------------|--------|---------|+<!--- gbrain:facts:end -->+```++A page with no file changes through `get_page` (`include_content: true`) and+`put_page` with that revision as `expected_revision`; `edit_page` refuses to+write fence markers. Neither outcome is a default, and nothing changes until the+user chooses.+### Extractor factsA managed write by a gbrain older than v0.60.11.0 to a conversation pagediff --cc scripts/page-body-readers-baseline.tsvindex 39c23b93de,3b62a7fa33..ce7a5269f3--- a/scripts/page-body-readers-baseline.tsv+++ b/scripts/page-body-readers-baseline.tsv@@@ -613,10 -619,5 +619,12 @@@ src/core/generations/adapters/page.ts psrc/core/generations/adapters/page.ts pageVersionEvidence sql INLINE legacy-adoption evidence: hashes retained page_versions copies of derived atom pages and compares identity hashes only; segmented versions (compiled_truth NULL) are skippedsrc/core/generations/adapters/atoms.ts atomGenerationAdapter sql META input size only: body_bytes for a segmented page, octet_length of an inline page columns (pages leave body_bytes NULL inline)src/core/generations/repair.ts releaseManaged field INLINE assertInlineBody refuses a segmented origin page before the managed release reads its body to bind the origin+ src/core/search/exact-scan.ts buildExactBatchStatement sql META #7191: octet_length of the body columns (stored size, never the body) decides an unreadable page+ src/core/cycle/synthesize-generations.ts pages sql INLINE reads the synthesis outputs of one re-synthesized transcript for the predecessor coverage match (generations/synthesis-coverage.ts); segmented pages are excluded in SQL, so a segmented earlier output is never compared and stays live as an unreadable unmatched predecessor+src/core/cycle/extract-facts.ts expireDeletedPageFacts sql INLINE reads the deleted page's stored fence through readFenceBlocks, which reads a segmented page as segmented: no fence proof, so its rows expire only when a live generation recorded them (GBRA-161 PR 2)+src/core/generations/fence-restore.ts planFenceRestore call:serializePageToMarkdown INLINE a segmented page is refused segmented_unsupported before the page is serialized for the guarded restore write+src/core/generations/fence-restore.ts planFenceRestore field INLINE a segmented page is refused segmented_unsupported before its fence blocks are read+src/core/generations/fence.ts readFenceBlocks field INLINE a segmented page reads segmented (held fence_absent) before any body field is read+src/core/generations/fence.ts fenceReadOf field NONE reads the fence block strings already read whole (inline, or from the marker segments of a segmented page), never a stored page body+src/core/generations/fence.ts fenceInput field NONE reads the fence block strings of a FenceRead (already parsed), never a stored page body+src/core/generations/fence.ts storedBlocks field NONE reads the fence block strings of a FenceRead (already parsed), never a stored page bodydiff --cc src/core/behavior-change-notice.tsindex 535c9c62b9,dea340b61e..6d5590572b--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -1085,21 -1089,85 +1089,87 @@@ export const BEHAVIOR_CHANGES: Readonly{ since: '0.60.348.0', text: 'A `gbrain jobs work` worker running two or more jobs at once (the supervisor and autopilot default is 2) now keeps one slot free of long jobs: autopilot-cycle, autopilot-global-maintenance, embed-backfill, connector-sync, extract and doctor-refresh run in at most concurrency minus one slots, so short jobs such as facts-absorb no longer wait behind them. Long jobs can take longer to start when one is already running. `gbrain config set minions.short_job_reserved_slots 0` restores the old behavior; `minions.long_job_names` adds job names to the long set.' },// #7263 (a background doctor refresh held a one-job worker for up to 2 h).{ since: '0.60.348.0', text: 'The background `doctor-refresh` job now queues behind sync, the autopilot cycles, global maintenance, embed backfill and loops extract (priority 10), and measures for at most 10 minutes: past that it starts no further check, records what it finished and completes, and the rest stays unknown until the next hourly refresh. Its timeout drops from 2 hours to 15 minutes. `gbrain config set doctor.background_refresh false` stops doctor from queueing it.' },- { since: 'TBD', text: 'Pages a derived writer retires (an atom a completed re-extraction no longer produces, a chronicle event a re-judged meeting no longer yields, an atom `gbrain repair stale-atoms` retired) now stay restorable for 30 days instead of 72 hours: the purge, automatic and `gbrain pages purge-deleted` alike, skips a page stamped `retired_by` extract-atoms, managed-reextract, stale-atoms or life-chronicle until 30 days after its deletion, and `gbrain restore <slug>` brings it back with its body. The unmanaged extract_atoms and chronicle retirements now save a page version first and stamp the page. A remote page write that adds or changes `retired_by`, `retired_at` or `retired_generation` is refused with `reserved_frontmatter_key`; carrying the stored value unchanged, or dropping the key, still writes.' },- { since: 'TBD', text: 'Unmanaged atom extraction now publishes each page\'s or transcript\'s atoms as one generation: the atoms, their provenance edges and the completion stamp land together or not at all (a failed write leaves no provisional atom), and the atoms a complete re-extraction no longer produces are retired in the same transaction. A re-extraction that would keep fewer than half of an origin\'s atoms (`generations.shrink_floor`), retire them all without proof the input is empty, change more than 64 atoms (`generations.max_items`) or trip the retirement valve is held instead: nothing changes, doctor `generation_held` warns, and `gbrain repair generations --kind atom --mode release-held --held` previews it. An atom from before this release is retired only when the extraction reproduces it or a retained page version the extractor wrote shows it unedited; a hand-written or hand-edited atom naming the origin stays live. `gbrain repair generations --kind atom --since 30d` previews restoring what a generation replaced. The derived purge hold now follows `generations.restore_days` (default 30).' },+ // GBRA-156 (warm CLI socket identity fix). `since` is restamped at the merge slot.+ { since: '0.60.350.0', text: 'The warm CLI socket now answers CLI calls whose connection setup differs from the serve\'s only in ways that cannot change an answer: connection sizing and driver settings (`GBRAIN_POOL_SIZE`, `GBRAIN_DIRECT_POOL_SIZE`, `GBRAIN_PREPARE` and the like), the database URL variables, driver-only URL parameters (`prepare=`, `sslmode`, `application_name`), and, on a Supabase Supavisor pooler host, the port, so a serve on the session lane (5432) answers CLI calls made on the transaction lane (6543). Only an explicit list of read-behavior `GBRAIN_*` settings must still match; on any other host another port is still refused. A refusal now names the part that differed (`refused (identity_mismatch): database port`, `env GBRAIN_MODEL`), never its value, and the serve logs each distinct one once. Guide: docs/guides/cli-socket.md.' },+ { since: '0.60.351.0', text: 'Remote (MCP and HTTP) page reads now hide a page marked private only by a privacy alias (`access: private|restricted|confidential` or `confidentiality: confidential|secret|private|restricted`, with no `visibility`), as they hide `visibility: private` pages; local CLI reads are unchanged. To keep showing such pages to remote callers: `gbrain config set visibility.honor_aliases false`.' },+ { since: '0.60.351.0', text: '`gbrain repair visibility` previews one class at a time, in the order remote callers are exposed: world facts from a private page (remotely readable ones first), Life Chronicle events, alias-only pages, then atoms and concepts; only that last class (`--class lineage`) reads concept-provenance links, and `--class facts|events|aliases|lineage` previews one. A preview lists one window (1,000 items, `--limit` up to 10,000), reports progress on stderr and prints `--apply --expect <hash>`, which applies exactly that window and resumes after its last applied item; apply it, then preview again for the next window. A bare `--apply` (`--all`, the remediation plan) still applies every class. Each plan statement is bounded at 120 s; a class that overruns is reported and skipped while the others are listed. The fact and concept-lineage plans are set-based now (a large brain timed out on them), and doctor `derived_visibility` counts facts first and reports derived-page counts as unknown when they overrun the same bound. A doctor rerun hint capped to fit an agent tool call also names the uncapped `--budget-ms` to use in a terminal.' },+ // GBRA-133 (held file-drift preview windows). `since` is stamped at the merge slot.+ { since: '0.60.353.0', text: '`gbrain repair file-drift --held` previews one window of the selected holds at a time, in held-path order: at most 200 pages, starting no page after 60 seconds of work, with each page reported on stderr. The hash and apply command cover only that window; a partial window prints `next_cursor` and the next preview command (`--cursor <next_cursor>`). Before, the preview prepared every held page (up to 1,000, silently dropping the rest) before printing anything, so a large held set against a remote database printed nothing for an hour. The apply reports each page on stderr too, and reads the preview artifact once instead of parsing it again for every page (seconds per page with large pages). With Git durability off, a preview that recreates or removes files now leads with "The next sync undoes this repair unless …" and the commit command, and reports `undone_by_next_sync_unless_committed`.' },+ // GBRA-156 (warm CLI socket: location variables by what they resolve to). `since` is restamped at the merge slot.+ { since: '0.60.357.0', text: 'The warm CLI socket no longer refuses a CLI only because the serve exports `GBRAIN_HOME` (or `GBRAIN_BRAIN_ID`) and the CLI does not: those count by the config home and brain they resolve to, which the socket already compares, so a serve started with `GBRAIN_HOME=$HOME` answers a CLI that relies on `HOME`. A different resolved home or brain is still refused.' },+ // GBRA-133 (file-drift provenance, database and signal stops). `since` is stamped at the merge slot.+ { since: '0.60.359.0', text: 'A `gbrain repair file-drift --held --side deleted --state file_gone` preview names each gone file\'s provenance (`details.pages[].provenance`, counted in `details.provenance`): the newest commit of HEAD\'s full history that deleted it (sha, author, date, subject), `never_committed` when no commit held it, or `deletion_uncommitted` when HEAD still holds it. New `--provenance never_committed|deleted_by_commit|deletion_uncommitted` keeps only the holds of one provenance. `--provenance never_committed --prefer database` keeps each page database-only: no file is written, the page forgets its recorded path (`database_only_reason=detached`) and the hold is cleared, so the next sync holds nothing again; `--prefer file` with it is refused, since each page holds the only copy.' },+ { since: '0.60.359.0', text: 'A `gbrain repair <kind> --apply` that the database refuses mid-run (deadlock 40P01, serialization failure 40001, a lost connection) now stops with a result (`stopped.reason` `database_contention` or `connection_lost`, the SQLSTATE in its message, what it applied, and the command that resumes from the refused item) instead of ending with an error and, under `--json`, no record of what it applied. A SIGTERM or SIGHUP (an outer timeout, a closed terminal) stops the apply before its next item with `stopped.reason: interrupted` and the same result; a second signal exits at once.' },+ // #7190 (GBRA-150): per-source applied-through watermark. `since` is stamped at the merge slot.+ { since: '0.60.361.0', id: 'applied_watermark_7190', text: '`get_write_request` with `applied: true` (`gbrain write-request <id> --applied`) now returns `applied`, read live: whether the write is searchable yet (`searchable_yet`, `searchable`, `state`), the gap (`requests_ahead`, `unembedded_chunks`), the request `sequence` and the source\'s write watermark (`indexed_through`, `committed_through_request`, `requests_pending`), and a pending write\'s hint names that read; a write\'s own reply is otherwise unchanged. `gbrain sources status --json`, MCP `sources_status` and `gbrain sync --json` add a `watermark` per source: `indexed_through` (the last commit a finished sync pass reached; a deadline-stopped or partial pass never moves it), `embedded_through` (held pages count as not embedded), `committed_through_request`, `pending` (requests, commits and files behind HEAD, held files, withheld deletes) and `writer_heartbeat` (the drain-lease holder and its last progress).' },+ // #7292 (GBRA-133: brain-added fences on unmanaged connector pages). `since` is stamped at the merge slot.+ { since: '0.60.363.0', text: 'On a brain without managed persistence, a Google connector re-render now carries the page\'s `## Facts` and `## Takes` fences (added by loop extraction or `remember`) into the file and the database, as the managed connector already did; before, the re-render dropped them and the next `extract_facts` expired those facts. A contact or email page whose database copy holds a facts fence its checkout file lacks is no longer held `file_database_drift`: the file holds no edit the database lacks, so the re-render replaces it and writes the fence back. A page already held that way imports on its next attempt (a new upstream change, or `gbrain sources retry-held <id>`). A file with a real edit is still held, and a stored fence the render cannot carry verbatim refuses `connector_fence_below_timeline` (preview the fix with `gbrain repair connector-fences --source <id>`).' },+ // GBRA-133 (deletion provenance and origin evidence at scale). `since` is stamped at the merge slot.+ { since: '0.60.364.0', text: 'A `gbrain repair file-drift --held --side deleted --state file_gone` preview over a long history no longer stalls or answers `unknown` for whole batches: the history is walked once and cached per commit instead of once per 500 files, `details.provenance` lists every kind (zeros included), the preview reports the commits it has read on stderr, and a file HEAD holds again reads `deletion_uncommitted`. The database-only keep (`--provenance never_committed --prefer database --apply`) reuses the walk instead of re-reading the history for every page. A managed sync deciding whether a missing file was ever committed reads the same walk, so on a long history a committed deletion is applied instead of being held when the per-batch read ran out of time.' },+ // GBRA-133 (direct pool by command). `since` is stamped at the merge slot.+ { since: '0.60.365.0', text: 'Behind a split pooler route (a Supabase pooler URL or `GBRAIN_DIRECT_DATABASE_URL`), the direct pool now follows the command (approved by the maintainer, 2026-10-21). `gbrain serve`, `jobs`, `autopilot` and `sync --watch` keep up to 3 direct connections. `sync`, `put`, `import`, `dream`, `cycle`, `sources`, `mcp`, `migrate-graduation`, `doctor` and `engine` open 1. Every other command opens none and runs its statements on the ordinary pool, except to apply pending schema migrations or once it takes a lease, when it opens 1. `gbrain engine status --probe` reports the profile as `mode.direct_profile` (and `single (one-shot command)` where the route is configured but unused). `GBRAIN_DIRECT_POOL_SIZE` still sets the size; `GBRAIN_DIRECT_POOL_BY_COMMAND=0` restores the earlier behavior.' },+ // #7306 / #7305 (GBRA-177): pinned-question output cap; hyphen-run slugs at write time. `since` is stamped at the merge slot.+ { since: '0.60.366.0', text: 'A pinned-question refresh whose answer does not fit the output cap no longer fails as `refresh_failed:provider_error` (or `model_output_not_json` after a second metered call): it fails `refresh_failed:answer_too_long:<cap>` after one call, the receipt\'s `blocked_reason` is `answer_too_long` with a fix naming the new key `cycle.standing_questions.max_output_tokens` (default 2000, the old fixed cap), and the `standing_questions` cycle phase skips that pin (reported `blocked:answer_too_long`) until the cap is raised instead of spending on it every cooldown. `gbrain questions refresh <id>` still runs when asked.' },+ { since: '0.60.366.0', text: 'A put_page or capture of a new slug with a hyphen run or a segment-final hyphen (three hyphens between `notes/x-1900` and `2000-ab`, or `notes/x-`) is refused with `invalid_params` (detail `slug_hyphen_run`) naming the folded slug (`notes/x-1900-2000-ab`), the slug import and sync derive from its file. A page that already exists under such a slug still updates, and its response carries `slug_advisory`. New doctor check `slug_path_mismatch` counts live pages whose slug their recorded file path does not derive and warns when the file lacks the `slug:` line that keeps the page, naming the read-only `gbrain repair frontmatter --source <id>` preview.' },+ // #7311 / #7305 (GBRA-177): retention purge of a shared-origin tombstone. `since` is stamped at the merge slot.+ { since: '0.60.366.0', text: 'The 72 h retention purge (the autopilot purge phase, `gbrain pages purge-deleted`) now removes a soft-deleted page whose canonical file another live page of its source records (a duplicate deleted with receipt `write_through.skipped: shared_origin`) database-only: its row, chunks, links and facts go; the file and the surviving page stay, and no content or fact tombstone is written. It used to refuse every run as a shared origin, so the purge phase failed each pass (`managed_purge_failed`), `global_maintenance_stalled` never cleared and the tombstone parked after 5 failures. A tombstone parked by that refusal is retried once by the first purge run after the upgrade and purged then. An owner `gbrain delete <slug> --purge` of such a page still refuses (it would tombstone the survivor\'s content), and on a soft-deleted page it now names the retention purge instead of a soft delete. Nothing changes on upgrade.' },+ { since: '0.60.366.0', text: 'A purge park (a soft-deleted page the purge stopped retrying after 5 failed purges) now records the gbrain version that wrote it. The first purge run of another version (the autopilot purge phase, the purge job, `gbrain pages purge-deleted`) tries such a park once more, so a park whose cause the upgrade fixed clears by itself instead of waiting for `--retry-parked`; a failure parks it again under the new version, so each version tries it at most once. A park written before parks recorded a version counts as another version\'s. Doctor `purge_parked_pages` counts only parks the running version wrote. `--retry-parked` is unchanged.' },+ // #7307 (GBRA-177). `since` is stamped at the merge slot.+ { since: '0.60.366.0', text: 'With System One triage (the decide `triage` slot) acting, the Dream synthesize phase and `gbrain dream retriage` no longer send a transcript to the decide provider when the verdict cache already holds a verdict for that exact content from today\'s LLM triage (the current triage model and triage version), so transcripts the LLM triage judged after a borderline decide answer are not re-judged and paid for every pass. A borderline (margin hold) decide answer is now cached for 24 hours: the transcript goes to today\'s LLM triage, and decide is not asked again for it in that time even when the LLM step ran out of its `dream.triage.max_ms` window. A transcript in unreliable-verdict backoff is not sent to decide either until its backoff ends. `gbrain dream retriage --force` still re-judges everything.' },+ { since: '0.60.366.0', text: 'Brain-wide maintenance stamps `autopilot.last_global_at` past a synthesize triage deferral that has stopped making progress: when the number of transcripts triage leaves for the next pass did not shrink across three passes in a row, the fourth pass stamps (the job result lists it under `pass_completed_with_failing_phase`), as it already did for a phase failing the same way. While the deferred count keeps shrinking, the stamp is still withheld. Doctor `global_maintenance_stalled` names `gbrain dream retriage` (preview with `--dry-run`; it asks before paid spend) for a deferral streak instead of rerunning the phase, which stops at the same time window.' },+ { since: '0.60.366.0', text: '`gbrain dream retriage` triages the same transcript list as the synthesize phase: on a brain with `dream.synthesize.conversation_pages true` and no `session_corpus_dir` it no longer refuses with config_error, and on a brain with a corpus dir and conversation pages left on by default it now also re-scores and reconciles those conversation pages (from source `default`, or the source named by `--source`). Judging stays behind the existing spend estimate and consent gate.' },+ { since: '0.60.366.0', text: 'Brain-wide maintenance no longer stops every job at a phase that fails with a run-scoped error such as a missing table, `permission_denied`, `write_quota_exhausted` or `recovery_required` (before, each later job resumed at that phase and stopped again, so later phases never ran and `autopilot.last_global_at` was never stamped): the failure is that phase\'s `fail:<code>` streak and the job goes on to the next phase, so it backs off and is stamped past after three passes like any other failing phase. A lost connection or database contention still stops the job and the next job retries that phase first, at most three jobs in a row before it counts as the streak. A phase skipped for `insufficient_cycle_budget` after another phase ran in the same job now moves to the next job, where it runs first with the whole budget, instead of counting as a `budget` blocker on every pass; its skip no longer replaces its measured duration.' },+ { since: '0.60.366.0', text: 'The Dream synthesize phase skips a transcript whose estimated synthesis cost alone exceeds `dream.synthesize.budget_usd` (reported as `over_budget_alone` in its skips), instead of deferring it and every transcript after it on every pass, which kept the synthesize cooldown and brain-wide maintenance from completing. Raise the cap or use a cheaper synthesis model to synthesize it. A cap of 0 still defers everything.' },+ { since: '0.60.366.0', text: 'With the System One triage slot in shadow mode (or on without a calibration), Dream now asks the decide provider only about transcripts the LLM triage judged in that pass, not about every transcript whose verdict was already cached, so a shadow brain stops paying the provider for its whole backlog on every pass.' },+ { since: '0.60.366.0', id: 'repair_provider_refusal_memo', text: 'Fence and content repair now treat a provider error that refuses the request\'s own input (a content-policy block, a prompt block, a context-length overflow) as `llm_refused`: the attempt memo records it and the same bytes are not sent again until the page, the model or the prompt changes. Timeouts, rate limits and server errors stay `llm_unavailable` and are retried on the next run.' },+ { since: '0.60.366.0', id: 'concepts_hold_before_spend', text: '`synthesize_concepts` now checks an existing concept page before the model call: a page whose fences it cannot republish losslessly (`concept_preservation_hold`) or whose body is stored in segments (`page_body_segmented`) is listed under `publication_held` with no model spend, every cycle, and a segmented concept no longer stops the phase. A concept\'s failed-attempt count is cleared only after its narrative is published.' },+ { since: '0.60.366.0', id: 'calibration_profile_unchanged_skip', text: '`calibration_profile` makes no model call and writes no new profile row when the holder\'s resolved count, Brier score, accuracy, partial rate and model all equal the latest stored profile (`skipped: unchanged_scorecard`); a new profile prompt takes effect at the next scorecard change.' },+ { since: '0.60.366.0', id: 'grade_takes_window', text: '`grade_takes` now reads unresolved takes oldest-first, leaves takes too recent to grade (or with no date) out of its 50-take window, and puts takes with no verdict for the current prompt and judge ahead of graded ones, so with auto-resolve off older takes beyond the first 50 are graded on later passes. Its `too_recent` count now covers only takes whose date it could not read in SQL.' },+ // #7327: a deadline-stopped pass resumes its scheduled re-screens; hold writes are holder progress+ { since: '0.60.370.0', text: 'A managed sync pass that stops at its deadline, a yield or a block now consumes the scheduled re-screens (`gbrain sources retry-held`) of the held files it already passed. The next pass resumes after them instead of re-screening every scheduled hold again; before, a scheduled re-screen larger than one job\'s budget never finished. A follower `gbrain sync` and the drain holder\'s `stalled` flag in status output now count the holder\'s hold writes as progress, so a holder that is screening held files is no longer reported `drain_stalled` / `no_progress` after 5 minutes.' },+ // #7338: Git edits to pages with no import record import when the database still holds the baseline file+ { since: '0.60.371.0', text: 'A managed sync no longer holds a Git edit to a page an older gbrain imported (one with no import record) as `file_drift` with an unknown side when the page still holds its file as of the source\\\'s managed baseline: the database did not change, so the edit imports. Before, such edits waited for the bounded legacy sweep to reach the page (500 pages per pass), so on a large activated brain most edits never became searchable. A page whose database copy changed since the baseline is still held. Edits already held this way import after `gbrain sources retry-held <source>` and the next sync. A round with imports or deletes now runs the bounded legacy sweep after them, so the sweep no longer adds its cost to each commit\'s time to searchable. A managed PGLite brain whose database directory sits inside another Git checkout no longer marks that whole checkout managed (which refused every write in it with `writer_coordinator_required`); the marker goes in the database directory. A `gbrain-managed.json` an older gbrain already wrote into that checkout\'s `.git` directory stays until it is removed by hand.' },+ // GBRA-151 (#7246 bounded whole-brain outputs). `since` is stamped at the merge slot.+ { since: '0.60.372.0', text: '`gbrain orphans` now prints at most 100 orphans per page (the totals still count every orphan). A paged `--json` result lists the totals and counts per domain first, then the page with `returned`, `limit`, `complete`, `next_cursor` and `next_command`; `--cursor <next_cursor>` prints the next page, `--limit <n>` sets the page size and `--all` prints every orphan in the earlier shape. A listing that fits in one page prints as before. MCP `find_orphans` adds `cursor`, `complete` and `next_cursor` beside offset paging.' },+ { since: '0.60.372.0', text: 'MCP `find_anomalies` and `gbrain anomalies --json` list at most 20 slugs per anomalous cohort; `count` still covers the whole cohort and `page_slugs_complete: false` marks a row that left slugs out. `gbrain anomalies --json --all` lists every slug on a local brain.' },+ { since: '0.60.372.0', text: 'When `gbrain serve`\'s stdout or stderr is a regular file (the `gbrain mcp expose` service installs, or any `>>` redirect), serve rotates that file at 10 MiB, keeping 5 copies (`<log>.1` to `<log>.5`), and writes a line repeated within 10 minutes once, followed by one "[gbrain serve-log] repeated N more time(s)" line. `GBRAIN_SERVE_LOG_MAX_BYTES` (0 turns rotation off), `GBRAIN_SERVE_LOG_MAX_FILES` and `GBRAIN_SERVE_LOG_DEDUPE_SECONDS` (0 turns dedupe off) change it.' },+ { since: '0.60.372.0', text: '`gbrain sources status --json` no longer prints every held file of a source by default: `git_holds` now carries `count`, `by_code` (each hold code with its count and one example item, whose `fix` applies to the rest), and the first 10 items with `items_complete: false` and an `items_command`. `--holds` lists every held file read, as before, and `--limit <n> [--cursor <c>]` pages them by path (the cursor needs the source id). The text output is unchanged.' },+ // #7355: a level read reports progress; pass_abandoned; racy floor+ { since: '0.60.377.0', text: 'A managed `gbrain sync` pass no longer stops `drain_stalled` / `no_progress` on a large source while it is still reading and classifying the level before its first commit: the level read reports progress to the drain as it works (its loops and the history walk for the origin evidence of files a page lost), writes the open pass row every 30 s so a follower and `gbrain sync status` see it working, and a pass that asks for a history walk already running joins it. A hung read still stops after 5 minutes. When two passes in a row never end (abandoned by the drain or killed; the newest open one counts after 5 quiet minutes), `gbrain sync status` reads `blocked` with the new reason `pass_abandoned` and `next` is `gbrain doctor --json` and a report, instead of the plain sync. The stat caches of the dirtiness probe and the working level now take the racy window from the earlier of the process clock and the filesystem clock (a file written in the Git directory), so a mount whose clock lags the process no longer keeps a stale `clean` verdict.' },+ // GBRA-151 (slow reads say what they are doing; #7357). `since` is stamped at the merge slot.+ { since: '0.60.380.0', text: 'The slow whole-brain reads (`gbrain sync status`, `gbrain sources status`, `gbrain doctor`, `gbrain orphans`, `gbrain anomalies`, `gbrain status`, `gbrain diag`) print one stderr line when they start ("[gbrain] reading <what>; large brains can take minutes") and one every 10 s while they run, so a cut-off call is never silent. stdout is unchanged and still carries only the result; `--quiet` turns the lines off.' },+ { since: '0.60.380.0', text: 'The `--json` documents of those reads now carry `elapsed_ms` and `complete`. `complete` is false when a budget or bound cut the result short (a `*_read` field with `status: not_read`, a paged or capped list, a doctor check unknown for its budget), and `incomplete` lists each field with its reason. An error document gets `elapsed_ms` only, and `gbrain anomalies --json` stays a bare array.' },+ { since: '0.60.380.0', text: 'A `--json` command stopped by SIGTERM, SIGINT or SIGHUP before its result now writes `{error: "interrupted", code: "interrupted", ...}` instead of `command_failed`. During a slow read it does so at once, before cleanup, with the read and its `elapsed_ms`, plus one stderr line saying nothing was read, so the result is not empty.' },+ { since: '0.60.380.0', text: '`gbrain extract --stale` no longer exits 1 when one page holds a line or fence longer than the block bound (`page_body_segmented`). The link phase and the mention pass report that page by code, leave it stale and due, and finish every other page; before, the mention pass threw, and the unmanaged sweep stopped at that page.' },+ // GBRA-133: a page written after its file is never soft-deleted for the file's deletion+ { since: '0.60.381.0', text: '`gbrain repair file-drift --held --side deleted --state file_gone --prefer file` (including `--provenance deleted_by_commit`) and `gbrain repair ghost-pages` no longer soft-delete a page whose revision was written in the database after its file last held it (neither the revision sync last imported from the file nor one a committed sync or Git-published write produced; for a page no import record covers, written after the commit that deleted its file): the preview lists it apart as `database_ahead_of_file` with how to recreate its file (`--slug <slug> --prefer database`), and the apply refuses it (`refused`, `database_ahead_of_file`), also for an approval saved before this release. Before, a commit that deleted the file was taken as the page\'s deletion, so content no commit held was soft-deleted.' },+ // #7381 (GBRA-180): shared-checkout writer safety.+ { since: '0.60.383.0', text: 'When a brain checkout publishes local commits whose patch the remote already has (a cherry-picked or rebased copy), `gbrain git commit-push` and `--pull` now leave those commits out of the merge: the other local commits are replayed onto the remote tip in memory. A copy the remote edited since no longer reports `integrate_conflict` forever, and a copy the remote reverted is no longer silently put back. The merge commit message lists the commits it left out.' },+ { since: '0.60.383.0', text: 'gbrain\'s own page commits (write-through, facts fences, takes, timeline, `lint --fix`) no longer commit without the checkout\'s commit lock after their 2-second wait: the file is written, noted in a pending ledger, and committed by the next page write that gets the lock or by the new `gbrain git commit-push --pending`. A commit git refuses now unstages its paths again, so nothing is left staged for another writer\'s commit to sweep up.' },+ { since: '0.60.383.0', text: '`gbrain git commit-push` refuses to commit a file another writer already staged under a directory you named (`commit_prestaged_paths`; name the file to claim it). `gbrain sources harden` records a source folder below the checkout top in git config `gbrain.sourceRoot`; with it set, commit-push refuses to commit or publish changes outside that folder (`commit_outside_source_root`) until the user reruns with `--allow-outside-source-root`.' },+ { since: '0.60.383.0', text: 'New opt-in `gbrain git guard --install`: a local prepare-commit-msg hook that refuses commits not made through gbrain in that checkout, `--no-verify` included (bypass once with `GBRAIN_COMMIT_GUARD=off`). The committed `scripts/brain-commit-push.sh` fallback (no gbrain on the machine) now releases the commit lock before it pushes and pushes under `brain-publish.lock`; rerun `gbrain sources harden` to refresh it.' },+ { since: '0.60.383.0', text: 'Four new doctor checks on source checkouts: `checkout_lagging` (behind the last fetched upstream for over an hour), `dirty_age` (pending write-through files or staged files waiting over 30 minutes), `commits_outside_source_root` (unpushed commits that change files outside the brain\'s folder) and `quarantined_changes` (local versions the opt-in quarantine parked). Each names its fix. Quarantine is off unless you set git config `gbrain.quarantine true` in a checkout: a content conflict then publishes the remote\'s version of the file and keeps this machine\'s version under `refs/gbrain/quarantine/`.' },+ { since: '0.60.386.0', text: 'Pages a derived writer retires (an atom a completed re-extraction no longer produces, a chronicle event a re-judged meeting no longer yields, an atom `gbrain repair stale-atoms` retired) now stay restorable for 30 days instead of 72 hours: the purge, automatic and `gbrain pages purge-deleted` alike, skips a page stamped `retired_by` extract-atoms, managed-reextract, stale-atoms or life-chronicle until 30 days after its deletion, and `gbrain restore <slug>` brings it back with its body. The unmanaged extract_atoms and chronicle retirements now save a page version first and stamp the page. A remote page write that adds or changes `retired_by`, `retired_at` or `retired_generation` is refused with `reserved_frontmatter_key`; carrying the stored value unchanged, or dropping the key, still writes.' },+ { since: '0.60.389.0', text: 'Unmanaged atom extraction now publishes each page\'s or transcript\'s atoms as one generation: the atoms, their provenance edges and the completion stamp land together or not at all (a failed write leaves no provisional atom), and the atoms a complete re-extraction no longer produces are retired in the same transaction. A re-extraction that would keep fewer than half of an origin\'s atoms (`generations.shrink_floor`), retire them all without proof the input is empty, change more than 64 atoms (`generations.max_items`) or trip the retirement valve is held instead: nothing changes, doctor `generation_held` warns, and `gbrain repair generations --kind atom --mode release-held --held` previews it. An atom from before this release is retired only when the extraction reproduces it or a retained page version the extractor wrote shows it unedited; a hand-written or hand-edited atom naming the origin stays live. `gbrain repair generations --kind atom --since 30d` previews restoring what a generation replaced. The derived purge hold now follows `generations.restore_days` (default 30).' },+ // GBRA-151 wave (#7388, #7394). `since` is stamped at the merge slot.+ { since: '0.60.390.0', text: 'doctor `multi_source_drift` now verifies a source with 65,534 or more files. Its existence probe sent one bind parameter per file, so past the Postgres cap it reported "Not verified: ... MAX_PARAMETERS_EXCEEDED" on Postgres (and failed on PGLite), and no `GBRAIN_DRIFT_LIMIT` could make it verify.' },+ { since: '0.60.390.0', text: '`gbrain extract links|timeline|all` with `--type`, `--since` or `--infer-dates` on the default `--source fs` file walk now exits 2 and prints the same command with `--source db`. Before, the walk ignored those filters and reported a full-corpus pass as if it were filtered. `--source db` applies them as before.' },+ { since: '0.60.395.0', text: 'A dream synthesis re-run of a transcript now retires the earlier outputs it replaced (GBRA-161 PR 4, #7065): after a complete re-synthesis (every chunk completed), an earlier reflection or original is versioned and soft-deleted (`retired_by: synthesis-resynthesis`, restorable for `generations.restore_days`, 30 by default) only when a new page is an exact duplicate of it, or has the same subject and covers every sentence, verbatim quote and citation it held. Every other earlier output stays live and `gbrain repair generations --kind synthesis --mode cleanup --since 30d` lists it with what it holds alone; its `--apply --expect <hash> --yes` retires exactly the previewed ones. A failed chunk or `gbrain config set generations.synthesis.retire_previous false` retires nothing, outputs written before this release are never retired, and `--mode restore` brings a retired output back. Separately, changing `models.dream.synthesize` no longer rewrites every deterministic (T3) concept page (#7269, reported by @p3ob7o).' },+ { since: '0.60.396.0', text: 'A fact that replaces another (`remember` with `replaces`, a near-duplicate supersession, or a published facts batch that supersedes) now also closes the retired fact\'s `valid_until` at the new fact\'s `valid_from`, in the database row and in its struck facts-fence row, so as-of reads no longer see the retired fact as current for the time between (#7214). A backdated replacement, starting on or before the retired fact, leaves the retired interval as it was.' },+ { since: '0.60.396.0', text: 'A facts-fence row with no `valid_from` cell now takes the page\'s stated date (frontmatter `event_date`, `date` or `published`, or a dated filename) on every write path: `put_page`, sync and import used to store the write time, and `extract_facts` used the page\'s creation or import time when the page stated no date (#7247). A page that states no date leaves such rows at the time they were recorded. Rows already stored keep their dates.' },+ // GBRA-133 (soak: an unread origin was reported as never committed). `since` is restamped at the merge slot.+ { since: '0.60.397.0', text: 'A `file_drift` hold (side `deleted`, state `file_gone`) for a missing file whose Git history read did not finish now carries `meta.reason` `origin_unknown` and says Git could not show whether a commit held the file, instead of `never_committed` and "Git never committed it". The page is still kept, and the `--held` preview still reads the whole history and names the provenance.' },+ { since: 'TBD', text: 'A page write whose body no longer has its `## Facts` or takes section no longer expires or deletes the rows that section held (GBRA-161 PR 2): the page projection, `extract_facts` and `gbrain extract takes` keep them live and record a held generation (`generation_held`, reason `fence_absent`). Doctor `generation_held`, `gbrain sync status` (new `fence_holds`) and `get_page` (new `fence_held`) list the page with an ask-the-user fix: restore the section to keep the rows, or write the exact empty fence it prints to retire them. An empty fence (begin and end markers, no rows) still retires every row, and an edit that removes some rows retires exactly those, with no shrink floor; each retired or replaced row\'s before-state is recorded and `gbrain repair generations --kind fact_fence|take_fence --mode restore` puts the earlier fence block back into the page as it is now.' },+ { since: 'TBD', text: 'The facts of a soft-deleted page now expire only when the page is still deleted under its page key and its rows came from a fence (a recorded generation, or a fence in the deleted page\'s stored body), one transaction per page (GBRA-161 PR 2); rows no fence derived are kept and held `no_proof`. Dream consolidation now records each cluster\'s `valid_until`, `consolidated_at` and `consolidated_into` before it closes it, records a same-instant tie (#6023) as a held generation (`tie`), and `gbrain repair generations --kind consolidation --mode restore` reopens a chain, which later runs leave open.' },- { since: 'TBD', text: 'A fact that replaces another (`remember` with `replaces`, a near-duplicate supersession, or a published facts batch that supersedes) now also closes the retired fact\'s `valid_until` at the new fact\'s `valid_from`, in the database row and in its struck facts-fence row, so as-of reads no longer see the retired fact as current for the time between (#7214). A backdated replacement, starting on or before the retired fact, leaves the retired interval as it was.' },- { since: 'TBD', text: 'A facts-fence row with no `valid_from` cell now takes the page\'s stated date (frontmatter `event_date`, `date` or `published`, or a dated filename) on every write path: `put_page`, sync and import used to store the write time, and `extract_facts` used the page\'s creation or import time when the page stated no date (#7247). A page that states no date leaves such rows at the time they were recorded. Rows already stored keep their dates.' },// GBRA-60 small-items wave (#7026 part 2, #7234). `since` is stamped at the merge slot.- { since: 'TBD', text: 'New opt-in `context.hot_memory.session_only`, off by default (#7026): with `gbrain config set context.hot_memory.session_only true`, the hot facts the turn hook and the session-start pack inject come from the current session only, so a session with no facts of its own gets none instead of the source\'s newest facts from the last 24 hours, which can belong to other sessions. MCP `_meta.brain_hot_memory` is unchanged.' },- { since: 'TBD', text: 'When the chronicle phase refuses a judge answer as `malformed_proposal`, it now prints one warning line naming the check that failed (a fixed code such as `when_unparseable`, the field, the JSON type found there and counts, never a value), and the direct extractor result carries the same fields under `malformed` (#7234). The refusal, its retry with backoff and the ledger row are unchanged.' },+ { since: '0.60.398.0', text: 'New opt-in `context.hot_memory.session_only`, off by default (#7026): with `gbrain config set context.hot_memory.session_only true`, the hot facts the turn hook and the session-start pack inject come from the current session only, so a session with no facts of its own gets none instead of the source\'s newest facts from the last 24 hours, which can belong to other sessions. MCP `_meta.brain_hot_memory` is unchanged.' },+ { since: '0.60.398.0', text: 'When the chronicle phase refuses a judge answer as `malformed_proposal`, it now prints one warning line naming the check that failed (a fixed code such as `when_unparseable`, the field, the JSON type found there and counts, never a value), and the direct extractor result carries the same fields under `malformed` (#7234). The refusal, its retry with backoff and the ledger row are unchanged.' },// #7023 (GBRA-60). `since` is restamped at the merge slot.- { since: 'TBD', text: 'The per-prompt context block now renders each hot-memory fact the same way the session-start pack does: a fact the assistant said keeps its `(assistant said)` prefix instead of reading as your own claim, and a fact injected once in a session is not injected again on later prompts, whatever its trust label or speaker. Before, assistant-attributed and external (`<external-data>`) facts came back on every prompt; a session already open when you upgrade sees each assistant fact once more (#7023, reported by @benswinney).' },+ { since: '0.60.398.0', text: 'The per-prompt context block now renders each hot-memory fact the same way the session-start pack does: a fact the assistant said keeps its `(assistant said)` prefix instead of reading as your own claim, and a fact injected once in a session is not injected again on later prompts, whatever its trust label or speaker. Before, assistant-attributed and external (`<external-data>`) facts came back on every prompt; a session already open when you upgrade sees each assistant fact once more (#7023, reported by @benswinney).' },// #7026 (GBRA-60). `since` is restamped at the merge slot.- { since: 'TBD', text: 'In Claude Code, the first prompt of a session no longer repeats the hot-memory facts the session-start block already showed: the user-prompt hook now reads the `gbrain hook session-start` output Claude Code records as a SessionStart `hook_success` entry, from the gbrain context envelope on, so core memory printed before it does not hide page pointers. SessionStart output from other tools is still ignored (#7026, reported by @benswinney).' },+ { since: '0.60.398.0', text: 'In Claude Code, the first prompt of a session no longer repeats the hot-memory facts the session-start block already showed: the user-prompt hook now reads the `gbrain hook session-start` output Claude Code records as a SessionStart `hook_success` entry, from the gbrain context envelope on, so core memory printed before it does not hide page pointers. SessionStart output from other tools is still ignored (#7026, reported by @benswinney).' },// #7270 (GBRA-60). `since` is restamped at the merge slot.- { since: 'TBD', text: '`gbrain facts relink` and `gbrain facts relink --conversation` no longer attach a fact the assistant or a named third party said (`attributed_to` assistant or other) to an entity page, core pages included: such a fact is left where it was saved, recall still finds it, and the run counts it as `not_user_attributed`. Before, the SessionEnd corpus sweep saved the assistant\'s own report about a page, and every relink pinned it onto that page. Doctor `unlinked_facts` no longer counts these facts. Rows linked before this release stay linked; `gbrain forget <fact-id>` removes one (#7270, reported by @andrew-agents-bot).' },+ { since: '0.60.398.0', text: '`gbrain facts relink` and `gbrain facts relink --conversation` no longer attach a fact the assistant or a named third party said (`attributed_to` assistant or other) to an entity page, core pages included: such a fact is left where it was saved, recall still finds it, and the run counts it as `not_user_attributed`. Before, the SessionEnd corpus sweep saved the assistant\'s own report about a page, and every relink pinned it onto that page. Doctor `unlinked_facts` no longer counts these facts. Rows linked before this release stay linked; `gbrain forget <fact-id>` removes one (#7270, reported by @andrew-agents-bot).' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --cc src/core/generations/adapters/index.tsindex 5ac78fce1a,68a5c79801..121c097f09--- a/src/core/generations/adapters/index.ts+++ b/src/core/generations/adapters/index.ts@@@ -4,14 -4,13 +4,17 @@@*/import type { GenerationAdapter } from '../contract.ts';import { atomGenerationAdapter } from './atoms.ts';+import { consolidationAdapter, factFenceAdapter } from './fact-rows.ts';+import { takeFenceAdapter } from './take-rows.ts';+import { extractedFactsAdapter } from './extracted-facts.ts';+ import { chronicleEventAdapter } from './chronicle-events.ts';+ import { synthesisAdapter } from './synthesis.ts';- const adapters = new Map<string, GenerationAdapter<unknown>>([atomGenerationAdapter, factFenceAdapter, takeFenceAdapter, consolidationAdapter, extractedFactsAdapter]- .map(adapter => [adapter.kind, adapter as GenerationAdapter<unknown>]));-const adapters = new Map<string, GenerationAdapter<unknown>>([atomGenerationAdapter, chronicleEventAdapter, synthesisAdapter].map(adapter => [adapter.kind, adapter as GenerationAdapter<unknown>]));++const adapters = new Map<string, GenerationAdapter<unknown>>([atomGenerationAdapter, factFenceAdapter, takeFenceAdapter, consolidationAdapter, extractedFactsAdapter,++ chronicleEventAdapter, synthesisAdapter].map(adapter => [adapter.kind, adapter as GenerationAdapter<unknown>]));- export function generationAdapter(kind: string): GenerationAdapter<unknown> | undefined { return adapters.get(kind); }+ /** The adapter of `kind`; a hyphenated spelling (`chronicle-event`) names the same kind. */+ export function generationAdapter(kind: string): GenerationAdapter<unknown> | undefined { return adapters.get(kind) ?? adapters.get(kind.replaceAll('-', '_')); }export function generationKinds(): string[] { return [...adapters.keys()]; }/** Registers an adapter for a kind (tests and later PRs). */export function registerGenerationAdapter(adapter: GenerationAdapter<unknown>): void { adapters.set(adapter.kind, adapter); }diff --cc src/core/generations/contract.tsindex 4eeb1aa5d6,35ad01bacd..b47c838036--- a/src/core/generations/contract.ts+++ b/src/core/generations/contract.ts@@@ -37,8 -37,17 +37,19 @@@ export interface GenerationAdapter<C =modelProduced: boolean;/** The result is a ranked cut: every item carries a distinct `order`, and a tie (or a missing rank) holds the result (`tie`). */strictOrder?: boolean;+ /** A canonical fence kind (generations/fence.ts): it publishes through `publishFenceGeneration` and restores by transplanting the fence. */+ fence?: 'facts' | 'takes';+ /**+ * Its items are database-only pages (no canonical file). A managed source then writes the new and changed items as+ * ordinary requests before the activation, and the activation itself retires what the generation dropped (no retire+ * members, nothing left pending); a restore runs as one coordinated request (managed.ts).+ */+ databaseOnly?: boolean;+ /**+ * Its producer writes the items itself before the activation (synthesis: the phase's children). The activation records+ * them where they are and never writes one; a managed plan keeps them without members and only retires (managed-retire.ts).+ */+ publishesInPlace?: boolean;/** Page keys locked before the ledger row, in slug order with the input guard (D7). */lockKeys(key: GenerationKey, itemKeys: readonly string[]): Array<{ sourceId: string; slug: string }>;/** The input as stored now, or null when it is gone. `context` carries an input the database does not hold (a transcript). */diff --cc src/core/generations/repair.tsindex 833304df31,fb6647d4ed..ac5d5be6b1--- a/src/core/generations/repair.ts+++ b/src/core/generations/repair.ts@@@ -30,8 -35,9 +35,10 @@@ import { afterCursor, type RepairHandleimport { generationAdapter, generationKinds } from './adapters/index.ts';import { readGenerationsConfig, restoreDaysHint } from './config.ts';import { RELEASABLE_HELD_REASONS, type GenerationAdapter, type GenerationKey, type HeldReason, type ProposedItem } from './contract.ts';- import { listOrphanCandidates, listPendingMembers } from './managed.ts';+ import { listOrphanCandidates, listPendingMembers, planManagedGeneration, requestUuid } from './managed.ts';+ import { admitInPlaceGeneration } from './managed-retire.ts';+ import { SYNTHESIS_CLEANUP_RETIRED_BY } from './adapters/synthesis.ts';+import { applyFenceRestore, planFenceRestore } from './fence-restore.ts';import { activateGeneration, assertItemsLive, itemSetHash, lockGeneration, publishGeneration, readLiveGeneration, type LedgerItem } from './publish.ts';export const GENERATION_MODES = ['restore', 'release-held', 'cleanup'] as const;@@@ -266,39 -302,118 +304,124 @@@ async function applyEntry(ctx: Operatioif (outcome.state === 'held') return { applied: false, outcome: 'refused', reason: `${approved.owner_key}: still held (${outcome.reason})` };return { applied: true, outcome: 'released', detail: { generation: outcome.generation, ...(outcome.state === 'published' ? { retired: outcome.retired.length } : {}) } };}+ if (adapter.fence) {+ const restored = await applyFenceRestore(ctx, key, approved);+ if (restored === 'changed') return changed('the live generation, its fence or the page changed since the preview');+ if (Array.isArray(restored)) return { applied: false, outcome: 'refused', reason: restored.join(', ') };+ return { applied: true, outcome: 'restored', detail: { restore_of: approved.restore_to, revived: approved.revive.length, retired: approved.retire.length } };+ }+ let restored: Awaited<ReturnType<typeof restoreGeneration>>;if (await managedPersistenceEnabled(ctx.engine)) {- return { applied: false, outcome: 'refused', reason: `${approved.owner_key}: a managed source restores retired atoms with gbrain repair atoms-restore; a generation restore here runs on unmanaged brains only` };+ if (!adapter.databaseOnly) {+ return { applied: false, outcome: 'refused', reason: `${approved.owner_key}: a managed source restores retired atoms with gbrain repair atoms-restore; a generation restore here runs on unmanaged brains only` };+ }+ restored = await submitManagedRestore(ctx.engine, adapter, key, approved);+ } else {+ restored = await maintenanceTransaction(ctx.engine, tx => restoreGeneration(tx, adapter, key, approved));}- const restored = await maintenanceTransaction(ctx.engine, async tx => {- const live = await readLiveGeneration(tx, key);- const plan0 = live?.id === approved.id ? await planRestore(tx, adapter, key, approved.id, approved.restore_to_id) : null;- await lockGeneration(tx, adapter, key, plan0 ? [...plan0.target.keys(), ...plan0.retire] : []);- if (!plan0 || (await readLiveGeneration(tx, key))?.id !== approved.id) return 'changed' as const;- const plan = await planRestore(tx, adapter, key, approved.id, approved.restore_to_id);- if (stableJson([plan.revive, plan.retire, plan.refused]) !== stableJson([approved.revive, approved.retire, approved.refused])) return 'changed' as const;- if (plan.refused.length) return plan.refused;- for (const itemKey of plan.revive) await adapter.restoreItem(tx, key, itemKey, plan.preimages.get(itemKey)!);- await adapter.retireItems(tx, key, plan.retire, 'generation-restore');- await assertItemsLive(tx, adapter, key, plan.target);- const items: LedgerItem[] = [- ...[...plan.target].map(([itemKey, identity]) => ({ key: itemKey, identityHash: identity, action: plan.revive.includes(itemKey) ? 'revived' as const : 'kept' as const,- ...(plan.revive.includes(itemKey) && plan.rows.get(itemKey)?.live ? { preimage: plan.rows.get(itemKey)!.preimage() } : {}) })),- ...plan.retire.map(itemKey => ({ key: itemKey, identityHash: plan.rows.get(itemKey)!.identityHash, action: 'retired' as const, preimage: plan.rows.get(itemKey)!.preimage() })),- ];- const setHash = itemSetHash([...plan.target].map(([itemKey, identityHash]) => ({ key: itemKey, identityHash })));- const activated = await activateGeneration(tx, key, live, { operationId: `restore:${approved.id}:${approved.restore_to_id}`, input: await adapter.readInput(tx, key, undefined),- setHash, completeness: { complete: true, restore: approved.restore_to }, restoreOf: approved.restore_to_id }, items);- return activated;- });if (restored === 'changed') return changed('the live generation or its items changed since the preview');if (Array.isArray(restored)) return { applied: false, outcome: 'refused', reason: restored.join(', ') };- return { applied: true, outcome: 'restored', detail: { generation: restored.generation, restore_of: approved.restore_to, revived: approved.revive.length, retired: approved.retire.length } };+ const fileHolds = adapter.publishesInPlace ? await restoreInPlaceFiles(ctx.engine, key.sourceId, approved.revive, approved.retire) : [];+ return { applied: true, outcome: 'restored', detail: { generation: restored.generation, restore_of: approved.restore_to, revived: approved.revive.length, retired: approved.retire.length,+ ...(fileHolds.length ? { file_holds: fileHolds } : {}) } };+ }++ /**+ * GBRA-161 PR 4: the operator's retirement of one previewed unmatched predecessor, as an approved retirement of its key+ * (versioned, `retired_by: synthesis-cleanup`, bound to the identity the preview showed). Unmanaged: one transaction, its+ * file removed after when the database holds everything in it; managed: one activation and its retire member through the writer.+ */+ async function retireUnmatched(engine: BrainEngine, adapter: GenerationAdapter<unknown>, approved: CleanupEntry): Promise<RepairItemOutcome> {+ const key = keyOf(adapter.kind, approved.source_id, approved.owner_key);+ const changed = (why: string): RepairItemOutcome => ({ applied: false, outcome: 'changed_since_preview', reason: `${approved.slug}: ${why}` });+ const live = await readLiveGeneration(engine, key);+ if (!approved.identity || live?.items.get(approved.slug) !== approved.identity) return changed('the page or its generation changed since the preview');+ const request = { key, items: [], runId: `cleanup:${approved.generation_id}:${approved.slug}`,+ approved: { retire: [approved.slug], retiredBy: SYNTHESIS_CLEANUP_RETIRED_BY, expect: { [approved.slug]: approved.identity } } };+ if (await managedPersistenceEnabled(engine)) {+ const { maintenancePreflight } = await import('../persistence/prepared-maintenance.ts');+ const authority = await maintenancePreflight(engine, key.sourceId);+ if (!authority) return { applied: false, outcome: 'refused', reason: `${approved.slug}: the source is no longer managed; preview again` };+ const plan = await planManagedGeneration(engine, adapter, request, { retiredBy: SYNTHESIS_CLEANUP_RETIRED_BY });+ if (plan.kind !== 'publish') return changed(plan.kind === 'held' ? `held (${plan.outcome.reason})` : 'nothing left to retire');+ await admitInPlaceGeneration(engine, authority, plan);+ return { applied: true, outcome: 'retired', detail: { retired_by: SYNTHESIS_CLEANUP_RETIRED_BY } };+ }+ const outcome = await publishGeneration(engine, adapter, request);+ if (outcome.state === 'held') return { applied: false, outcome: 'refused', reason: `${approved.slug}: held (${outcome.reason})` };+ if (outcome.state !== 'published' || !outcome.retired.includes(approved.slug)) return changed('the page changed since the preview');+ const { removeDreamPageFile } = await import('../cycle/derived-write-through.ts');+ const file = await removeDreamPageFile(engine, '', approved.slug, key.sourceId, '');+ return { applied: true, outcome: 'retired', detail: { generation: outcome.generation, retired_by: SYNTHESIS_CLEANUP_RETIRED_BY, ...(file.held ? { file_held: file.held } : {}) } };+ }++ /**+ * GBRA-161 PR 4: the files of an in-place kind (synthesis pages) after its unmanaged restore committed: each revived page is+ * written back to its file and each retired page's file removed, both only where the file holds nothing the database+ * lacks (otherwise its `file_database_drift` entry is returned and the file stays).+ */+ async function restoreInPlaceFiles(engine: BrainEngine, sourceId: string, revived: readonly string[], retired: readonly string[]): Promise<string[]> {+ const { removeDreamPageFile, reverseWriteDreamRefs } = await import('../cycle/derived-write-through.ts');+ const { renderPageToMarkdown } = await import('../cycle/synthesize.ts');+ const held: string[] = [];+ for (const slug of retired) { const file = await removeDreamPageFile(engine, '', slug, sourceId, ''); if (file.held) held.push(file.held); }+ await reverseWriteDreamRefs(engine, '', revived.map(slug => ({ slug, source_id: sourceId })), { phase: 'repair generations', nativeSourceId: '', render: renderPageToMarkdown, held });+ return held;+ }++ /** The approved restore of one key, under its locks in the caller's transaction: 'changed', the refused keys, or the new generation. */+ async function restoreGeneration(tx: BrainEngine, adapter: GenerationAdapter<unknown>, key: GenerationKey, approved: RestoreEntry): Promise<'changed' | string[] | { generation: number }> {+ const live = await readLiveGeneration(tx, key);+ const plan0 = live?.id === approved.id ? await planRestore(tx, adapter, key, approved.id, approved.restore_to_id) : null;+ await lockGeneration(tx, adapter, key, plan0 ? [...plan0.target.keys(), ...plan0.retire] : []);+ if (!plan0 || (await readLiveGeneration(tx, key))?.id !== approved.id) return 'changed' as const;+ const plan = await planRestore(tx, adapter, key, approved.id, approved.restore_to_id);+ if (stableJson([plan.revive, plan.retire, plan.refused]) !== stableJson([approved.revive, approved.retire, approved.refused])) return 'changed' as const;+ if (plan.refused.length) return plan.refused;+ for (const itemKey of plan.revive) await adapter.restoreItem(tx, key, itemKey, plan.preimages.get(itemKey)!);+ await adapter.retireItems(tx, key, plan.retire, 'generation-restore');+ await assertItemsLive(tx, adapter, key, plan.target);+ const items: LedgerItem[] = [+ ...[...plan.target].map(([itemKey, identity]) => ({ key: itemKey, identityHash: identity, action: plan.revive.includes(itemKey) ? 'revived' as const : 'kept' as const,+ ...(plan.revive.includes(itemKey) && plan.rows.get(itemKey)?.live ? { preimage: plan.rows.get(itemKey)!.preimage() } : {}) })),+ ...plan.retire.map(itemKey => ({ key: itemKey, identityHash: plan.rows.get(itemKey)!.identityHash, action: 'retired' as const, preimage: plan.rows.get(itemKey)!.preimage() })),+ ];+ const setHash = itemSetHash([...plan.target].map(([itemKey, identityHash]) => ({ key: itemKey, identityHash })));+ const activated = await activateGeneration(tx, key, live, { operationId: `restore:${approved.id}:${approved.restore_to_id}`, input: await adapter.readInput(tx, key, undefined),+ setHash, completeness: { complete: true, restore: approved.restore_to }, restoreOf: approved.restore_to_id }, items);+ return { generation: activated.generation };+ }++ export const GENERATION_RESTORE_INTENT = 'managed_generation_restore';++ /**+ * GBRA-161 PR 3: a managed source restores a database-only kind (chronicle events) in one coordinated request, journaled+ * on the key's input page and bound to its current revision: the request runs `restoreGeneration` under the item locks.+ */+ async function submitManagedRestore(engine: BrainEngine, adapter: GenerationAdapter<unknown>, key: GenerationKey, approved: RestoreEntry): Promise<'changed' | string[] | { generation: number }> {+ const { maintenancePreflight, submitDatabaseMaintenanceIntent } = await import('../persistence/prepared-maintenance.ts');+ const authority = await maintenancePreflight(engine, key.sourceId);+ if (!authority) return [`${approved.owner_key}: the source is no longer managed; preview again`];+ const slug = adapter.lockKeys(key, [])[0]!.slug;+ const input = await engine.readPageSnapshot(slug, { sourceId: key.sourceId, includeDeleted: true });+ const intent = { kind: GENERATION_RESTORE_INTENT, key, approved, expected_revision: input?.revision ?? null, ...(input?.page.deleted_at ? { deleted_page: true } : {}) };+ const receipt = await submitDatabaseMaintenanceIntent(engine, authority, slug, intent, requestUuid(digest(['generation-restore-v1', key, approved.id, approved.restore_to_id, input?.revision ?? null])));+ const result = receipt.restore as 'changed' | string[] | { generation: number } | undefined;+ return result ?? 'changed';+ }++ /** Preparer of `managed_generation_restore` (trusted local only): the restore of a database-only kind, writing no file. */+ export async function prepareGenerationRestore(engine: BrainEngine, row: WriteRequest): Promise<PreparedMutation> {+ const p = row.intent as { kind?: string; key?: GenerationKey; approved?: RestoreEntry; expected_revision?: string | null } | null;+ const adapter = p?.key ? generationAdapter(p.key.kind) : undefined;+ if (!p || p.kind !== GENERATION_RESTORE_INTENT || row.authority.remote || !adapter?.databaseOnly || !p.approved || p.key!.sourceId !== row.source_id) {+ throw opError('permission_denied', 'Unsupported generation restore request.',+ `Request ${row.request_id} in source ${row.source_id} is not a generation restore the trusted local writer admitted, so the coordinator refused it before any change. Restores run only from gbrain repair generations on the brain host.`);+ }+ const key = p.key!;+ const approved = p.approved;+ return { observedRevision: p.expected_revision ?? null, noop: true, additionalPageKeys: adapter.lockKeys(key, [...approved.revive, ...approved.retire]),+ apply: async tx => ({ restore: await restoreGeneration(tx, adapter, key, approved) }) };}/**diff --cc test/e2e/g2-consolidation-generations-postgres.test.tsindex 0000000000,0000000000..cb41f8c933new file mode 100644--- /dev/null+++ b/test/e2e/g2-consolidation-generations-postgres.test.ts@@@ -1,0 -1,0 +1,3 @@@++import { registerPostgresTests } from '../helpers/test-backends.ts';++++await registerPostgresTests(() => import('../pathological/g2-consolidation-generations.test.ts'));diff --cc test/e2e/g2-extracted-facts-postgres.test.tsindex 0000000000,0000000000..c77dc1793fnew file mode 100644--- /dev/null+++ b/test/e2e/g2-extracted-facts-postgres.test.ts@@@ -1,0 -1,0 +1,3 @@@++import { registerPostgresTests } from '../helpers/test-backends.ts';++++await registerPostgresTests(() => import('../pathological/g2-extracted-facts.test.ts'));diff --cc test/e2e/g2-fence-generations-postgres.test.tsindex 0000000000,0000000000..2d41e362abnew file mode 100644--- /dev/null+++ b/test/e2e/g2-fence-generations-postgres.test.ts@@@ -1,0 -1,0 +1,3 @@@++import { registerPostgresTests } from '../helpers/test-backends.ts';++++await registerPostgresTests(() => import('../pathological/g2-fence-generations.test.ts'));diff --cc test/trust-write-gate-drift.test.tsindex 5db8c3920c,59c3d2874a..8573a08ac8--- a/test/trust-write-gate-drift.test.ts+++ b/test/trust-write-gate-drift.test.ts@@@ -55,9 -55,8 +55,10 @@@ const EXEMPT: Record<string, string> ='src/core/persistence/memory-mutations.ts': 'forget (lifecycle); remember is gated in memory-prepare.ts','src/core/repair/captured-facts.ts': 'owner repair of existing rows','src/core/repair/consolidate-ties.ts': 'owner repair reopening the validity of existing facts (lifecycle)',- 'src/core/repair/duplicate-facts.ts': 'owner repair behind a preview: expires exact duplicates of existing fact rows and points them at the row kept (lifecycle); no new text',+ 'src/core/repair/duplicate-facts.ts': 'owner repair behind a preview hash: supersedes exact copies of an existing fact with its oldest row (expired_at, superseded_by; lifecycle, no new text); fenced copies are struck through put_page, which runs the gate',+ 'src/core/generations/managed-retire.ts': 'versioned delete of a synthesis output a managed generation retires, plus its retired_by/retired_at stamp (lifecycle); no new text',+ 'src/core/generations/adapters/extracted-facts.ts': 'callers gate first and pass only rows the gate inserts or flags (the conversation lane and the backstop decide in conversation-publication.ts and backstop.ts); restore puts back a row\'s own recorded state',+ 'src/core/generations/adapters/fact-rows.ts': 'generation restore puts back a fact row\'s own recorded before-state (lifecycle); no new text','src/core/repair/extractor-facts.ts': 'owner repair of existing rows','src/core/repair/redacted-facts.ts': 'owner repair behind a preview hash: puts back into existing fact rows the words a stored source page proves; fenced rows publish through put_page, which runs the gate','src/core/repair/facts-rehome.ts': 'owner repair moving existing facts onto their entity page (placement)',