Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
test: doctor goldens gain uncommitted_sync_deletions; delete-cap reads use resolvable config keys
garrytan42714f45da1c
diff --git a/src/core/sync-reconcile.ts b/src/core/sync-reconcile.tsindex f0e11318c4..12129eb278 100644--- a/src/core/sync-reconcile.ts+++ b/src/core/sync-reconcile.ts@@ -72,9 +72,11 @@ export async function readPurgeRetentionHours(engine: { getConfig(key: string):/** The caps in effect for `sourceId`: its own key, else the brain's, else the default. */export async function readSyncDeleteCaps(engine: { getConfig(key: string): Promise<string | null> }, sourceId: string): Promise<SyncDeleteCaps> {- const read = async (key: typeof SYNC_MAX_DELETES_KEY | typeof SYNC_MAX_DELETE_RATIO_KEY, fallback: number) =>- parseSyncDeleteCap(key, await engine.getConfig(`${key}.source.${sourceId}`)) ?? parseSyncDeleteCap(key, await engine.getConfig(key)) ?? fallback;- return { maxDeletes: await read(SYNC_MAX_DELETES_KEY, DEFAULT_SYNC_MAX_DELETES), maxDeleteRatio: await read(SYNC_MAX_DELETE_RATIO_KEY, DEFAULT_SYNC_MAX_DELETE_RATIO) };+ const maxDeletes = parseSyncDeleteCap(SYNC_MAX_DELETES_KEY, await engine.getConfig(`sync.max_deletes.source.${sourceId}`))+ ?? parseSyncDeleteCap(SYNC_MAX_DELETES_KEY, await engine.getConfig(SYNC_MAX_DELETES_KEY)) ?? DEFAULT_SYNC_MAX_DELETES;+ const maxDeleteRatio = parseSyncDeleteCap(SYNC_MAX_DELETE_RATIO_KEY, await engine.getConfig(`sync.max_delete_ratio.source.${sourceId}`))+ ?? parseSyncDeleteCap(SYNC_MAX_DELETE_RATIO_KEY, await engine.getConfig(SYNC_MAX_DELETE_RATIO_KEY)) ?? DEFAULT_SYNC_MAX_DELETE_RATIO;+ return { maxDeletes, maxDeleteRatio };}/** The limit `deletes` deletions out of `reconcilable` file-backed pages go over, or null. */diff --git a/test/fixtures/goldens/doctor/content-pglite-human.json b/test/fixtures/goldens/doctor/content-pglite-human.jsonindex fd8f676fe4..75ae44858d 100644--- a/test/fixtures/goldens/doctor/content-pglite-human.json+++ b/test/fixtures/goldens/doctor/content-pglite-human.json@@ -211,6 +211,7 @@" [OK] rename_identity_downgrades: No rename that lost its page identity is waiting for a disposition."," [OK] purge_parked_pages: No soft-deleted page is parked by the managed purge."," [INFO] missing_recorded_files: Not applicable: no source is a classic checkout on this host (managed sources are checked by ghost_pages).",+ " [OK] uncommitted_sync_deletions: No soft-deleted page was removed by a sync while Git never held its file (0 tombstone(s) checked)."," [INFO] unindexed_files: Unindexed files are not known for default (not computed yet), notes (not computed yet). The maintenance phase unindexed_files computes them on each run and continues an incomplete scan; to compute them now, run gbrain sources retry-held <id> --unindexed."," [OK] sync_overwritten_db_edits: No page shows a database edit that a sync import overwrote."," [OK] sync_config_keys: No retired sync config key is stored on this brain.",diff --git a/test/fixtures/goldens/doctor/content-pglite-json.json b/test/fixtures/goldens/doctor/content-pglite-json.jsonindex 0fd5e4b235..b027bb61f6 100644--- a/test/fixtures/goldens/doctor/content-pglite-json.json+++ b/test/fixtures/goldens/doctor/content-pglite-json.json@@ -3120,6 +3120,44 @@"severity": "info","status": "ok"},+ {+ "category": "brain",+ "details": {+ "by_source": [+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "default",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ },+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "notes",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ }+ ],+ "count": 0,+ "docs": "docs/guides/repair.md#uncommitted-deletions",+ "exact": true,+ "other_writer_count": 0,+ "purged": "Pages already purged cannot be restored by this command; only a backup (pg_dump, or gbrain backup create taken before the purge) can bring them back.",+ "samples": [],+ "truncated": false+ },+ "elapsed_ms": "<volatile>",+ "message": "No soft-deleted page was removed by a sync while Git never held its file (0 tombstone(s) checked).",+ "name": "uncommitted_sync_deletions",+ "status": "ok"+ },{"category": "brain","details": {diff --git a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json b/test/fixtures/goldens/doctor/hot-checks-pglite-json.jsonindex beade6096c..5e1878a0f5 100644--- a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json+++ b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json@@ -3313,6 +3313,54 @@"severity": "info","status": "ok"},+ {+ "category": "brain",+ "details": {+ "by_source": [+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "default",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ },+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "notes",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ },+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "plain",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ }+ ],+ "count": 0,+ "docs": "docs/guides/repair.md#uncommitted-deletions",+ "exact": true,+ "other_writer_count": 0,+ "purged": "Pages already purged cannot be restored by this command; only a backup (pg_dump, or gbrain backup create taken before the purge) can bring them back.",+ "samples": [],+ "truncated": false+ },+ "elapsed_ms": "<volatile>",+ "message": "No soft-deleted page was removed by a sync while Git never held its file (0 tombstone(s) checked).",+ "name": "uncommitted_sync_deletions",+ "status": "ok"+ },{"category": "brain","details": {@@ -7664,6 +7712,54 @@"severity": "info","status": "ok"},+ {+ "category": "brain",+ "details": {+ "by_source": [+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "default",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ },+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "notes",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ },+ {+ "checked": 0,+ "other_writer": 0,+ "source_id": "plain",+ "status": "known",+ "sync_deleted": 0,+ "tombstones": 0,+ "truncated": false,+ "unknown": 0+ }+ ],+ "count": 0,+ "docs": "docs/guides/repair.md#uncommitted-deletions",+ "exact": true,+ "other_writer_count": 0,+ "purged": "Pages already purged cannot be restored by this command; only a backup (pg_dump, or gbrain backup create taken before the purge) can bring them back.",+ "samples": [],+ "truncated": false+ },+ "elapsed_ms": "<volatile>",+ "message": "No soft-deleted page was removed by a sync while Git never held its file (0 tombstone(s) checked).",+ "name": "uncommitted_sync_deletions",+ "status": "ok"+ },{"category": "brain","details": {