Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: forget on an unbound connector source withdraws database-only again; only a sandbox or write-through off refuses a file-backed claim

garrytanff419a4c9ea5
diff --git a/src/core/persistence/memory-mutations.ts b/src/core/persistence/memory-mutations.ts
index c4694e2e27..21f6dfc449 100644
--- a/src/core/persistence/memory-mutations.ts
+++ b/src/core/persistence/memory-mutations.ts
@@ -339,14 +339,9 @@ export async function submitForgetMutation(ctx: OperationContext, operation: 'fo
throw verbError('scope_denied', 'A sandboxed subagent cannot strike the claim in the page files that carry it.',
'Forget the fact from the main session instead; nothing was withdrawn.', 'subagent_sandbox');
}
- if (fileBacked && target?.kind === 'publish' && target.databaseOnlyReason) {
- throw verbError('unavailable', target.databaseOnlyReason === 'disabled_by_config'
- ? 'This brain has sync.write_through off, so forget cannot strike the claim in the page files that carry it.'
- : 'This source writes the page database-only, so forget cannot strike the claim in the page files that carry it.',
- target.databaseOnlyReason === 'disabled_by_config'
- ? 'Turn write-through back on (gbrain config set sync.write_through true), then forget the fact again; nothing was withdrawn.'
- : 'Bind the source to its canonical checkout, then forget the fact again; nothing was withdrawn.',
- target.databaseOnlyReason === 'disabled_by_config' ? 'sync_write_through_off' : String(target.databaseOnlyReason));
+ if (fileBacked && target?.kind === 'publish' && target.databaseOnlyReason === 'disabled_by_config') {
+ throw verbError('unavailable', 'This brain has sync.write_through off, so forget cannot strike the claim in the page files that carry it.',
+ 'Turn write-through back on (gbrain config set sync.write_through true), then forget the fact again; nothing was withdrawn.', 'sync_write_through_off');
}
if (target?.kind === 'publish' && target.databaseOnlyReason) authority.databaseOnlyReason = target.databaseOnlyReason;
const binding = target?.kind === 'unbound' ? await claimWorktree(ctx.engine, sourceId, target.root, undefined, undefined, { automatic: true })
diff --git a/test/g4-forget-fence-edit.test.ts b/test/g4-forget-fence-edit.test.ts
index bb978e958c..6342cde19f 100644
--- a/test/g4-forget-fence-edit.test.ts
+++ b/test/g4-forget-fence-edit.test.ts
@@ -236,6 +236,19 @@ for (const backend of testBackends()) describe(`[${backend}] G4: forget is a fen
expect((await engine.executeRaw<{ active: boolean }>('SELECT expired_at IS NULL AS active FROM facts WHERE id=$1', [id]))[0]!.active).toBe(true);
}, { databaseUrl, setup }), 180_000);
+ test('an unbound connector source still withdraws a claim its page file carries, database-only', () => managedBrain(async ({ engine, ctx, root }) => {
+ expect(await call(ctx, 'put_page', { slug: 'notes/a', content: note('A', [`| 1 | ${CLAIM} | fact | 1.0 | world | medium | 2026-01-01 | | test | |`]) })).toMatchObject({ state: 'committed' });
+ const { settleManagedGitEffects } = await import('./helpers/managed-brain.ts');
+ await settleManagedGitEffects(engine);
+ const id = (await engine.executeRaw<{ id: number }>(`SELECT id FROM facts WHERE source_id='default' AND fact=$1 AND expired_at IS NULL`, [CLAIM]))[0]!.id;
+ await unbind(engine);
+ await engine.executeRaw(`UPDATE sources SET local_path=COALESCE(local_path,$1), config = config || '{"kind":"google"}'::jsonb WHERE id='default'`, [root]);
+ const before = readFileSync(join(root, 'notes/a.md'), 'utf8');
+ expect(await call(ctx, 'forget', { id: String(id) })).toMatchObject({ state: 'committed', expired: true });
+ expect(await ledger(engine, CLAIM)).toEqual(['notes/a']);
+ expect(readFileSync(join(root, 'notes/a.md'), 'utf8')).toBe(before);
+ }, { databaseUrl, setup }), 180_000);
+
test('a source whose owner is unavailable still withdraws a claim only a database-only page carries', () => managedBrain(async ({ engine, ctx, root }) => {
await engine.setConfig('sync.write_through', 'false');
expect(await call(ctx, 'put_page', { slug: 'notes/b', content: note('B', [`| 1 | ${OTHER} | fact | 1.0 | world | medium | 2026-01-01 | | test | |`]) })).toMatchObject({ state: 'committed' });