Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: the auto-link SQL gate reads an off value the way the TypeScript checks do

garrytan674808bdac23
diff --git a/src/core/persistence/effect-journal.ts b/src/core/persistence/effect-journal.ts
index 068257c966..ea2dd72d2c 100644
--- a/src/core/persistence/effect-journal.ts
+++ b/src/core/persistence/effect-journal.ts
@@ -17,6 +17,7 @@ import { claimOwner, EXPIRED_PREPARING_CHARGE_SQL } from './claim-phase.ts';
import { refreshFenceClear } from './worktree-refresh-schema.ts';
import { pageBatchChildRequestIds } from './page-batch-id.ts';
import { EFFECT_FAULT_POINTS, faultPoint } from './fault-points.ts';
+import { asciiLowerSql, edgeTrimSql } from '../edge-whitespace.ts';
/**
* `snapshot` is the publication's final read of the page, including deleted rows, in this transaction.
@@ -67,7 +68,7 @@ export async function queuePublicationEffects(tx: BrainEngine, row: EffectReques
const inserted = queued.length ? await tx.executeRaw<{ kind: string }>(`INSERT INTO persistence_effects (request_id,kind,revision,data,source_id,source_incarnation,worktree_id)
SELECT $1::uuid,t.e->>'kind',$2::uuid,t.e->'data',$3,$4::uuid,$5::uuid FROM jsonb_array_elements($6::text::jsonb) WITH ORDINALITY AS t(e,n)
WHERE NOT (COALESCE((t.e->>'gated')::boolean,false) AND EXISTS (SELECT 1 FROM config
- WHERE key IN ('auto_link',$7) AND lower(btrim(value,E' \\t\\r\\n')) IN ('false','0','no','off')))
+ WHERE key IN ('auto_link',$7) AND ${asciiLowerSql(edgeTrimSql('value'))} IN ('false','0','no','off')))
ORDER BY t.n ON CONFLICT(request_id,kind) DO NOTHING RETURNING kind`,
[row.id, revision ?? null, row.source_id, row.source_incarnation, row.worktree_id, JSON.stringify(queued), REMOTE_AUTO_LINKS_KEY]) : [];
if (queued.some(effect => effect.kind === 'links')) {
diff --git a/test/remote-graph-freshness.test.ts b/test/remote-graph-freshness.test.ts
index a7af07c84f..771a5e323b 100644
--- a/test/remote-graph-freshness.test.ts
+++ b/test/remote-graph-freshness.test.ts
@@ -128,4 +128,14 @@ describe('remote put_page graph freshness', () => {
await engine.unsetConfig('mcp.remote_auto_links');
}
}, 120_000);
+
+ test('an off value with edge whitespace other than a space still queues no mention pass', async () => {
+ await engine.setConfig('mcp.remote_auto_links', 'Off\u00a0');
+ try {
+ const row = await remoteWrite('notes/freshness-off-padded', BODY.replace('Freshness example', 'Freshness off padded'));
+ expect((row.outcome?.auto_links as Record<string, unknown> | undefined)?.mention_links).toBeUndefined();
+ } finally {
+ await engine.unsetConfig('mcp.remote_auto_links');
+ }
+ }, 120_000);
});