Skip to content

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

fix(social-publish): checkpoint verified post on rebind, rawValue exact body

Barack Sokullu367c6c45998b
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 9eb9ddcb1..ed65c701f 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -2793,10 +2793,11 @@ export class Agent extends LoopDetector {
if (!observedBody) return false;
const hasDedicatedAuthoredText = !!this._workflowMessageBody(record?.bodyText);
if (hasDedicatedAuthoredText) {
- // Exact verification compares NFC: compatibility folding would certify
- // visibly distinct payloads (circled digits, fullwidth letters,
- // ligatures) as the approved body.
- if (this._workflowSocialExactBody(requirement?.value)
+ // Exact verification compares NFC against the preserved raw value:
+ // compatibility folding would certify visibly distinct payloads
+ // (circled digits, fullwidth letters, ligatures) as the approved body.
+ const requiredBody = requirement?.rawValue ?? requirement?.value;
+ if (this._workflowSocialExactBody(requiredBody)
=== this._workflowSocialExactBody(authoredText)) return true;
} else {
if (this._workflowPublishedPayloadValueObserved(requirement, { pageText: authoredText })) return true;
@@ -18449,6 +18450,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (this._sameAdapterWorkflowBinding(current, live)) return false;
if (!this._trustedSocialPublishTargetAdapters(guard).has(live.adapterName)) return false;
+ // A fully verified destination must survive the rebind: checkpoint it
+ // before its terminal evidence is cleared, or the final `done` reports
+ // it missing and prompts a duplicate publication.
+ this._recordSocialPublishTargetSatisfied(guard);
const previousBindingKey = this._adapterWorkflowBindingKey(current);
guard.siteWorkflow = live;
guard.siteWorkflowUrl = liveUrl;
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 29001fa9a..fb15392cd 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -2508,10 +2508,11 @@ export class Agent extends LoopDetector {
if (!observedBody) return false;
const hasDedicatedAuthoredText = !!this._workflowMessageBody(record?.bodyText);
if (hasDedicatedAuthoredText) {
- // Exact verification compares NFC: compatibility folding would certify
- // visibly distinct payloads (circled digits, fullwidth letters,
- // ligatures) as the approved body.
- if (this._workflowSocialExactBody(requirement?.value)
+ // Exact verification compares NFC against the preserved raw value:
+ // compatibility folding would certify visibly distinct payloads
+ // (circled digits, fullwidth letters, ligatures) as the approved body.
+ const requiredBody = requirement?.rawValue ?? requirement?.value;
+ if (this._workflowSocialExactBody(requiredBody)
=== this._workflowSocialExactBody(authoredText)) return true;
} else {
if (this._workflowPublishedPayloadValueObserved(requirement, { pageText: authoredText })) return true;
@@ -16248,6 +16249,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (this._sameAdapterWorkflowBinding(current, live)) return false;
if (!this._trustedSocialPublishTargetAdapters(guard).has(live.adapterName)) return false;
+ // A fully verified destination must survive the rebind: checkpoint it
+ // before its terminal evidence is cleared, or the final `done` reports
+ // it missing and prompts a duplicate publication.
+ this._recordSocialPublishTargetSatisfied(guard);
const previousBindingKey = this._adapterWorkflowBindingKey(current);
guard.siteWorkflow = live;
guard.siteWorkflowUrl = liveUrl;
diff --git a/test/run.js b/test/run.js
index f0aa2b55a..bf1ddfe45 100644
--- a/test/run.js
+++ b/test/run.js
@@ -91325,6 +91325,53 @@ test('multi-platform social publication requires verified evidence for every des
}
});
+test('rebinding checkpoints a verified first post without a prior done', async () => {
+ for (const [index, AgentClass] of [AgentCh, AgentFx].entries()) {
+ const agent = new AgentClass({});
+ agent.useSiteAdapters = true;
+ agent._persist = () => {};
+ agent._ensureWorkflowMetadataRequirements = async () => {};
+ const tabId = 9085 + index;
+ const approvedScratchpadText = [
+ '[Approved plan pinned by planner]',
+ '- Post this update on X and Bluesky.',
+ ].join('\n');
+ agent.conversations.set(tabId, [
+ { role: 'system', content: 'system' },
+ { role: 'user', content: 'Post this update on X and Bluesky.' },
+ ]);
+ const twitterWorkflow = agent._resolvePlannerSiteWorkflow('https://x.com/compose/post', {
+ request_kind: 'execute',
+ site_job: 'publish-post',
+ });
+ const guard = agent._startPlanExecutionGuard(tabId, 'act', {
+ requestKind: 'execute',
+ requiresStateChange: true,
+ requiresSubmission: true,
+ siteWorkflow: twitterWorkflow,
+ siteWorkflowUrl: 'https://x.com/compose/post',
+ approvedScratchpadText,
+ });
+ guard.successfulConsequentialToolCalls = 1;
+ guard.evidenceTaskKey = guard.taskKey;
+ guard.workflowTerminalEvidence = {
+ bindingKey: agent._adapterWorkflowBindingKey(guard.siteWorkflow),
+ job: guard.siteWorkflow.job.id,
+ verificationKind: agent._workflowVerificationKind(guard.siteWorkflow),
+ source: 'dispatch_bound_published_resource',
+ };
+ guard.verifiedSubmissionEvidence = true;
+ const liveUrl = 'https://bsky.app/';
+ agent._currentUrl = async () => liveUrl;
+ agent._currentProgressPageScope = () => liveUrl;
+ assert.equal(await agent._adoptLiveSocialPublishWorkflow(tabId, {}), true);
+ assert.equal(guard.siteWorkflow.adapterName, 'bluesky');
+ assert.deepEqual(guard.socialPublishSatisfiedTargets, ['twitter'],
+ AgentClass.name + ': rebinding without a prior done checkpoint forgot the verified first post');
+ assert.deepEqual(agent._missingSocialPublishTargets(guard), ['bluesky']);
+ }
+});
+
test('alternative social destinations require one verified publication, not every named platform', () => {
for (const [index, AgentClass] of [AgentCh, AgentFx].entries()) {
const agent = new AgentClass({});
@@ -91598,10 +91645,18 @@ test('X and Bluesky same-route publication accepts only one new permalink with t
{ field: 'body', value: 'A' },
{ bodyText: 'A' },
), false, AgentClass.name + ': an NFKC-folded fullwidth letter verified as an exact body');
- assert.equal(agent._workflowSocialPublishedBodyObserved(
- { field: 'body', value: 'Hello world' },
- { bodyText: 'Hello world' },
- ), true, AgentClass.name + ': an identical body stopped verifying');
+ assert.equal(agent._workflowSocialPublishedBodyObserved(
+ { field: 'body', value: 'Hello world' },
+ { bodyText: 'Hello world' },
+ ), true, AgentClass.name + ': an identical body stopped verifying');
+ assert.equal(agent._workflowSocialPublishedBodyObserved(
+ { field: 'body', value: '1', rawValue: 'â‘ ' },
+ { bodyText: '1' },
+ ), false, AgentClass.name + ': a folded classifier value verified against its NFKC form');
+ assert.equal(agent._workflowSocialPublishedBodyObserved(
+ { field: 'body', value: '1', rawValue: 'â‘ ' },
+ { bodyText: 'â‘ ' },
+ ), true, AgentClass.name + ': the preserved raw body stopped verifying');
const guard = agent._startPlanExecutionGuard(tabId, 'act', {
requestKind: 'execute',
requiresStateChange: true,