Skip to content

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

Hold a deletion only for an earlier deletion that may have removed the same item

Barack Sokullu43d62f4547e4
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index a939edfee..b25b04f0b 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -7378,11 +7378,22 @@ export class Agent extends LoopDetector {
// to the form it was sent from. Which item to delete is still decided
// below, by the latest request or by the user on WebBrain's own card, and
// nothing is recorded as reconciled, so a later post or commit is still
- // held. An earlier attempt that may itself have deleted something still
- // holds a deletion: this one could repeat it, and a run rebuilt from the
- // conversation keeps no dispatch record that would catch the repeat.
+ // held. An earlier attempt that may itself have deleted this item still
+ // holds the deletion: this one could repeat it, and a run rebuilt from
+ // the conversation keeps no dispatch record that would catch the repeat.
+ // One that deleted another item, by its link or its row, does not; one
+ // whose item cannot be told apart from this one does.
const unreconciled = prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind);
- const earlierDeletion = archivedAttempts.some(receipt => receipt.mutationKind === 'delete');
+ const deletingLink = permalinked ? this._normalizeUrl(detected.actionResource.url) : '';
+ const deletingRow = record?.identity || '';
+ const mayRepeatThisDeletion = receipt => {
+ const link = receipt.actionResource?.complete && receipt.actionResource.url ? this._normalizeUrl(receipt.actionResource.url) : '';
+ const row = receipt.actionRecord?.identity || '';
+ if (link && deletingLink) return link === deletingLink;
+ if (row && deletingRow) return row === deletingRow;
+ return true;
+ };
+ const earlierDeletion = archivedAttempts.some(receipt => receipt.mutationKind === 'delete' && mayRepeatThisDeletion(receipt));
if (unreconciled && !(deletion && !earlierDeletion)) {
return blocked('prior_effect_unreconciled', publication && !crossPlatform
? 'The earlier post from before the latest correction has not been matched yet. Read it on this platform (its permalink or the account\'s recent posts), then retry; do not repeat an uncertain publication.'
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index e10e7a690..026cf1da4 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -6924,11 +6924,22 @@ export class Agent extends LoopDetector {
// to the form it was sent from. Which item to delete is still decided
// below, by the latest request or by the user on WebBrain's own card, and
// nothing is recorded as reconciled, so a later post or commit is still
- // held. An earlier attempt that may itself have deleted something still
- // holds a deletion: this one could repeat it, and a run rebuilt from the
- // conversation keeps no dispatch record that would catch the repeat.
+ // held. An earlier attempt that may itself have deleted this item still
+ // holds the deletion: this one could repeat it, and a run rebuilt from
+ // the conversation keeps no dispatch record that would catch the repeat.
+ // One that deleted another item, by its link or its row, does not; one
+ // whose item cannot be told apart from this one does.
const unreconciled = prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind);
- const earlierDeletion = archivedAttempts.some(receipt => receipt.mutationKind === 'delete');
+ const deletingLink = permalinked ? this._normalizeUrl(detected.actionResource.url) : '';
+ const deletingRow = record?.identity || '';
+ const mayRepeatThisDeletion = receipt => {
+ const link = receipt.actionResource?.complete && receipt.actionResource.url ? this._normalizeUrl(receipt.actionResource.url) : '';
+ const row = receipt.actionRecord?.identity || '';
+ if (link && deletingLink) return link === deletingLink;
+ if (row && deletingRow) return row === deletingRow;
+ return true;
+ };
+ const earlierDeletion = archivedAttempts.some(receipt => receipt.mutationKind === 'delete' && mayRepeatThisDeletion(receipt));
if (unreconciled && !(deletion && !earlierDeletion)) {
return blocked('prior_effect_unreconciled', publication && !crossPlatform
? 'The earlier post from before the latest correction has not been matched yet. Read it on this platform (its permalink or the account\'s recent posts), then retry; do not repeat an uncertain publication.'
diff --git a/test/guards-steering-receipts.mjs b/test/guards-steering-receipts.mjs
index 963cf8409..50c7ca270 100644
--- a/test/guards-steering-receipts.mjs
+++ b/test/guards-steering-receipts.mjs
@@ -1061,13 +1061,23 @@ for (const build of ['chrome', 'firefox']) {
assert.equal(h.decisions('deletion_request').length, 0, 'The repeat is not put to the deletion question');
assert.notEqual(h.steeringBlock(timelineDelete), null);
} finally { h.close(); }
- // A deletion archived at an earlier correction holds it the same way.
- const archived = await timelinePostThen('now delete it');
- try {
- archived.guard.steeringMutationReceipts = [...(archived.guard.steeringMutationReceipts || []),
- { dispatched: true, actionSequence: 2, mutationKind: 'delete', actionResource: { complete: true, url: timelinePost } }];
- assert.equal((await archived.check(timelineDelete))?.actionGuard?.reason, 'prior_effect_unreconciled');
- } finally { archived.close(); }
+ // A deletion archived at an earlier correction holds it the same way when
+ // it deleted this post, or an item that cannot be told apart from it; a
+ // deletion of another post does not.
+ for (const [earlier, held] of [
+ [{ actionResource: { complete: true, url: timelinePost } }, true],
+ [{}, true],
+ [{ actionResource: { complete: true, url: 'https://mastoturk.org/@webbrain_qa_owned/117440000000000009' } }, false],
+ ]) {
+ const archived = await timelinePostThen('now delete it');
+ try {
+ archived.guard.steeringMutationReceipts = [...(archived.guard.steeringMutationReceipts || []),
+ { dispatched: true, actionSequence: 2, mutationKind: 'delete', ...earlier }];
+ const result = await archived.check(timelineDelete);
+ if (held) assert.equal(result?.actionGuard?.reason, 'prior_effect_unreconciled', JSON.stringify(earlier));
+ else assert.equal(result?.mutationConfirmation?.kind, 'delete', `Another post's deletion does not hold this one: ${JSON.stringify(result)}`);
+ } finally { archived.close(); }
+ }
});
test(`${build}: after a correction an unidentified target says so; commits still need reconciliation`, async () => {