Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix: reverify only app-pinned completed memory actions

Barack Sokullu1d45a118c184
diff --git a/package-lock.json b/package-lock.json
index b15021abe..dc3abf219 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "webbrain",
- "version": "40.4.3",
+ "version": "40.4.4",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "webbrain",
- "version": "40.4.3",
+ "version": "40.4.4",
"license": "GPL-3.0-or-later",
"devDependencies": {
"c8": "^12.0.0",
diff --git a/package.json b/package.json
index 75270aed0..beed0398e 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "webbrain",
- "version": "40.4.3",
+ "version": "40.4.4",
"description": "Open-source AI browser agent — chat with pages, automate tasks, multi-provider LLM support.",
"private": true,
"type": "module",
diff --git a/src/chrome/ARCHITECTURE.md b/src/chrome/ARCHITECTURE.md
index 7db2e84f1..3363015ba 100644
--- a/src/chrome/ARCHITECTURE.md
+++ b/src/chrome/ARCHITECTURE.md
@@ -1,6 +1,6 @@
# WebBrain Chrome/Edge Extension — Architecture
-> Version 40.4.3 · Manifest V3 · Service Worker background
+> Version 40.4.4 · Manifest V3 · Service Worker background
## High-Level Overview
diff --git a/src/chrome/manifest.json b/src/chrome/manifest.json
index 84ac9509d..a521aafb4 100644
--- a/src/chrome/manifest.json
+++ b/src/chrome/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "WebBrain",
- "version": "40.4.3",
+ "version": "40.4.4",
"description": "Open-source AI browser agent — chat with pages, automate tasks, multi-provider LLM support.",
"permissions": [
"sidePanel",
diff --git a/src/chrome/src/agent/bot-memory.js b/src/chrome/src/agent/bot-memory.js
index 39e66a5ac..d0404c8dc 100644
--- a/src/chrome/src/agent/bot-memory.js
+++ b/src/chrome/src/agent/bot-memory.js
@@ -358,8 +358,20 @@ export class BotMemorySession {
this.closed = false;
}
rememberAttempt(attempt, observedTarget = null) {
+ const scope = this.config.context?.reconciliation;
+ const rootRunId = this.config.runId.replace(/-recovery-[23]$/, '');
+ const pinnedVerified = attempt?.status === 'verified' && scope?.version === 1
+ && /^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i.test(rootRunId)
+ && scope.runId === rootRunId && typeof scope.instructionHash === 'string' && /^[a-f0-9]{64}$/.test(scope.instructionHash)
+ && Array.isArray(scope.targets) && scope.targets.length <= 20
+ && typeof attempt.runId === 'string' && Number.isInteger(attempt.policyVersion)
+ && attempt.policyVersion > 0 && typeof attempt.actionKey === 'string' && !!attempt.actionKey
+ && typeof attempt.identity === 'string' && attempt.identity === memoryTargetIdentity(attempt.target)
+ && scope.targets.some(target => target?.attemptId === attempt.id && target.runId === attempt.runId
+ && target.policyVersion === attempt.policyVersion && target.actionKey === attempt.actionKey
+ && target.identity === attempt.identity);
if (!attempt || typeof attempt.id !== 'string' || attempt.botId !== this.config.botId
- || !['dispatched', 'uncertain'].includes(attempt.status)) return;
+ || (!['dispatched', 'uncertain'].includes(attempt.status) && !pinnedVerified)) return;
const identity = memoryTargetIdentity(attempt.target);
if (!identity || (observedTarget && identity !== memoryTargetIdentity(observedTarget))) return;
this.knownAttempts.set(attempt.id, { attemptId: attempt.id, target: structuredClone(attempt.target),
diff --git a/src/chrome/src/ui/settings.js b/src/chrome/src/ui/settings.js
index 23749202b..83abb8aca 100644
--- a/src/chrome/src/ui/settings.js
+++ b/src/chrome/src/ui/settings.js
@@ -92,7 +92,7 @@ const SUBSCRIPTION_GUIDE_PRODUCTS = Object.freeze({
// Version shown in the subtitle. Kept here so it only needs one update per
// release; the subtitle string itself is translated.
-const EXT_VERSION = '40.4.3';
+const EXT_VERSION = '40.4.4';
const providersContainer = document.getElementById('providers');
const displaySettings = document.getElementById('display-settings');
diff --git a/src/firefox/ARCHITECTURE.md b/src/firefox/ARCHITECTURE.md
index e6a9f7a5d..af7499e4c 100644
--- a/src/firefox/ARCHITECTURE.md
+++ b/src/firefox/ARCHITECTURE.md
@@ -1,6 +1,6 @@
# WebBrain Firefox Extension — Architecture
-> Version 40.4.3 · Manifest V2 · Background Page
+> Version 40.4.4 · Manifest V2 · Background Page
## How Firefox Differs from Chrome
diff --git a/src/firefox/manifest.json b/src/firefox/manifest.json
index 353caf22b..2fea95fb6 100644
--- a/src/firefox/manifest.json
+++ b/src/firefox/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "WebBrain",
- "version": "40.4.3",
+ "version": "40.4.4",
"description": "Open-source AI browser agent — chat with pages, automate tasks, multi-provider LLM support.",
"permissions": [
"activeTab",
diff --git a/src/firefox/src/agent/bot-memory.js b/src/firefox/src/agent/bot-memory.js
index 39e66a5ac..d0404c8dc 100644
--- a/src/firefox/src/agent/bot-memory.js
+++ b/src/firefox/src/agent/bot-memory.js
@@ -358,8 +358,20 @@ export class BotMemorySession {
this.closed = false;
}
rememberAttempt(attempt, observedTarget = null) {
+ const scope = this.config.context?.reconciliation;
+ const rootRunId = this.config.runId.replace(/-recovery-[23]$/, '');
+ const pinnedVerified = attempt?.status === 'verified' && scope?.version === 1
+ && /^[a-f0-9]{8}-[a-f0-9]{4}-[1-8][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$/i.test(rootRunId)
+ && scope.runId === rootRunId && typeof scope.instructionHash === 'string' && /^[a-f0-9]{64}$/.test(scope.instructionHash)
+ && Array.isArray(scope.targets) && scope.targets.length <= 20
+ && typeof attempt.runId === 'string' && Number.isInteger(attempt.policyVersion)
+ && attempt.policyVersion > 0 && typeof attempt.actionKey === 'string' && !!attempt.actionKey
+ && typeof attempt.identity === 'string' && attempt.identity === memoryTargetIdentity(attempt.target)
+ && scope.targets.some(target => target?.attemptId === attempt.id && target.runId === attempt.runId
+ && target.policyVersion === attempt.policyVersion && target.actionKey === attempt.actionKey
+ && target.identity === attempt.identity);
if (!attempt || typeof attempt.id !== 'string' || attempt.botId !== this.config.botId
- || !['dispatched', 'uncertain'].includes(attempt.status)) return;
+ || (!['dispatched', 'uncertain'].includes(attempt.status) && !pinnedVerified)) return;
const identity = memoryTargetIdentity(attempt.target);
if (!identity || (observedTarget && identity !== memoryTargetIdentity(observedTarget))) return;
this.knownAttempts.set(attempt.id, { attemptId: attempt.id, target: structuredClone(attempt.target),
diff --git a/src/firefox/src/ui/settings.js b/src/firefox/src/ui/settings.js
index 00749d956..bb39dc765 100644
--- a/src/firefox/src/ui/settings.js
+++ b/src/firefox/src/ui/settings.js
@@ -84,7 +84,7 @@ const SUBSCRIPTION_GUIDE_PRODUCTS = Object.freeze({
// Version shown in the subtitle. Kept here so it only needs one update per
// release; the subtitle string itself is translated.
-const EXT_VERSION = '40.4.3';
+const EXT_VERSION = '40.4.4';
const providersContainer = document.getElementById('providers');
const displaySettings = document.getElementById('display-settings');
diff --git a/test/bot-memory.mjs b/test/bot-memory.mjs
index 8ef18c9a8..83aea60ae 100644
--- a/test/bot-memory.mjs
+++ b/test/bot-memory.mjs
@@ -222,6 +222,70 @@ for (const browser of ['chrome', 'firefox']) {
assert.equal(callbacks.length, 1);
await session.close();
});
+ test(`${browser}: only the exact immutable reconciliation target can reverify a completed write`, async () => {
+ const root = '11111111-1111-4111-8111-111111111111';
+ const previous = { id: 'verified-attempt', botId: 'bot-1', runId: '22222222-2222-4222-8222-222222222222',
+ policyVersion: 1, actionKey: 'remind', identity: memoryTargetIdentity(target), status: 'verified', target,
+ dispatchedAt: Date.now() - 1000 };
+ const pinned = { attemptId: previous.id, runId: previous.runId, policyVersion: previous.policyVersion,
+ actionKey: previous.actionKey, identity: previous.identity };
+ const envelope = suffix => ({ ...config(), runId: root + suffix,
+ callbackUrl: 'https://app.test/api/internal/bot-memory/' + root + suffix,
+ context: { recentActions: [previous], reconciliation: { version: 1, runId: root,
+ instructionHash: 'a'.repeat(64), targets: [pinned] } } });
+ for (const suffix of ['', '-recovery-2', '-recovery-3']) {
+ const calls = [];
+ const session = new BotMemorySession(envelope(suffix), { observe: async () => observed(),
+ fetchImpl: async (_, options) => { const call = JSON.parse(options.body); calls.push(call);
+ return Response.json({ verified: true, attempt: previous }); } });
+ assert.equal(session.pending.size, 0, 'A completed write must never become pending or replayable');
+ assert.equal(session.knownAttempts.size, 1);
+ await session.afterTool(7, 'read_page', {}, { success: true, text: 'Fresh page' });
+ assert.deepEqual(calls, [], 'Fresh reads must not automatically mutate a completed record');
+ assert.equal((await session.tool(7, 'bot_memory_verify', { attempt_id: previous.id })).verified, true);
+ assert.deepEqual(calls.map(call => call.operation), ['verify']);
+ assert.equal(calls[0].args.attemptId, previous.id);
+ assert.deepEqual(JSON.parse(calls[0].args.evidence.facts.observedTarget), target);
+ await session.close();
+ assert.deepEqual(calls.map(call => call.operation), ['verify'], 'Closing must not downgrade completed history');
+ }
+ const wrong = [
+ value => { delete value.context.reconciliation; },
+ value => { value.context.reconciliation.version = 2; },
+ value => { value.context.reconciliation.runId = previous.runId; },
+ value => { value.context.reconciliation.instructionHash = ''; },
+ value => { value.context.reconciliation.instructionHash = ['a'.repeat(64)]; },
+ value => { value.context.reconciliation.targets[0].attemptId = 'other'; },
+ value => { value.context.reconciliation.targets[0].runId = root; },
+ value => { value.context.reconciliation.targets[0].policyVersion = 2; },
+ value => { value.context.reconciliation.targets[0].actionKey = 'other'; },
+ value => { value.context.reconciliation.targets[0].identity += '-other'; },
+ value => { value.context.recentActions[0].botId = 'bot-2'; },
+ value => { value.context.recentActions[0].target.url += '?different=1'; },
+ value => { value.runId += '-recovery-4'; value.callbackUrl += '-recovery-4'; },
+ value => { value.runId += '-recovery-2-recovery-3'; value.callbackUrl += '-recovery-2-recovery-3'; },
+ ];
+ for (const mutate of wrong) {
+ const value = structuredClone(envelope('')); mutate(value);
+ const calls = [];
+ const session = new BotMemorySession(value, { observe: async () => observed(),
+ fetchImpl: async (_, options) => { calls.push(JSON.parse(options.body)); return Response.json({ verified: true }); } });
+ assert.equal(session.knownAttempts.size, 0);
+ assert.equal((await session.verify(7, previous.id)).success, false);
+ await session.close(); assert.deepEqual(calls, []);
+ }
+ const calls = [];
+ const lookup = new BotMemorySession({ ...envelope(''), context: { ...envelope('').context, recentActions: [] } }, {
+ observe: async () => observed(), fetchImpl: async (_, options) => { const call = JSON.parse(options.body); calls.push(call);
+ return Response.json(call.operation === 'lookup' ? { previous } : { verified: true }); },
+ });
+ await lookup.tool(7, 'bot_memory_observe', {});
+ await lookup.tool(7, 'bot_memory_lookup', { action_key: 'remind', target_index: 0 });
+ assert.equal(lookup.knownAttempts.size, 1);
+ lookup.observe = async () => ({ ...observed(), targets: [{ kind: 'url', url: target.url + '?different=1' }] });
+ assert.equal((await lookup.verify(7, previous.id)).success, false);
+ await lookup.close(); assert.deepEqual(calls.map(call => call.operation), ['lookup']);
+ });
test(`${browser}: identity preserves generic SPA fragments and meaningful queries, with known video URL equivalence`, async () => {
assert.notEqual(memoryTargetIdentity({ kind: 'url', url: 'https://example.test/#!/invoice/103' }),
memoryTargetIdentity({ kind: 'url', url: 'https://example.test/#!/invoice/104' }));