Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Keep the #9184 + #9188 entry inside the CI guards: count #9188's second facts UPDATE in the writer inventories, drop a placeholder from the label-edit suggestion, and weigh the readers test on the Postgres arms

garrytan8152caf616f5
diff --git a/docs/architecture/canonical-writers.tsv b/docs/architecture/canonical-writers.tsv
index 5c8542a84c..e9aa1ba585 100644
--- a/docs/architecture/canonical-writers.tsv
+++ b/docs/architecture/canonical-writers.tsv
@@ -291,7 +291,7 @@ src/core/belief/purge.ts 1 engine_guard bumpPurgeEpoch updates only sources.purg
src/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 the revision-bound label-only write (repair/label-write.ts).
+src/core/repair/visibility.ts 2 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 change in the page through the revision-bound label-only write (repair/label-write.ts); only on an unmanaged brain, when that write kept a more trusted world row beside the new private one, a second UPDATE in one maintenanceTransaction makes that row private, rechecking id, row_num, visibility='world' and expired_at IS NULL (GST-2487).
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/docs/architecture/system-of-record.md b/docs/architecture/system-of-record.md
index c55b48cd41..2cfb6c487f 100644
--- a/docs/architecture/system-of-record.md
+++ b/docs/architecture/system-of-record.md
@@ -328,7 +328,7 @@ or a physical projection that leaves attribution untouched):
- `src/core/repair/timeline-comments.ts` (1): `gbrain repair timeline-comments` row cleanup: `withCoordinatedWrite` under the page key on managed brains, `maintenanceTransaction` otherwise.
- `src/core/repair/url-clone-fences.ts` (2): `gbrain repair url-clone-fences` (#6946), unmanaged brains only (a managed brain previews nothing); keeping the appended fence rows database-only (clearing `row_num`, inserting a row the database lost) runs in one `maintenanceTransaction` under the page lock after the preview recheck; HEAD's bytes then import through `importFromContent` (a HEAD that asks for private in a spelling page privacy does not read is held: not imported, and the apply reports `held`, #7897).
- `src/core/repair/unwithdrawn-facts.ts` (1): `gbrain repair unwithdrawn-facts` (#8819) puts back the ledger preimage of each preview-approved fact a fence generation retired though no fence held it: a database-only `managed_maintenance_restore_unwithdrawn_facts` request on managed brains; unmanaged and repo-less brains list every candidate as `excluded:unmanaged_reconcile`, so their page-locked `maintenanceTransaction` only reclassifies a set previewed while the brain was managed and restores nothing.
-- `src/core/repair/visibility.ts` (1): `gbrain repair visibility --apply` tightening of database-only world facts from a private source: a receipted `managed_maintenance_tighten_fact_visibility` request on managed brains, `maintenanceTransaction` on unmanaged ones; fenced rows change through a revision-bound `put_page`.
+- `src/core/repair/visibility.ts` (2): `gbrain repair visibility --apply` tightening of database-only world facts from a private source: a receipted `managed_maintenance_tighten_fact_visibility` request on managed brains, `maintenanceTransaction` on unmanaged ones; fenced rows change through a revision-bound `put_page`, and on an unmanaged brain a more trusted world row the page write kept is made private in one `maintenanceTransaction`.
- `src/core/schema-pack/page-to-alias.ts` (1): the page-to-alias conversion soft-deletes each converted page in `maintenanceTransaction`.
- `src/core/schema-pack/page-to-link.ts` (1): the page-to-link conversion soft-deletes each converted page in `maintenanceTransaction`.
- `src/core/schema-pack/retype.ts` (1): each bounded retype batch runs in `maintenanceTransaction`.
diff --git a/scripts/postgres-arm-weights-postgres-only.json b/scripts/postgres-arm-weights-postgres-only.json
index c9054f71bc..814b1c8bc5 100644
--- a/scripts/postgres-arm-weights-postgres-only.json
+++ b/scripts/postgres-arm-weights-postgres-only.json
@@ -333,6 +333,7 @@
"test/purge-global-marker.test.ts": 5204,
"test/purge-missing-cache-6911.test.ts": 10826,
"test/purge-read-surfaces.test.ts": 15834,
+ "test/readers-label-setter.test.ts": 21304,
"test/recall-page-fill.test.ts": 7624,
"test/receipt-compaction-newest-sync-gbra130.test.ts": 4363,
"test/remediation-manual-only.test.ts": 8860,
diff --git a/scripts/postgres-arm-weights.json b/scripts/postgres-arm-weights.json
index cdef99f4c2..71d553184d 100644
--- a/scripts/postgres-arm-weights.json
+++ b/scripts/postgres-arm-weights.json
@@ -487,6 +487,7 @@
"test/qm-scope-read.test.ts": 12809,
"test/qm-scope-writes.test.ts": 26999,
"test/read-meta-diag.test.ts": 6603,
+ "test/readers-label-setter.test.ts": 35850,
"test/reason-trailers-gbra217.test.ts": 22834,
"test/recall-page-fill.test.ts": 11747,
"test/receipt-compaction-newest-sync-gbra130.test.ts": 7251,
diff --git a/src/core/persistence/label-edit.ts b/src/core/persistence/label-edit.ts
index ef108846db..9c6fd7792f 100644
--- a/src/core/persistence/label-edit.ts
+++ b/src/core/persistence/label-edit.ts
@@ -37,7 +37,7 @@ export function readLabelEdit(value: unknown): LabelEdit | undefined {
&& Object.entries(set).every(([key, v]) => EDIT_KEYS.includes(key) && plainValue(key, v))
&& remove.every(key => typeof key === 'string' && EDIT_KEYS.includes(key) && !Object.hasOwn(set, key));
if (!valid) throw opError('invalid_params', 'The label edit names a key or value a label edit cannot write.',
- `A label edit sets or removes only ${EDIT_KEYS.join(', ')}, each value a plain word (${READERS_KEY}: a list of member ids or group:<id>). This is a gbrain planning defect: report it with the gbrain version; nothing was written.`);
+ `A label edit sets or removes only ${EDIT_KEYS.join(', ')}, each value a plain word (${READERS_KEY}: a list of member ids and group: ids). This is a gbrain planning defect: report it with the gbrain version; nothing was written.`);
return { set: Object.fromEntries(Object.entries(set as LabelEdit['set']).map(([key, v]) => [key, Array.isArray(v) ? [...v] : v])), remove: [...new Set(remove as string[])] };
}