Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Register the label repair writer and trust listing with the census guards
garrytanc41665b58827
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsvindex 50b8fecfd9..985d0ae5dc 100644--- a/docs/architecture/canonical-writers.tsv+++ b/docs/architecture/canonical-writers.tsv@@ -33,6 +33,7 @@ src/core/persistence/twin-merge.ts 10 coordinator The #6948 twin merge (links insrc/core/repair/origin-twins.ts 1 coordinator gbrain repair origin-twins and the post-sync heal resolve each verified twin as a receipted managed_maintenance_resolve_origin_twin request (submitDatabaseMaintenanceIntent, owner host only) on managed brains and in one maintenanceTransaction on unmanaged brains; the verdict is recomputed inside the write and any drift holds the file instead of merging.src/core/repair/unwithdrawn-facts.ts 1 coordinator `gbrain repair unwithdrawn-facts` (#8819) puts the ledger before-state back on preview-approved facts a fact_fence generation retired though no fence held them. On a managed brain the UPDATE runs only inside the managed_maintenance_restore_unwithdrawn_facts publication; an unmanaged or repo-less brain classifies every candidate excluded (unmanaged_reconcile), so a set previewed while it was managed is reclassified in one maintenanceTransaction under the page lock after the revision recheck and restores nothing.src/core/repair/private-labels.ts 1 coordinator `gbrain repair private-labels` (GST-2059) removes or re-adds only the previewed privacy keys on preview-approved pages. On a managed brain each page goes through publishMaintenancePage (maintenancePreflight owner check, revision-bound, keep_trust; the Git door on a repo source); an unmanaged or repo-less brain re-imports it in one maintenanceTransaction under the page lock after the revision recheck, except a page whose file sits in an unmanaged source's checkout, which is held (file_backed) and never written.+src/core/repair/label-write.ts 1 coordinator The label-only page write of `gbrain repair visibility` and `gbrain repair private-labels` (GST-2468). On a managed brain it publishes through publishMaintenancePage (maintenancePreflight owner check, revision-bound, keep_trust, label_edit). Only an unmanaged or repo-less brain calls importFromContent (importAtRevision), in one maintenanceTransaction under the page lock after the revision recheck and under withTrustKeep; for a page whose file sits in an unmanaged checkout (writeLabelFile) the file must still hold the page (ownerRepairFile), and writePageThrough writes the spliced bytes back with their preimage checked inside that transaction, so a refused or failed file write rolls the import back.src/core/search-vector-backfill.ts 2 projection backfillPageVectors (reindex-search-vector, the fts_cjk_boundary migration) rewrites only pages.search_vector, through the seal's pageSearchVectorSql over the sanitized timeline and guarded by the knowledge revision it read (its read is an UPDATE-to-self of id); canonical fields are untouched and the managed writer guard passes search_vector-only updates.src/commands/sources-set-path.ts 1 coordinator Managed rebind uses native exclusion, exact manifest verification and a retained source-incarnation receipt; unmanaged pointer repair remains explicit.src/commands/sources.ts 10 coordinator Managed add/archive/restore/remove/purge/reclone route through source lifecycle; remaining legacy canonical SQL stays fenced.@@ -290,7 +291,7 @@ src/core/belief/purge.ts 1 engine_guard bumpPurgeEpoch updates only sources.purgsrc/core/belief/purge-mirror.ts 4 engine_guard W1 restore replay (BELIEF_LEDGER.md 8) of purges newer than the archive: runs only inside the backup restore's single transaction before the restored root is published, granting gbrain.write_sources for that one source in that transaction; its fact, take and page deletes repeat what purge_fact and purgePageInTransaction removed.src/core/persistence/links-extraction-holds.ts 2 engine_guard GBRA-130 A-1: records and clears only the derived pages.links_extract_failure column (a stale-extraction failure record outside the managed writer guard tracked set, like the attendance marker); it touches no canonical body, title, type, tag or frontmatter column.src/core/repair/url-clone-fences.ts 3 engine_guard GBRA-130 C-2: unmanaged brains only (refused on managed). Keeps the fence rows the database already holds database-only in a maintenance transaction, then imports the clone file's HEAD bytes through importFromContent before restoring the file (a HEAD the private hold refuses is restored without importing, #7897); preview-bound (--expect) with destructive consent and a file backup.-src/core/repair/visibility.ts 1 coordinator `gbrain repair visibility --apply` (GBRA-159) only tightens database-only active facts from world to private when their source page is private. On a managed brain the UPDATE runs only inside the managed_maintenance_tighten_fact_visibility publication (owner-checked by maintenancePreflight, page key locked); an unmanaged brain runs it in one maintenanceTransaction. The UPDATE rechecks visibility='world', row_num IS NULL and expired_at IS NULL under the row lock. Fenced rows are never updated here: they change in the page through a revision-bound put_page.+src/core/repair/visibility.ts 1 coordinator `gbrain repair visibility --apply` (GBRA-159) only tightens database-only active facts from world to private when their source page is private. On a managed brain the UPDATE runs only inside the managed_maintenance_tighten_fact_visibility publication (owner-checked by maintenancePreflight, page key locked); an unmanaged brain runs it in one maintenanceTransaction. The UPDATE rechecks visibility='world', row_num IS NULL and expired_at IS NULL under the row lock. Fenced rows are never updated here: they change in the page through the revision-bound label-only write (repair/label-write.ts).src/core/repair/access.ts 1 projection `gbrain repair access` (GBRA-218) sets only pages.page_readers, the derived readers column the v282 trigger keeps equal to gbrain_access_readers(frontmatter) on every later write, for rows whose stored value differs. It writes no canonical field, revision, content hash, generation or embedding state; gbrain_require_managed_writer passes the update because no canonical page column (identity, bodies, frontmatter, deleted_at, revision, trust tier, body generation) changes. The derived value only restores reads to listed members: a readable_by page with no derived value reads as nobody remotely.src/core/access/policy.ts 3 projection GBRA-218 A2 folder rules: restampSource sets only pages.folder_rule_ids (in id-ordered windows, then once more under the source lock), the derived column the v283 stamping trigger keeps equal to gbrain_access_folder_rules(source_id, slug) on every page write, and writeAccessStore sets only sources.config.access_store. Neither writes a canonical page column, revision, content hash, generation, source checkpoint or topology column, so gbrain_require_managed_writer passes both on a managed brain. A narrowing keeps its prefix's pending coverage row until the restamp finishes, which reads every page under it as nobody, so a stale stamp only hides.src/core/facts/file-body-guard.ts 1 engine_guard #6982 replaceStoredBody mirrors a checkout file body over the page row only inside its caller's maintenanceTransaction, after re-reading the row under a row lock and confirming it still equals the body the caller compared, and saves a page_versions row first; on a managed brain the canonical table trigger refuses the write outside the coordinator.diff --git a/src/cli/commands/trust.ts b/src/cli/commands/trust.tsindex a3f4aac838..f039a3ef34 100644--- a/src/cli/commands/trust.ts+++ b/src/cli/commands/trust.ts@@ -138,7 +138,7 @@ export async function run(engine: BrainEngine, args: string[], ctx: CliDispatchCif (rest.includes('--label-lowerings')) {await ctx.completeStartup?.(engine);const at = rest.indexOf('--source');- const source = rest.find(arg => arg.startsWith('--source='))?.slice('--source='.length) ?? (at >= 0 ? rest[at + 1] : null);+ const source = at >= 0 ? rest[at + 1] ?? '' : null;if (source !== null && (!source || source.startsWith('-'))) {await refuse(args, '--source needs a source id.', 'Run gbrain trust backfill --label-lowerings --source <id>, or omit --source to list every source.');return;diff --git a/test/fixtures/goldens/cli/literal-imports.json b/test/fixtures/goldens/cli/literal-imports.jsonindex cdf6c80117..d82de6edd0 100644--- a/test/fixtures/goldens/cli/literal-imports.json+++ b/test/fixtures/goldens/cli/literal-imports.json@@ -223,6 +223,7 @@"./commands/trust-claim.ts","./core/eligibility/explain.ts","./core/eligibility/scan.ts",+ "./core/trust/label-lowerings.ts","./core/trust/backfill.ts"],"waiting": [diff --git a/test/import-private-hold-callers-7897.test.ts b/test/import-private-hold-callers-7897.test.tsindex 7bb1e481a5..76827c6ac7 100644--- a/test/import-private-hold-callers-7897.test.ts+++ b/test/import-private-hold-callers-7897.test.ts@@ -27,7 +27,7 @@ const AUDITED: Record<string, Audit> = {'src/core/generations/adapters/page.ts': { calls: { importFromContent: 1 }, disposition: 'derived', why: 'a stored preimage or a producer page gbrain serializes' },'src/core/import-file.ts': { calls: { importFromContent: 2 }, disposition: 'held', why: 'the identity-move retry passes the caller\'s options; importFromFile holds before it imports' },'src/core/minions/handlers/ingest-capture.ts': { calls: { importFromContent: 1 }, disposition: 'held', why: 'the shared import options set holdNoncanonicalPrivate (#7880)' },- 'src/core/repair/private-labels.ts': { calls: { importFromContent: 1 }, disposition: 'derived', why: 'the stored page re-serialized with only the previewed privacy keys removed or re-added' },+ 'src/core/repair/label-write.ts': { calls: { importFromContent: 1 }, disposition: 'derived', why: 'the label-only repair write (repair visibility, repair private-labels): the stored page, or its own checkout file, with only the previewed privacy labels changed' },'src/core/oversized-backfill.ts': { calls: { importFromContent: 1 }, disposition: 'derived', why: 're-serializes the stored page' },'src/core/persistence/connector-sync.ts': { calls: { importFromContent: 1 }, disposition: 'derived',why: 'GitHub and Google renders: fixed keys, provider text only as quoted values, visibility: private only in lowercase; the rest is the stored page' },