Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(persistence): a write prepared without the strict flag publishes its unchanged statements (GBRA-133)

garrytan3fa8e4c41247
diff --git a/src/core/persistence/coordinator.ts b/src/core/persistence/coordinator.ts
index 25bea044d6..4528e38c06 100644
--- a/src/core/persistence/coordinator.ts
+++ b/src/core/persistence/coordinator.ts
@@ -583,7 +583,8 @@ export async function publishMutation(engine: BrainEngine, row: WriteRequest, pr
'Retry the write with a new request_id; it is now stored database-only.');
}
const door = recovery?.version === 1 ? recovery : null;
- if (door && await sourceCanonicalGit(tx, row.source_id, true) !== !!door.door) throw strictChanged(row.source_id);
+ // A write prepared strict rechecks its flag under the source lock; one prepared without it publishes as before (only conversion sets the flag).
+ if (door?.door && !await sourceCanonicalGit(tx, row.source_id, true)) throw strictChanged(row.source_id);
if (recovery) {
const records = recoveryFiles(recovery);
for (const record of records) if ((skill ? bundleFileHash(record) : fileHash(record.path)) !== record.beforeHash) {
diff --git a/src/core/persistence/group-publish.ts b/src/core/persistence/group-publish.ts
index 9e72fb256f..8a6f19abb9 100644
--- a/src/core/persistence/group-publish.ts
+++ b/src/core/persistence/group-publish.ts
@@ -311,7 +311,8 @@ export async function publishGroup(engine: BrainEngine, rows: WriteRequest[], pr
() => members.length ? tx.executeRaw(`UPDATE persistence_requests r SET publication_started=true FROM unnest($1::uuid[],$2::uuid[]) AS t(id,token)
WHERE r.id=t.id AND r.execution_token=t.token AND r.state='running' RETURNING r.id`, [members.map(row => row.id), members.map(row => row.execution_token)]) : Promise.resolve([]),
() => prepared.some(member => member.file) ? sourceMirrorReadOnly(tx, head.source_id, true) : Promise.resolve(false),
- () => recorded.size ? sourceCanonicalGit(tx, head.source_id, true) : Promise.resolve(strict),
+ // A group prepared strict rechecks its flag under the source lock; one prepared without it publishes as before.
+ () => strict ? sourceCanonicalGit(tx, head.source_id, true) : Promise.resolve(false),
() => tx.lockPageKeys(keys),
// The owner's host binding every file member's Git effect records (a STABLE_IN_GROUP read), fetched with the guards.
() => prepared.some(member => member.file && !member.noop) ? tx.executeRaw(HOST_BINDING_SQL, [head.worktree_id]) : Promise.resolve([]),