Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
GBRA-161 PR 1a (wip): error docs anchors, hot-check golden, stale write-gate exemption
garrytanac1030a882fe
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.mdindex 4dd48ca70e..8630a15e48 100644--- a/docs/guides/error-codes.md+++ b/docs/guides/error-codes.md@@ -1567,7 +1567,7 @@ More: [docs/guides/shared-brain-skills.md#approve-publication-following-and-editReasons: `stale_generation`, `pin_moved`.-More: [docs/architecture/generations.md](../../docs/architecture/generations.md)+More: [docs/architecture/generations.md#publishing](../../docs/architecture/generations.md#publishing)### generation_held@@ -1589,7 +1589,7 @@ More: [docs/guides/repair.md#generations](../../docs/guides/repair.md#generation|---|---|---|---|---|---|---|| A derived generation was not activated because one of its items was not live at the content the publication wrote; nothing was committed. | Activation rechecks every item of the new generation under the key lock; an item another writer changed or deleted in between would make the ledger record a set that is not what the pages say. | Run the producer again; it reads the items as they are now. | agent | `repeat the read that failed` | 11 | yes |-More: [docs/architecture/generations.md](../../docs/architecture/generations.md)+More: [docs/architecture/generations.md#publishing](../../docs/architecture/generations.md#publishing)### ghost_mass_delete_refuseddiff --git a/src/core/error-registry.ts b/src/core/error-registry.tsindex 9d1a2f7906..f4db43354e 100644--- a/src/core/error-registry.ts+++ b/src/core/error-registry.ts@@ -289,9 +289,9 @@ export const CODES = {follow_approval_required: { class: 'caller', summary: "Following a brain's shared skills needs the user's explicit follow approval.", docs: 'docs/guides/shared-brain-skills.md#approve-publication-following-and-editing-separately' },forget_requires_owner: { class: 'consent', exit: 3, actor: 'user', summary: "A caller asked to forget a fact (remote forget) or remove a take (takes_remove) more trusted than its own writes, so nothing was removed and the owner was asked instead.", why: "Lower-trust writers cannot overwrite, supersede or forget what the owner confirmed or curated (#5575 guarded supersession). The request became a trust proposal the owner can accept on the brain host; forget's frozen expired meaning is unchanged because nothing expired.", docs: 'docs/guides/error-codes.md#forget_requires_owner', suggestion: 'Do not retry. Tell the user the fact or take needs their decision and give them the command in fix (gbrain trust confirm <proposal_ref> on the brain host).' },reserved_frontmatter_key: { class: 'caller', summary: 'A remote page write tried to add or change a frontmatter key only a trusted derived writer sets (`retired_by`, `retired_at`, `retired_generation`); nothing was written.', why: 'Those keys mark a page a derived writer retired, which the purge holds for 30 days and the repairs treat as machine-owned. A remote caller that could set them could make a page look machine-retired. Carrying the stored value unchanged, or dropping the key, is allowed.', suggestion: 'Remove the key from the frontmatter (or keep the stored value) and write the page again.' },- generation_fenced: { class: 'retryable', exit: 11, reasons: ['stale_generation', 'pin_moved'], summary: 'A derived result was not published because the live generation or its input changed after the producer read them; nothing was written.', why: 'The generation primitive (GBRA-161) publishes a result only against the generation and input pin it was computed from. A concurrent run that published first (stale_generation), or an input edited since the read (pin_moved), would otherwise let an older result replace a newer one.', docs: 'docs/architecture/generations.md', suggestion: 'Run the producer again; it reads the current generation and input and recomputes.' },+ generation_fenced: { class: 'retryable', exit: 11, reasons: ['stale_generation', 'pin_moved'], summary: 'A derived result was not published because the live generation or its input changed after the producer read them; nothing was written.', why: 'The generation primitive (GBRA-161) publishes a result only against the generation and input pin it was computed from. A concurrent run that published first (stale_generation), or an input edited since the read (pin_moved), would otherwise let an older result replace a newer one.', docs: 'docs/architecture/generations.md#publishing', suggestion: 'Run the producer again; it reads the current generation and input and recomputes.' },generation_held: { class: 'caller', reasons: ['shrunk', 'oversize', 'valve', 'no_proof', 'fence_absent', 'attempts_exhausted', 'segmented_unsupported'], summary: 'A derived result was recorded as held instead of published, so nothing it would have retired was retired.', why: 'A model-produced result at or below the input-relative shrink floor (shrunk), one over generations.max_items (oversize), one over the run window retirement budget (valve), an empty result without a proof the input is really empty (no_proof, fence_absent), repeated failed attempts on one input (attempts_exhausted) or a segmented page the ledger cannot keep a copy of (segmented_unsupported) would retire live items on evidence the primitive does not accept (GBRA-161 D4/D5).', docs: 'docs/guides/repair.md#generations', suggestion: 'Preview the held set with gbrain repair generations --kind <kind> --mode release-held --held --since <restore_days>d. shrunk, valve and attempts_exhausted publish once with --apply --expect <hash> --yes after the user agrees; oversize needs gbrain config set generations.max_items first; no_proof, fence_absent and segmented_unsupported clear only when the input changes.', fix: { argv: ['gbrain', 'doctor', '--only', 'generation_held', '--json'], consent: [], actor: 'agent', why: 'Lists the held generations by kind and reason with their preview commands, read-only.', requires_exclusive: false } },- generation_live_conflict: { class: 'retryable', exit: 11, summary: 'A derived generation was not activated because one of its items was not live at the content the publication wrote; nothing was committed.', why: 'Activation rechecks every item of the new generation under the key lock; an item another writer changed or deleted in between would make the ledger record a set that is not what the pages say.', docs: 'docs/architecture/generations.md', suggestion: 'Run the producer again; it reads the items as they are now.' },+ generation_live_conflict: { class: 'retryable', exit: 11, summary: 'A derived generation was not activated because one of its items was not live at the content the publication wrote; nothing was committed.', why: 'Activation rechecks every item of the new generation under the key lock; an item another writer changed or deleted in between would make the ledger record a set that is not what the pages say.', docs: 'docs/architecture/generations.md#publishing', suggestion: 'Run the producer again; it reads the items as they are now.' },frontmatter_slug_conflict: { class: 'caller', summary: "The file's frontmatter `slug:` names a different page than its path does.", why: "The path decides a file's page; a conflicting declared slug would overwrite or fork another page, so the file is refused until one of them changes.", suggestion: 'Remove the `slug:` line or make it match the path, then commit and sync again.' },full_resync_required: { class: 'retryable', summary: "The catalog cursor is invalid or expired." },gate_failed: { class: 'caller', summary: "The eval gate found retrieval regressions or correctness below its thresholds." },diff --git a/src/core/generations/publish.ts b/src/core/generations/publish.tsindex 03314adb18..20981e9ad2 100644--- a/src/core/generations/publish.ts+++ b/src/core/generations/publish.ts@@ -72,7 +72,7 @@ export async function readLiveGeneration(db: BrainEngine, key: GenerationKey): Pfunction fenced(reason: 'stale_generation' | 'pin_moved', key: GenerationKey, detail: string) {return opError('generation_fenced', `The ${key.kind} generation of ${key.ownerKey} was not published: ${detail}; nothing was written.`,- 'Run the producer again; it reads the current generation and input and recomputes.', { reason, docs: 'docs/architecture/generations.md' });+ 'Run the producer again; it reads the current generation and input and recomputes.', { reason, docs: 'docs/architecture/generations.md#publishing' });}export interface LedgerItem { key: string; identityHash: string; action: 'published' | 'retired' | 'revived' | 'kept' | 'adopted'; preimage?: Preimage }@@ -105,7 +105,7 @@ export async function assertItemsLive(tx: BrainEngine, adapter: GenerationAdapteconst wrong = [...expected].filter(([itemKey, identity]) => { const row = rows.get(itemKey); return !row?.live || row.identityHash !== identity; }).map(([itemKey]) => itemKey);if (wrong.length) {throw opError('generation_live_conflict', `The ${key.kind} generation of ${key.ownerKey} was not activated: ${wrong.slice(0, 5).join(', ')} is not live at the content just written; nothing was committed.`,- 'Run the producer again; it reads the items as they are now.', { docs: 'docs/architecture/generations.md' });+ 'Run the producer again; it reads the items as they are now.', { docs: 'docs/architecture/generations.md#publishing' });}}diff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.jsonindex e3477807f1..4efa858d5c 100644--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json@@ -1089,7 +1089,7 @@{"category": "ops","elapsed_ms": "<volatile>",- "message": "RLS enabled on 151/151 public tables",+ "message": "RLS enabled on 154/154 public tables","name": "rls","status": "ok"},@@ -1103,14 +1103,14 @@{"category": "meta","elapsed_ms": "<volatile>",- "message": "1302 column(s) verified against live schema",+ "message": "1335 column(s) verified against live schema","name": "schema_columns","status": "ok"},{"category": "meta","elapsed_ms": "<volatile>",- "message": "All 151 table(s) the applied migrations create exist.",+ "message": "All 154 table(s) the applied migrations create exist.","name": "schema_missing_tables","status": "ok"},@@ -1907,6 +1907,35 @@"name": "atom_retirements_restorable","status": "ok"},+ {+ "category": "brain",+ "details": {+ "by_source": [],+ "docs": "docs/guides/repair.md#generations",+ "items": 0,+ "keys": 0,+ "repair": "generations",+ "restore_days": 30+ },+ "elapsed_ms": "<volatile>",+ "message": "No live generation retired items in the last 30 day(s).",+ "name": "generation_retirements",+ "status": "ok"+ },+ {+ "category": "brain",+ "details": {+ "by_reason": [],+ "count": 0,+ "docs": "docs/guides/repair.md#generations",+ "releasable": 0,+ "repair": "generations"+ },+ "elapsed_ms": "<volatile>",+ "message": "No derived generation is held.",+ "name": "generation_held",+ "status": "ok"+ },{"category": "brain","details": {@@ -5630,7 +5659,7 @@{"category": "ops","elapsed_ms": "<volatile>",- "message": "RLS enabled on 151/151 public tables",+ "message": "RLS enabled on 154/154 public tables","name": "rls","status": "ok"},@@ -5644,14 +5673,14 @@{"category": "meta","elapsed_ms": "<volatile>",- "message": "1302 column(s) verified against live schema",+ "message": "1335 column(s) verified against live schema","name": "schema_columns","status": "ok"},{"category": "meta","elapsed_ms": "<volatile>",- "message": "All 151 table(s) the applied migrations create exist.",+ "message": "All 154 table(s) the applied migrations create exist.","name": "schema_missing_tables","status": "ok"},@@ -6448,6 +6477,35 @@"name": "atom_retirements_restorable","status": "ok"},+ {+ "category": "brain",+ "details": {+ "by_source": [],+ "docs": "docs/guides/repair.md#generations",+ "items": 0,+ "keys": 0,+ "repair": "generations",+ "restore_days": 30+ },+ "elapsed_ms": "<volatile>",+ "message": "No live generation retired items in the last 30 day(s).",+ "name": "generation_retirements",+ "status": "ok"+ },+ {+ "category": "brain",+ "details": {+ "by_reason": [],+ "count": 0,+ "docs": "docs/guides/repair.md#generations",+ "releasable": 0,+ "repair": "generations"+ },+ "elapsed_ms": "<volatile>",+ "message": "No derived generation is held.",+ "name": "generation_held",+ "status": "ok"+ },{"category": "brain","details": {diff --git a/test/trust-write-gate-drift.test.ts b/test/trust-write-gate-drift.test.tsindex 42a6e2d082..5dace42574 100644--- a/test/trust-write-gate-drift.test.ts+++ b/test/trust-write-gate-drift.test.ts@@ -26,7 +26,6 @@ const EXEMPT: Record<string, string> = {'src/core/company-brain/profile.ts': 'company profile publication of an owner-approved company source (operator_curated, never gated)','src/core/cycle/dream-provenance.ts': 'stamps provenance frontmatter; no new text','src/core/cycle/drift.ts': 'adjusts take weights from evidence drift; no new text',- 'src/core/cycle/extract-atoms-page-state.ts': 'atom scan bookkeeping; no content','src/core/cycle/grade-takes.ts': 'writes resolution fields on existing takes; no new claim text','src/core/cycle/phantom-redirect.ts': 'slug redirect (placement only)','src/core/embed-facts.ts': 'embedding columns only',