Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(sync): the waiver screen checks authority after the snapshot read again
garrytandfbe0f464351
diff --git a/src/core/persistence/sync-waivers.ts b/src/core/persistence/sync-waivers.tsindex fec05be6ec..6e00186386 100644--- a/src/core/persistence/sync-waivers.ts+++ b/src/core/persistence/sync-waivers.ts@@ -76,22 +76,17 @@ export async function screenWaiver(engine: BrainEngine, cursor: WaiverCursor, peconst intent = pending.intent;if (intent.kind === 'managed_sync_delete') {if (intent.unownedDeletion || intent.renameFrom || intent.rawHash !== null || typeof intent.path !== 'string' || typeof intent.sourcePath !== 'string') return null;- // The authority check runs beside the snapshot read; its refusal counts only for an entry that would be waived.- const [snapshot, denied] = await Promise.all([engine.readPageSnapshot(pending.slug, { sourceId: cursor.sourceId, includeDeleted: true }), authorityRefusal(engine, cursor, pending)]);+ const snapshot = await engine.readPageSnapshot(pending.slug, { sourceId: cursor.sourceId, includeDeleted: true });if (!softDeletedAt(snapshot, pending)) return null;- if (denied) throw denied.error;+ await validateSyncAuthority(engine, cursor.authority, pending.slug);return { kind: 'delete', kernel: [] };}- const [kernel, denied] = await Promise.all([unchangedSyncImport(engine, cursor, pending, config), authorityRefusal(engine, cursor, pending)]);+ const kernel = await unchangedSyncImport(engine, cursor, pending, config);if (!kernel) return null;- if (denied) throw denied.error;+ await validateSyncAuthority(engine, cursor.authority, pending.slug);return { kind: 'import', kernel };}-function authorityRefusal(engine: BrainEngine, cursor: WaiverCursor, pending: WaiverEntry): Promise<{ error: unknown } | null> {- return validateSyncAuthority(engine, cursor.authority, pending.slug).then(() => null, (error: unknown) => ({ error }));-}-/** #5984: `GBRAIN_SYNC_WAIVE_BATCH=0` (or `sync.waive_batch=false`) waives one entry per transaction, as before. */export async function waiverBatchEnabled(engine: BrainEngine, env: NodeJS.ProcessEnv = process.env): Promise<boolean> {const value = env.GBRAIN_SYNC_WAIVE_BATCH ?? await engine.getConfig('sync.waive_batch').catch(() => null);