Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Let a deletion after a correction go to WebBrain's card instead of refusing it
Barack Sokullu555ce1e5d90d
diff --git a/docs/guards.md b/docs/guards.mdindex 50b7645df..58c26e7b3 100644--- a/docs/guards.md+++ b/docs/guards.md@@ -130,6 +130,15 @@ of `renderClarifyCard` in `ui/sidepanel.js`. Tests: `test/guard-ask-cards.mjs`.| `credentials` | `chat-user-input-required`, `otp-mailbox-scope`, `strict-secret-credential-handling` | One-time codes, passwords and payment details are the user's to enter. || `unrequested_publication` | `bot-memory-reservation`, `click-duplicate-submit`, `clickax-task-click-lock`, `consequential-durability-checkpoint`, `github-conditional-commit-unbound`, `recipient-guard-unrequested-send`, `sched-reconciliation-required`, `social-api-publication-route`, `social-publication-audit`, `social-publication-authorization-guard`, `steer-post-correction-commit-guard`, `steer-prior-submission-unreconciled` | A post, commit, submit or send the user did not ask for, or a second copy of one that may already have gone out, is public or hard to undo. |+After a correction, `steer-post-correction-commit-guard` and+`steer-prior-submission-unreconciled` hold a post, commit or submit until+WebBrain has matched what the attempt before the correction did. A deletion+is not held to that, because it cannot repeat that attempt: the latest+request, or the user on WebBrain's deletion card, decides which item goes. A+Mastodon post is one WebBrain cannot match after the fact (the home timeline+shows it, not a page of its own), and "now delete it" used to be refused on+every click there.+The `permission_gate`, `host_check`, `budget`, `infra` and `user_control`entries in the registry document checks that are not guards; they are listedthere so the registry covers every refusal.diff --git a/package.json b/package.jsonindex 31dfaae91..071830054 100644--- a/package.json+++ b/package.json@@ -64,7 +64,7 @@"benchmark:relevance": "node scripts/benchmark-offline-relevance.mjs --verbose","test:social-contract": "node --test test/social-publish-contract.mjs test/publication-quote-markup.mjs test/publication-prefetch.mjs","test:social-contract:dom": "node test/social-publish-contract-dom.mjs",- "test:runtime-lifecycle": "node test/bot-memory-dom.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/lifecycle-steering-restart.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/guard-policy.mjs test/lean-mode.mjs test/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/history-recovery.mjs test/history-recovery-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs && node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",+ "test:runtime-lifecycle": "node test/bot-memory-dom.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/guard-advisory-writes.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/lifecycle-steering-restart.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/clarify-timeout-policy.mjs test/guard-ask-cards.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/guard-advisory-completion.mjs test/guard-policy.mjs test/lean-mode.mjs test/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/history-recovery.mjs test/history-recovery-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs && node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs","test:page-feedback": "node --test test/trusted-field-preparation.mjs test/guard-advisory-writes.mjs test/draftjs-text.mjs test/codemirror-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/guard-advisory-actions.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/delivery-click-ax-response-loss.mjs test/delivery-stop-compound.mjs test/delivery-cdp-input.mjs test/delivery-click-locks.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs","test:history-recovery": "node --test test/history-recovery.mjs test/history-recovery-ui.mjs test/history-recovery-state.mjs test/history-recovery-scheduler.mjs test/history-recovery-atomic.mjs test/conversation-persistence.mjs","test:chat-steering": "node --test test/chat-steering.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs",@@ -102,7 +102,7 @@"test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs","test:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/integration-mv3.mjs --batch && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs","test:shard:browser-b2": "node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs --selector-recovery && node test/quality/upload-release-binding-mv3.mjs --sequential-assets && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/shared-action-guards-mv3.mjs && node test/quality/video-upload-attachment-mv3.mjs",- "test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs",+ "test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/mastodon-delete-after-correction-mv3.mjs && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs","test:shard:tail": "node test/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security","test:composer-context": "node --test test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs","test:bot-memory": "node --test test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs && node test/bot-memory-dom.mjs && node test/quality/cloud-bot-memory-mv3.mjs",diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 5744fffce..03d2fb922 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -6628,7 +6628,11 @@ export class Agent extends LoopDetector {if (guard.resourceMutationAuthorization?.key === this._resourceMutationActionKey(tabId, name, args, detectedSubmit)&& guard.resourceMutationAuthorization.taskKey === guard.taskKey&& guard.taskKey === this._progressTaskKeyHash(tabId) && !this._checkAbort(tabId) && !this._hasPendingSteering(tabId)- && guard.steeringPriorSubmissionReconciliation?.verified === true) return null;+ // A deletion that the latest request or the user's answer on+ // WebBrain's card bound to this exact item cannot repeat the earlier+ // submission; any other action needs that submission reconciled.+ && (guard.steeringPriorSubmissionReconciliation?.verified === true+ || (guard.resourceMutationAuthorization.deletion === true && detectedSubmit?.mutationKind === 'delete'))) return null;// An unidentified target says nothing about the earlier effect; report// what is actually missing instead of an unreconciled submission.const unresolvedTarget = detectedSubmit?.isSubmit !== true && !isNetworkMutation(name, args) && name !== 'chrome_web_store_publish';@@ -7368,7 +7372,14 @@ export class Agent extends LoopDetector {} else if (formCommit && priorForm && priorForm === detected.actionUrl && inPlace&& this._steeringPriorEffectObserved(tabId, prior)) observedKind = 'form_observation';}- if (prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind)) {+ // A deletion cannot repeat the earlier submission or sit beside it, so an+ // earlier result WebBrain cannot match does not hold it back: a Mastodon+ // post, for one, sits on a timeline that WebBrain does not match 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.+ const unreconciled = prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind);+ if (unreconciled && !deletion) {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.': publication && siteCrossPlatform && prior.mutationKind !== 'delete'@@ -7377,12 +7388,12 @@ export class Agent extends LoopDetector {? `The earlier submission from before the latest correction${priorHost ? `, on ${priorHost},` : ''} has not been observed yet: no page was read since it was sent. Read the current page, then retry; nothing about it needs to be found here, and do not repeat it.`: 'The earlier submission from before the latest correction has not been observed yet. Read the page that shows its result, then retry; do not repeat an uncertain mutation.');}- if (matching.length === 1 || deletedVerifiedResource) {+ if (!unreconciled && (matching.length === 1 || deletedVerifiedResource)) {guard.steeringPriorSubmissionReconciliation = { verified: true, verificationKind: 'resource_identity', taskKey: guard.taskKey,actionSequence: prior.actionSequence, resourceUrl: matching[0]?.url || reconciled.resourceUrl,resourceScopeToken: matching[0]?.scopeToken || reconciled?.resourceScopeToken || '',deleted: deletedVerifiedResource, document: fresh.frameDocumentIdentity };- } else if (!(reconciled?.verified === true && reconciled.actionSequence === prior.actionSequence)) {+ } else if (!unreconciled && !(reconciled?.verified === true && reconciled.actionSequence === prior.actionSequence)) {// Outcome knowledge without resource identity; never a resource URL// that a later deletion could treat as verified.guard.steeringPriorSubmissionReconciliation = { verified: true, verificationKind: observedKind, taskKey: guard.taskKey,@@ -7425,7 +7436,7 @@ export class Agent extends LoopDetector {return blocked('deletion_declined', 'The user chose not to delete this item, so it was not deleted. Do not try to delete it again; continue with the rest of the task and report that it was not deleted.', { retryable: false });}if (decision?.approved === true) {- guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey };+ guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey, deletion: true };return null;}if (guard.resourceMutationAuthorization?.key === key && guard.resourceMutationAuthorization.taskKey === guard.taskKey) return null;@@ -7461,7 +7472,7 @@ export class Agent extends LoopDetector {}const final = await this._detectLikelySubmitAction(tabId, name, args, { mutationReconciliation: true });if (!current() || this._resourceMutationActionKey(tabId, name, args, final) !== key) return blocked('resource_changed_after_authorization');- guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey };+ guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey, deletion: true };return null;}if (guard.resourceMutationAuthorization?.key === key && guard.resourceMutationAuthorization.taskKey === guard.taskKey) return null;diff --git a/src/chrome/src/agent/guard-policy.js b/src/chrome/src/agent/guard-policy.jsindex 0b17e4ffd..c6e939d09 100644--- a/src/chrome/src/agent/guard-policy.js+++ b/src/chrome/src/agent/guard-policy.js@@ -253,7 +253,7 @@ export const GUARDS = Object.freeze({"steer-prior-submission-target-unresolved": { class: "quality", family: "predispatch", decides: "no-evidence", onDecided: "advise", onCannotDecide: "ask",summary: "After a correction with an earlier dispatched submission, a submit-capable call whose target the probe could not resolve as a link, field, menu item or ordinary button is refused." },"steer-prior-submission-unreconciled": { class: "unrequested_publication", family: "predispatch", decides: "no-evidence", onDecided: "block", onCannotDecide: "ask",- summary: "_steeringPriorSubmissionBlock: after a correction, any network mutation, chrome_web_store_publish or committing submit is refused until the earlier submission is reconciled (or this exact action was authorized and reconciled by _resourceMutationPreSubmitBlock)." },+ summary: "_steeringPriorSubmissionBlock: after a correction, any network mutation, chrome_web_store_publish or committing submit is refused until the earlier submission is reconciled, unless _resourceMutationPreSubmitBlock authorized this exact action: reconciled with it, or a deletion that the latest request or the user's card bound to its item." },"steering-and-page-feedback-call-fence": { class: "host_check", family: "predispatch", decides: "mixed", onDecided: "block", onCannotDecide: "block",summary: "A user correction is pending, or page-monitor feedback (user input/intervention, unknown attribution, non-passive churn, stale scroll/model state) arrived after the model observation: the stale call (Act done and Ask answers included) and the rest of the batch are skipped and a fresh observation is…" },"submit-confirmation-card": { class: "permission_gate", family: "predispatch", decides: "knows", onDecided: "block", onCannotDecide: "block",diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 5b77e5a49..36d70f662 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -6174,7 +6174,11 @@ export class Agent extends LoopDetector {if (guard.resourceMutationAuthorization?.key === this._resourceMutationActionKey(tabId, name, args, detectedSubmit)&& guard.resourceMutationAuthorization.taskKey === guard.taskKey&& guard.taskKey === this._progressTaskKeyHash(tabId) && !this._checkAbort(tabId) && !this._hasPendingSteering(tabId)- && guard.steeringPriorSubmissionReconciliation?.verified === true) return null;+ // A deletion that the latest request or the user's answer on+ // WebBrain's card bound to this exact item cannot repeat the earlier+ // submission; any other action needs that submission reconciled.+ && (guard.steeringPriorSubmissionReconciliation?.verified === true+ || (guard.resourceMutationAuthorization.deletion === true && detectedSubmit?.mutationKind === 'delete'))) return null;// An unidentified target says nothing about the earlier effect; report// what is actually missing instead of an unreconciled submission.const unresolvedTarget = detectedSubmit?.isSubmit !== true && !isNetworkMutation(name, args) && name !== 'chrome_web_store_publish';@@ -6914,7 +6918,14 @@ export class Agent extends LoopDetector {} else if (formCommit && priorForm && priorForm === detected.actionUrl && inPlace&& this._steeringPriorEffectObserved(tabId, prior)) observedKind = 'form_observation';}- if (prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind)) {+ // A deletion cannot repeat the earlier submission or sit beside it, so an+ // earlier result WebBrain cannot match does not hold it back: a Mastodon+ // post, for one, sits on a timeline that WebBrain does not match 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.+ const unreconciled = prior.dispatched !== true || (matching.length !== 1 && !deletedVerifiedResource && !observedKind);+ if (unreconciled && !deletion) {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.': publication && siteCrossPlatform && prior.mutationKind !== 'delete'@@ -6923,12 +6934,12 @@ export class Agent extends LoopDetector {? `The earlier submission from before the latest correction${priorHost ? `, on ${priorHost},` : ''} has not been observed yet: no page was read since it was sent. Read the current page, then retry; nothing about it needs to be found here, and do not repeat it.`: 'The earlier submission from before the latest correction has not been observed yet. Read the page that shows its result, then retry; do not repeat an uncertain mutation.');}- if (matching.length === 1 || deletedVerifiedResource) {+ if (!unreconciled && (matching.length === 1 || deletedVerifiedResource)) {guard.steeringPriorSubmissionReconciliation = { verified: true, verificationKind: 'resource_identity', taskKey: guard.taskKey,actionSequence: prior.actionSequence, resourceUrl: matching[0]?.url || reconciled.resourceUrl,resourceScopeToken: matching[0]?.scopeToken || reconciled?.resourceScopeToken || '',deleted: deletedVerifiedResource, document: fresh.frameDocumentIdentity };- } else if (!(reconciled?.verified === true && reconciled.actionSequence === prior.actionSequence)) {+ } else if (!unreconciled && !(reconciled?.verified === true && reconciled.actionSequence === prior.actionSequence)) {// Outcome knowledge without resource identity; never a resource URL// that a later deletion could treat as verified.guard.steeringPriorSubmissionReconciliation = { verified: true, verificationKind: observedKind, taskKey: guard.taskKey,@@ -6971,7 +6982,7 @@ export class Agent extends LoopDetector {return blocked('deletion_declined', 'The user chose not to delete this item, so it was not deleted. Do not try to delete it again; continue with the rest of the task and report that it was not deleted.', { retryable: false });}if (decision?.approved === true) {- guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey };+ guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey, deletion: true };return null;}if (guard.resourceMutationAuthorization?.key === key && guard.resourceMutationAuthorization.taskKey === guard.taskKey) return null;@@ -7007,7 +7018,7 @@ export class Agent extends LoopDetector {}const final = await this._detectLikelySubmitAction(tabId, name, args, { mutationReconciliation: true });if (!current() || this._resourceMutationActionKey(tabId, name, args, final) !== key) return blocked('resource_changed_after_authorization');- guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey };+ guard.resourceMutationAuthorization = { key, taskKey: guard.taskKey, deletion: true };return null;}if (guard.resourceMutationAuthorization?.key === key && guard.resourceMutationAuthorization.taskKey === guard.taskKey) return null;diff --git a/src/firefox/src/agent/guard-policy.js b/src/firefox/src/agent/guard-policy.jsindex 0b17e4ffd..c6e939d09 100644--- a/src/firefox/src/agent/guard-policy.js+++ b/src/firefox/src/agent/guard-policy.js@@ -253,7 +253,7 @@ export const GUARDS = Object.freeze({"steer-prior-submission-target-unresolved": { class: "quality", family: "predispatch", decides: "no-evidence", onDecided: "advise", onCannotDecide: "ask",summary: "After a correction with an earlier dispatched submission, a submit-capable call whose target the probe could not resolve as a link, field, menu item or ordinary button is refused." },"steer-prior-submission-unreconciled": { class: "unrequested_publication", family: "predispatch", decides: "no-evidence", onDecided: "block", onCannotDecide: "ask",- summary: "_steeringPriorSubmissionBlock: after a correction, any network mutation, chrome_web_store_publish or committing submit is refused until the earlier submission is reconciled (or this exact action was authorized and reconciled by _resourceMutationPreSubmitBlock)." },+ summary: "_steeringPriorSubmissionBlock: after a correction, any network mutation, chrome_web_store_publish or committing submit is refused until the earlier submission is reconciled, unless _resourceMutationPreSubmitBlock authorized this exact action: reconciled with it, or a deletion that the latest request or the user's card bound to its item." },"steering-and-page-feedback-call-fence": { class: "host_check", family: "predispatch", decides: "mixed", onDecided: "block", onCannotDecide: "block",summary: "A user correction is pending, or page-monitor feedback (user input/intervention, unknown attribution, non-passive churn, stale scroll/model state) arrived after the model observation: the stale call (Act done and Ask answers included) and the rest of the batch are skipped and a fresh observation is…" },"submit-confirmation-card": { class: "permission_gate", family: "predispatch", decides: "knows", onDecided: "block", onCannotDecide: "block",diff --git a/test/guards-steering-receipts.mjs b/test/guards-steering-receipts.mjsindex ed9cbba82..b4b438d73 100644--- a/test/guards-steering-receipts.mjs+++ b/test/guards-steering-receipts.mjs@@ -979,6 +979,73 @@ for (const build of ['chrome', 'firefox']) {}});+ // Your trace: a post on MastoTurk, then "now delete it". Mastodon shows the+ // post on the home timeline, which WebBrain does not match to the form it+ // was sent from, so the earlier result stays unmatched. Its deletion is not+ // refused for that on every click: WebBrain asks on its own card, and that+ // answer lets this one deletion through the correction check.+ const timelineHome = 'https://mastoturk.org/home', timelineCompose = 'https://mastoturk.org/publish';+ const timelinePost = 'https://mastoturk.org/@webbrain_qa_owned/117450000000000001';+ const timelineSubmit = text => ({ isSubmit: true, validationSubmitEvidence: 'strong', url: timelineCompose, actionUrl: timelineCompose,+ method: 'GET', frameDocumentIdentity: 'compose-doc', fields: [{ label: 'Aklında ne var?', type: 'textarea', value: text, changed: true }] });+ // The post's own "Sil", which the Mastodon reader ties to the post; no+ // page scan of the timeline comes with it.+ const timelineDelete = { isSubmit: false, mutationKind: 'delete', frameDocumentIdentity: 'home-doc',+ actionResource: { complete: true, nativeAdapter: 'mastodon', account: 'https://mastoturk.org/@webbrain_qa_owned',+ scopeToken: 'owned-post-scope', url: timelinePost, textValues: ['WebBrain test gönderisi'] } };+ async function timelinePostThen(correction) {+ const h = await fixture('go to mastoturk.org and try to post something', { pageUrl: timelineHome });+ h.agent._recordCompletionSubmitAttempt(h.tab, timelineSubmit('WebBrain test gönderisi'), 'click_ax', { ref_id: 'ref_4' },+ timelineCompose, timelineHome, { success: true, dispatched: true, verified: true }, 'compose-doc', 'home-doc');+ h.agent._completionSubmitStates.set(h.tab, { ...h.agent._completionSubmitStates.get(h.tab),+ observedAfterSubmit: true, completionSignalObserved: true, currentUrl: timelineHome });+ h.guard = await h.steer(correction);+ h.read(timelineHome);+ return h;+ }++ test(`${build}: after a correction, deleting the earlier post goes to WebBrain's card even when that post cannot be matched`, async () => {+ const h = await timelinePostThen('now delete it');+ try {+ const block = await h.check(timelineDelete);+ assert.notEqual(block?.actionGuard?.reason, 'prior_effect_unreconciled', JSON.stringify(block));+ assert.equal(block?.mutationConfirmation?.kind, 'delete', JSON.stringify(block));+ assert.equal(block.mutationConfirmation.url, timelinePost, 'The card shows the post the menu belongs to');+ const cards = [];+ const result = await h.agent._resolveMutationConfirmation(h.tab, block, (status, details) => {+ if (status !== 'clarify') return;+ cards.push(details);+ h.agent._settleClarification(h.agent._pendingClarifications.get(h.tab).get(details.clarifyId), { answer: 'once', source: 'option' });+ }, () => h.check(timelineDelete));+ assert.equal(result, null, JSON.stringify(result));+ assert.equal(cards.length, 1);+ assert.equal(h.steeringBlock(timelineDelete), null, 'The answer lets this one deletion through the correction check');+ // The earlier post is still unmatched: nothing else goes ahead on its account.+ assert.notEqual(h.guard.steeringPriorSubmissionReconciliation?.verified, true);+ const another = timelineSubmit('Another test post');+ assert.equal((await h.check(another))?.actionGuard?.reason, 'prior_effect_unreconciled');+ assert.equal(h.steeringBlock(another)?.actionGuard?.reason, 'prior_effect_unreconciled');+ } finally { h.close(); }+ });++ test(`${build}: after a correction that names the earlier post, it is deleted without a card; a declined card holds it`, async () => {+ const named = await timelinePostThen(`delete ${timelinePost}`);+ try {+ assert.equal(await named.check(timelineDelete), null, 'The latest request binds this post');+ assert.equal(named.steeringBlock(timelineDelete), null);+ } finally { named.close(); }+ const declined = await timelinePostThen('now delete it');+ try {+ const block = await declined.check(timelineDelete);+ const result = await declined.agent._resolveMutationConfirmation(declined.tab, block, (status, details) => {+ if (status === 'clarify') declined.agent._settleClarification(declined.agent._pendingClarifications.get(declined.tab).get(details.clarifyId), { answer: 'deny', source: 'option' });+ }, () => declined.check(timelineDelete));+ assert.equal(result?.actionGuard?.reason, 'deletion_declined');+ assert.equal((await declined.check(timelineDelete))?.actionGuard?.reason, 'deletion_declined');+ assert.notEqual(declined.steeringBlock(timelineDelete), null, 'Without the user\'s answer the correction check still holds it');+ } finally { declined.close(); }+ });+test(`${build}: after a correction an unidentified target says so; commits still need reconciliation`, async () => {const h = await fixture('Save the owned profile name as Original.');try {diff --git a/test/guards-unbound-deletion.mjs b/test/guards-unbound-deletion.mjsindex 1a2678af1..da1efcf5c 100644--- a/test/guards-unbound-deletion.mjs+++ b/test/guards-unbound-deletion.mjs@@ -432,14 +432,23 @@ for (const build of ['chrome', 'firefox']) {assert.equal(steered.guard.resourceMutationAuthorization, undefined);});- test(`${build}: an unreconciled earlier submission after a correction still blocks first`, async () => {+ // A deletion cannot repeat the earlier submission or sit beside it, so an+ // earlier submission WebBrain has not matched does not hold it: the row is+ // bound to the latest request as any deletion is. The earlier submission is+ // still unmatched, so a form commit stays held.+ test(`${build}: an unreconciled earlier submission after a correction does not hold a deletion the request names`, async () => {const f = fixture('Remove the Wool socks from my cart.');f.guard.steeringPriorSubmission = { dispatched: true, actionSequence: 3, mutationKind: 'submit', observedAfterSubmit: false,submittedActionUrl: 'https://shop.example/checkout', submittedFields: [{ label: 'Coupon', type: 'text', value: 'SAVE10' }],originatingUrl: pageUrl, currentUrl: pageUrl };- assert.equal(reason(await f.check()), 'prior_effect_unreconciled');- assert.equal(f.calls.length, 0);- assert.notEqual(f.agent._steeringPriorSubmissionBlock(f.tab, 'click_ax', f.args, f.detected), null);+ assert.equal(await f.check(), null);+ assert.equal(decisions(f).length, 1, 'The row is bound to the request as any deletion is');+ assert.equal(f.agent._steeringPriorSubmissionBlock(f.tab, 'click_ax', f.args, f.detected), null);+ assert.notEqual(f.guard.steeringPriorSubmissionReconciliation?.verified, true);+ const coupon = { isSubmit: true, validationSubmitEvidence: 'strong', url: pageUrl, actionUrl: 'https://shop.example/checkout',+ method: 'POST', frameDocumentIdentity: documentIdentity, fields: [{ label: 'Coupon', type: 'text', value: 'SAVE20' }] };+ assert.equal(f.agent._steeringPriorSubmissionBlock(f.tab, 'click_ax', { ref_id: 'ref_43' }, coupon)?.actionGuard?.reason,+ 'prior_effect_unreconciled', 'A form commit is still held to the earlier submission');});}diff --git a/test/quality/mastodon-delete-after-correction-mv3.mjs b/test/quality/mastodon-delete-after-correction-mv3.mjsnew file mode 100644index 000000000..8a732444c--- /dev/null+++ b/test/quality/mastodon-delete-after-correction-mv3.mjs@@ -0,0 +1,311 @@+// Your trace: on MastoTurk WebBrain posted something, then "now delete it"+// came in as a correction. Every click on the post's "Sil" was refused as+// prior_effect_unreconciled ("the earlier submission ... has not been observed+// yet"), with the post right there on the timeline: Mastodon shows it on the+// home timeline, not at an address of its own, so WebBrain never matched it to+// the form it was sent from, and no card was offered that could have let the+// person's yes count. Here the deletion goes to WebBrain's own card once, and+// that answer also covers Mastodon's confirmation: exactly the new post is+// deleted, once. The extension, provider pipeline, dispatch and gates are+// real; the pages, posts and model are owned local fixtures.+import assert from 'node:assert/strict';+import fs from 'node:fs/promises';+import http from 'node:http';+import os from 'node:os';+import path from 'node:path';+import { chromium } from 'playwright';+import { conformFixtureCompletionCall } from './completion-provider-contract.mjs';+import { defaultDecide, fixedChoiceQuestion, fixtureFixedChoiceReply, fixturePageTextReply } from '../semantic-decision-stub.mjs';++const out = path.resolve(process.env.WEBBRAIN_QUALITY_ARTIFACTS || 'ci/artifacts/quality-audit-2026-10-18/mastodon-delete-after-correction-mv3');+await fs.mkdir(out, { recursive: true });+const request = 'go to mastoturk.org and try to post something';+const correction = 'now delete it';+// A refused click is tried again, as the model in the trace did.+const retries = 2;+const account = 'webbrain_qa_owned';+const body = 'WebBrain test gönderisi';++const textOf = content => typeof content === 'string' ? content : Array.isArray(content)+ ? content.filter(part => part?.type === 'text').map(part => part.text || '').join('\n') : '';+function objectFrom(content) {+ const text = textOf(content);+ for (let start = text.indexOf('{'); start >= 0; start = text.indexOf('{', start + 1)) {+ let depth = 0, quoted = false, escaped = false;+ for (let index = start; index < text.length; index++) {+ const character = text[index];+ if (quoted) { if (escaped) escaped = false; else if (character === '\\') escaped = true; else if (character === '"') quoted = false; }+ else if (character === '"') quoted = true;+ else if (character === '{') depth++;+ else if (character === '}' && --depth === 0) {+ try { return JSON.parse(text.slice(start, index + 1)); } catch { break; }+ }+ }+ }+ return null;+}+const toolMessages = messages => {+ const names = new Map((messages || []).flatMap(message => (message.tool_calls || []).map(call => [call.id, call.function?.name])));+ return (messages || []).filter(message => message.role === 'tool')+ .map(message => ({ id: message.tool_call_id, name: names.get(message.tool_call_id), result: objectFrom(message.content) }));+};+const refFrom = (tree, pattern) => String(tree?.result?.pageContent || '').split('\n').find(line => pattern.test(line))?.match(/\[(ref_\d+)\]/)?.[1];++// Mastodon 4.4 markup (from the delete-confirmation fixture), newest first.+// On the timeline now, and every post the fixture accepted.+const posts = [], created = [];+const statusId = index => String(117450000000000000n + BigInt(index));+const post = (id, text, author = account) => `<article data-id="${id}"><div class="status__wrapper status__wrapper-public focusable" tabindex="0" aria-label="QA, ${text}, 18 Eki 07:30, ${author}">+<div class="status status-public"><div class="status__info"><a href="/@${author}/${id}" class="status__relative-time"><time>1m</time></a>+<a href="/@${author}" title="${author}" class="status__display-name"><span class="display-name"><bdi><strong class="display-name__html">QA</strong></bdi> <span class="display-name__account">@${author}</span></span></a></div>+<div class="status__content"><div class="status__content__text status__content__text--visible translate" lang="tr"><p>${text}</p></div></div>+<div class="status__action-bar"><div class="status__action-bar__button-wrapper"><button type="button" aria-label="Yanıtla" title="Yanıtla" class="status__action-bar__button icon-button"><svg class="icon icon-reply" aria-hidden="true"></svg></button></div>+<div class="status__action-bar__button-wrapper"><button type="button" aria-label="Daha fazla" aria-expanded="false" title="Daha fazla" class="status__action-bar__button icon-button"><svg class="icon icon-ellipsis-h" aria-hidden="true"></svg></button></div></div></div></div></article>`;+const menu = '<div class="dropdown-animation dropdown-menu bottom"><div class="dropdown-menu__arrow bottom"></div><div class="dropdown-menu__container"><ul class="dropdown-menu__container__list">'+ + '<li class="dropdown-menu__item"><button data-index="0">Bu gönderiyi genişlet</button></li><li class="dropdown-menu__item"><button data-index="1">Gönderi bağlantısını kopyala</button></li>'+ + '<li class="dropdown-menu__separator"></li><li class="dropdown-menu__item"><button data-index="3">Düzenle</button></li>'+ + '<li class="dropdown-menu__item dropdown-menu__item--dangerous"><button data-index="4">Sil</button></li>'+ + '<li class="dropdown-menu__item dropdown-menu__item--dangerous"><button data-index="5">Sil, Düzenle ve yeniden-paylaş</button></li></ul></div></div>';+const confirmation = '<div style="pointer-events:auto"><div role="presentation" class="modal-root__overlay"></div><div role="dialog" class="modal-root__container">'+ + '<div class="modal-root__modal safety-action-modal"><div class="safety-action-modal__top"><div class="safety-action-modal__confirmation"><h1>Gönderiyi sil?</h1><p>Bu gönderiyi silmek istediğinden emin misin?</p></div></div>'+ + '<div class="safety-action-modal__bottom"><div class="safety-action-modal__actions"><button class="link-button">İptal</button><button type="button" class="button">Sil</button></div></div></div></div></div>';+const homeBody = () => `<!doctype html><meta charset="utf-8"><title>Anasayfa - MastoTurk</title>+<script id="initial-state" type="application/json">${JSON.stringify({ meta: { me: '1', delete_modal: true },+ accounts: { 1: { id: '1', username: account, acct: account, url: `https://mastoturk.org/@${account}` } } })}</script>+<style>body{margin:0;font:15px sans-serif}button{padding:8px}.columns-area__panels{display:flex}.columns-area__panels__main{width:600px}.navigation-panel{width:300px;padding:8px}+.modal-root__overlay{position:fixed;inset:0;background:rgba(0,0,0,.4)}.modal-root__container{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}+.safety-action-modal{position:relative;background:#fff;padding:20px}.dropdown-menu{background:#fff;border:1px solid #888}svg{width:12px;height:12px;display:inline-block}</style>+<div class="app-holder" id="mastodon"><div class="ui"><div class="columns-area__panels"><div class="columns-area__panels__main"><div class="column" role="region" aria-label="Anasayfa"><div role="feed" class="item-list" id="feed">+${[...posts].reverse().map(item => post(item.id, item.text)).join('')}${post('117442625347497184', 'Another owned QA post')}${post('117439945096942320', 'Someone else', 'otherqa')}+</div></div></div><div class="columns-area__panels__pane columns-area__panels__pane--start columns-area__panels__pane--navigational"><div class="columns-area__panels__pane__inner"><div class="navigation-panel">+<div class="navigation-bar"><div class="account account--minimal"><div class="account__wrapper"><div class="account__info-wrapper"><a class="account__display-name" title="${account}" href="/@${account}"><span class="display-name__account">@${account}</span></a></div></div></div></div>+<div class="navigation-panel__menu"><a class="button navigation-panel__compose-button column-link" href="/publish">Yeni Gönderi</a><a class="column-link" href="/home">Anasayfa</a></div></div></div></div>+</div><div class="modal-root"></div></div></div>+<script>+const ui = document.querySelector('.ui'), modalRoot = document.querySelector('.modal-root');+const background = inert => { for (const sibling of ui.children) if (sibling !== modalRoot) inert ? sibling.setAttribute('inert', '') : sibling.removeAttribute('inert'); };+const closeModal = () => { modalRoot.replaceChildren(); background(false); };+for (const more of document.querySelectorAll('.status__action-bar button[aria-label="Daha fazla"]')) more.onclick = () => {+ if (document.querySelector('#post-menu')) return;+ const id = more.closest('article').dataset.id, holder = document.createElement('div');+ holder.id = 'post-menu'; holder.style.cssText = 'position:absolute;left:560px;top:' + (more.getBoundingClientRect().bottom + 4) + 'px;z-index:5';+ holder.innerHTML = ${JSON.stringify(menu)};+ more.setAttribute('aria-expanded', 'true'); more.setAttribute('aria-controls', 'post-menu');+ document.body.append(holder);+ const closeMenu = () => { holder.remove(); more.setAttribute('aria-expanded', 'false'); };+ for (const item of holder.querySelectorAll('button[data-index]')) item.onclick = () => {+ closeMenu();+ if (item.dataset.index !== '4') return;+ setTimeout(() => {+ modalRoot.innerHTML = ${JSON.stringify(confirmation)}; background(true);+ modalRoot.querySelector('.link-button').onclick = closeModal;+ modalRoot.querySelector('.button').onclick = async () => {+ const result = await fetch('/api/v1/statuses/' + id, { method: 'DELETE' });+ if (result.ok) { document.querySelector('article[data-id="' + id + '"]').remove(); closeModal(); }+ };+ }, 60);+ };+};+</script>`;+const composeBody = `<!doctype html><meta charset="utf-8"><title>Yeni gönderi - MastoTurk</title>+<style>body{font:16px sans-serif;margin:24px} textarea{width:500px;height:120px} button{padding:10px 18px}</style>+<form class="compose-form"><div class="navigation-bar"><a class="account__display-name" href="/@${account}">@${account}</a></div>+<textarea class="autosuggest-textarea__textarea" aria-label="Aklında ne var?" placeholder="Aklında ne var?"></textarea>+<div class="compose-form__submit"><button type="submit">Gönder</button></div></form>+<script>+document.querySelector('form.compose-form').addEventListener('submit', async event => {+ event.preventDefault();+ const response = await fetch('/api/v1/statuses', { method: 'POST', headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ status: document.querySelector('textarea').value, visibility: 'public' }) });+ if (response.ok) location.href = '/home';+});+</script>`;++// The model.+let steered = false, judgeCalls = 0, blockedRemote = 0;+const deletes = [], unknownPrompts = [], cards = [], decisions = [];+const phase = { name: 'before', index: 0, lastId: null, emitted: 0, attempts: 0 };+const completionRecovery = { reads: 0 };+const blockedResult = result => result && (result.blocked === true || result.denied === true || result.success === false);+const before = [+ () => ({ name: 'navigate', args: { url: 'https://mastoturk.org/publish' } }),+ () => ({ name: 'get_accessibility_tree', args: { filter: 'all' } }),+ tree => ({ name: 'set_field', args: { ref_id: refFrom(tree, /textbox "Aklında ne var\?"/), text: body } }),+ tree => ({ name: 'click_ax', args: { ref_id: refFrom(tree, /button "Gönder"/) } }),+ async (_tree, run) => { await run.steer(); return { name: 'get_accessibility_tree', args: { filter: 'all' } }; },+ () => ({ name: 'done', args: { outcome: 'success', summary: 'Posted a test message on mastoturk.org.' } }),+];+const after = [+ () => ({ name: 'get_accessibility_tree', args: { filter: 'all' } }),+ tree => ({ name: 'click_ax', args: { ref_id: refFrom(tree, /button "Daha fazla"/) }, consequential: true }),+ () => ({ name: 'get_accessibility_tree', args: { filter: 'all' } }),+ tree => ({ name: 'click_ax', args: { ref_id: refFrom(tree, /button "Sil"$/) || refFrom(tree, /button "Sil"/) }, consequential: true }),+ () => ({ name: 'get_accessibility_tree', args: { filter: 'all' } }),+ tree => ({ name: 'click_ax', args: { ref_id: refFrom(tree, /button "Sil"/) }, consequential: true }),+ () => ({ name: 'get_accessibility_tree', args: { filter: 'all' } }),+ () => ({ name: 'done', args: { outcome: 'success', summary: 'Deleted the test post.' } }),+];+const intent = () => ({ request_kind: 'execute', scope_relation: steered ? 'revision' : 'new', requires_state_change: true,+ requires_submission: true, messaging: null, deliverables: [steered ? 'The test post is deleted' : 'A post on mastoturk.org'],+ completion_requirements: { download: false }, allows_planner_shaped_result: false, allows_app_state_tool_evidence: false,+ read_scope: 'visible_page', summary: steered ? 'Delete the post just published.' : 'Post something on mastoturk.org.',+ steps: [{ id: '1', action: steered ? 'Delete the post that was just published and verify it is gone.' : 'Compose and publish a post, then verify it.' }],+ memory: { use_progress_ledger: false, progress_action: null }, scheduling: null, risks: [] });++let context, page, panel, tabId = null, worker;+const run = {+ async steer() {+ for (let wait = 0; !posts.length && wait < 50; wait++) await new Promise(resolve => setTimeout(resolve, 100));+ assert.equal(posts.length, 1, 'The Mastodon post was sent before the correction');+ const accepted = await panel.evaluate(({ tabId, text }) => chrome.runtime.sendMessage({ target: 'background', action: 'chat_steer',+ tabId, requestId: 'owned-delete-after-correction', messageId: 'owned-now-delete-it', text }), { tabId, text: correction });+ assert.equal(accepted?.accepted, true, JSON.stringify(accepted));+ steered = true;+ },+};+const server = http.createServer(async (incoming, response) => {+ if (incoming.url !== '/v1/chat/completions') { response.writeHead(404).end(); return; }+ let raw = ''; for await (const part of incoming) raw += part;+ const input = JSON.parse(raw), system = textOf(input.messages?.[0]?.content);+ let completion;+ try {+ if (system.startsWith('Extract stable user preferences')) completion = { role: 'assistant', content: '{"memories":[]}' };+ else if (system === 'Hi' || textOf(input.messages?.at(-1)?.content) === 'Hi') completion = { role: 'assistant', content: 'Hello' };+ else if (system.startsWith('Identify only the exact plain public Mastodon post')) completion = { role: 'assistant',+ content: JSON.stringify({ kind: 'unsupported', body: null, account: null }) };+ else if (system.startsWith("Compile the user's social-publication intent")) completion = { role: 'assistant',+ content: JSON.stringify({ version: 1, status: 'none', actions: [], requirements: null, prohibited: [], reason: 'No X or Bluesky publication is requested.' }) };+ else if (fixturePageTextReply(input.messages)) completion = { role: 'assistant', content: fixturePageTextReply(input.messages) };+ else if (fixedChoiceQuestion(input.messages)) {+ const question = fixedChoiceQuestion(input.messages);+ if (['deletion_request', 'deletion_prerequisite'].includes(question.kind)) decisions.push({ kind: question.kind, request: question.request, page: question.page });+ completion = { role: 'assistant', content: /^- "mode_claim":/m.test(system) ? JSON.stringify({ choice: 'result', evidence: '' })+ : fixtureFixedChoiceReply(input.messages, {+ deletion_request: ({ request, page }) => defaultDecide('deletion_request', { request, page }),+ deletion_prerequisite: ({ request, page }) => defaultDecide('deletion_prerequisite', { request, page }),+ user_turn_kind: 'continue' }) };+ } else if (system.startsWith('Check one separately proposed consequential action')) {+ const trusted = JSON.parse(textOf(input.messages[1].content)), proposed = objectFrom(input.messages[2].content);+ completion = { role: 'assistant', content: JSON.stringify({ key: proposed.key, authorized: true, latestRequestEvidence: trusted.latestAcceptedRequest }) };+ } else if (system.startsWith('Independently check whether the authentic user request authorizes')) {+ const audit = JSON.parse(textOf(input.messages.find(message => message.role === 'user')?.content));+ completion = { role: 'assistant', content: JSON.stringify({ key: audit.key, actionId: audit.action.id, authorized: true, reason: 'Requested.' }) };+ } else if (system.startsWith('Evaluate only the observable requirements')) {+ judgeCalls++;+ completion = { role: 'assistant', content: JSON.stringify({ outcome: 'succeeded', reason: 'The page shows the expected result.' }) };+ } else if (!input.tools?.length) {+ if (!system.startsWith('You are the intent and compact planning subsystem') && !system.startsWith('You are the planning subsystem')) unknownPrompts.push(system.slice(0, 160));+ completion = { role: 'assistant', content: JSON.stringify(intent()) };+ } else {+ const tools = toolMessages(input.messages);+ if (steered && phase.name === 'before' && JSON.stringify(input.messages).includes(correction)) Object.assign(phase, { name: 'after', index: 0, lastId: null, attempts: 0 });+ else if (phase.lastId && tools.some(tool => tool.id === phase.lastId)) {+ const last = tools.find(tool => tool.id === phase.lastId);+ const steps = phase.name === 'before' ? before : after;+ const wasConsequential = phase.name === 'after' && [1, 3, 5].includes(phase.index);+ // A refused consequential click is tried again, as a model would.+ if (wasConsequential && blockedResult(last?.result) && phase.attempts < retries) phase.attempts++;+ else { phase.index = Math.min(phase.index + 1, steps.length - 1); phase.attempts = 0; }+ }+ const steps = phase.name === 'before' ? before : after;+ const tree = tools.findLast(tool => tool.name === 'get_accessibility_tree' && tool.result?.pageContent);+ const step = await steps[phase.index](tree, run);+ const call = conformFixtureCompletionCall(input, { name: step.name, args: step.args }, completionRecovery);+ phase.lastId = `owned-${phase.name}-${phase.index}-${++phase.emitted}`;+ completion = { role: 'assistant', content: '', tool_calls: [{ id: phase.lastId, type: 'function',+ function: { name: call.name, arguments: JSON.stringify(call.args) } }] };+ }+ } catch (error) {+ unknownPrompts.push(`provider error: ${error.stack || error.message}`);+ response.writeHead(500, { 'Content-Type': 'application/json' }); response.end(JSON.stringify({ error: error.message })); return;+ }+ response.writeHead(200, { 'Content-Type': 'application/json' });+ response.end(JSON.stringify({ id: `response-${phase.emitted}`, choices: [{ message: completion,+ finish_reason: completion.tool_calls ? 'tool_calls' : 'stop' }], usage: { prompt_tokens: 100, completion_tokens: 30 } }));+});+await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));+const base = `http://127.0.0.1:${server.address().port}`;+const profile = await fs.mkdtemp(path.join(os.tmpdir(), 'webbrain-delete-after-correction-mv3-'));+try {+ const extension = path.join(profile, 'extension'); await fs.cp(path.resolve('src/chrome'), extension, { recursive: true });+ await fs.appendFile(path.join(extension, 'src/background.js'), '\nglobalThis.afterCorrectionAgent = agent;\n');+ context = await chromium.launchPersistentContext(path.join(profile, 'user'), { headless: true, channel: 'chromium',+ viewport: { width: 1126, height: 745 },+ args: [`--disable-extensions-except=${extension}`, `--load-extension=${extension}`, '--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1'] });+ await context.route('**/*', async route => {+ const routed = route.request(), requested = new URL(routed.url());+ if (requested.hostname === '127.0.0.1' && requested.port === String(server.address().port)) return route.continue();+ if (requested.origin === 'https://mastoturk.org') {+ if (requested.pathname === '/api/v1/statuses' && routed.method() === 'POST') {+ const id = statusId(posts.length + 1);+ posts.push({ id, text: JSON.parse(routed.postData() || '{}').status }); created.push(posts.at(-1).text);+ return route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify({ id, url: `https://mastoturk.org/@${account}/${id}` }) });+ }+ const status = requested.pathname.match(/^\/api\/v1\/statuses\/(\d+)$/)?.[1];+ if (status && routed.method() === 'DELETE') {+ deletes.push(status); const index = posts.findIndex(item => item.id === status); if (index >= 0) posts.splice(index, 1);+ return route.fulfill({ status: 200, contentType: 'application/json', body: '{}' });+ }+ if (requested.pathname === '/publish') return route.fulfill({ contentType: 'text/html', body: composeBody });+ if (routed.isNavigationRequest()) return route.fulfill({ contentType: 'text/html', body: homeBody() });+ return route.fulfill({ status: 404, body: '' });+ }+ if (/^https?:$/.test(requested.protocol)) { blockedRemote++; return route.abort('blockedbyclient'); }+ return route.continue();+ });+ worker = context.serviceWorkers()[0] || await context.waitForEvent('serviceworker', { timeout: 30_000 });+ const extensionOrigin = `chrome-extension://${new URL(worker.url()).host}`;+ const settings = await context.newPage(); await settings.goto(`${extensionOrigin}/src/ui/settings.html`);+ panel = await context.newPage(); await panel.goto(`${extensionOrigin}/src/ui/sidepanel.html`);+ const message = (action, data = {}) => settings.evaluate(({ action, data }) => chrome.runtime.sendMessage({ target: 'background', action, ...data }), { action, data });+ await settings.evaluate(() => chrome.storage.local.set({ helpImproveWebBrain: false, userMemoryEnabled: false, tracingEnabled: false,+ autoScreenshot: false, screenshotFallback: false, planBeforeActMode: 'off', planBeforeAct: false, planReviewMode: 'never',+ maxAgentSteps: 40, systemOneEnabled: false, agentAllowLocalNetwork: true, askBeforeConsequentialActions: false,+ openaiAskStreamingEnabled: false }));+ assert.equal((await message('update_provider', { providerId: 'openrouter', config: { apiKey: 'owned-fixture-fake-key',+ baseUrl: `${base}/v1`, model: 'minimax/minimax-m3', enabled: true, contextWindow: 1000000, supportsAskStreaming: false, supportsVision: false } })).ok, true);+ assert.equal((await message('set_active_provider', { providerId: 'openrouter' })).ok, true);+ await worker.evaluate(() => { afterCorrectionAgent.clarifyTimeoutSec = -1; });+ page = await context.newPage(); await page.goto('https://mastoturk.org/home');+ tabId = await settings.evaluate(async () => (await chrome.tabs.query({})).find(tab => tab.url.startsWith('https://mastoturk.org'))?.id);+ // WebBrain's own cards are answered "Go ahead" ('once'); every card is recorded.+ let answering = true;+ const answerer = (async () => {+ const answered = new Set();+ while (answering) {+ const pending = await worker.evaluate(tabId => [...(afterCorrectionAgent._pendingClarifications.get(tabId)?.entries() || [])]+ .map(([id, entry]) => ({ id, question: String(entry?.question || entry?.data?.question || '').slice(0, 300) })), tabId).catch(() => []);+ for (const { id, question } of pending) {+ if (answered.has(id)) continue;+ answered.add(id); cards.push({ id: id.replace(/_[a-z0-9]{8,}$/i, '_*'), question });+ await message('clarify_response', { tabId, clarifyId: id, answer: 'once', source: 'option' }).catch(() => {});+ }+ await new Promise(resolve => setTimeout(resolve, 100));+ }+ })();+ const result = await message('chat', { tabId, text: request, mode: 'act', requestId: 'owned-delete-after-correction', locale: 'en' });+ answering = false; await answerer;+ const toolResults = (result.updates || []).filter(event => event.type === 'tool_result').map(event => ({ name: event.data?.name,+ success: event.data?.result?.success, guard: event.data?.result?.actionGuard || null,+ error: event.data?.result?.error ? String(event.data.result.error).slice(0, 400) : null }));+ const clarifies = (result.updates || []).filter(event => event.type === 'clarify')+ .map(event => ({ kind: event.data?.promptKind || null, question: String(event.data?.question || '').slice(0, 300) }));+ const done = result.updates?.findLast(event => event.type === 'tool_result' && event.data?.name === 'done')?.data?.result || null;+ const evidence = { request, correction, created, posts, deletes, steered, toolResults, clarifies, cards, decisions, unknownPrompts, judgeCalls, blockedRemote,+ done: done && { outcome: done.outcome, summary: String(done.summary || '').slice(0, 300), error: done.error || null }, finalContent: String(result.content || '').slice(0, 600) };+ await fs.writeFile(path.join(out, 'evidence.json'), JSON.stringify(evidence, null, 2));+ assert.deepEqual(unknownPrompts, [], 'Every model question was one the fixture answers');+ assert.equal(steered, true, 'The correction arrived after the post was sent');+ const refused = toolResults.filter(item => item.guard);+ assert.deepEqual(refused, [], `No step of the deletion was refused: ${JSON.stringify(refused)}`);+ assert.deepEqual(cards.map(card => card.id), ['deletion_*'], `One question, WebBrain's deletion card: ${JSON.stringify(cards)}`);+ assert.deepEqual(deletes, [statusId(1)], 'Exactly the new post is deleted, once, through Mastodon\'s confirmation');+ assert.deepEqual(created, [body], 'One post, before the correction');+ assert.deepEqual(posts, [], 'and it is gone from the timeline');+ assert.equal(evidence.done?.outcome, 'success', JSON.stringify(evidence.done));+ console.log(JSON.stringify({ passed: true, installedMV3: true, deletes: deletes.length, cards: cards.length, refused: refused.length, judgeCalls, blockedRemote }));+} finally {+ await context?.close(); await new Promise(resolve => server.close(resolve));+ const resolved = path.resolve(profile);+ if (resolved.startsWith(path.resolve(os.tmpdir()) + path.sep + 'webbrain-delete-after-correction-mv3-')) await fs.rm(resolved, { recursive: true, force: true });+}diff --git a/test/resource-mutation-guards.mjs b/test/resource-mutation-guards.mjsindex b74ab7f53..84b62ba13 100644--- a/test/resource-mutation-guards.mjs+++ b/test/resource-mutation-guards.mjs@@ -64,12 +64,18 @@ for (const build of ['chrome', 'firefox']) {earlierResultOfThisTask: true }, 'The model is told this is the verified earlier result of this task');});+ // Unmatched, the earlier post is never reconciled. A deletion cannot repeat+ // it, so the one the request names is decided as any deletion is, without+ // telling the model that this is the earlier post.test(`${build}: native acknowledgment, an unrelated post or a wrong body/account cannot reconcile publication`, async () => {for (const resources of [[], [record(savedUrl, 'Different')], [record('https://x.com/bob/status/900')]]) {const f = fixture(`Delete ${savedUrl}.`);f.detected.reconciliationResources = resources;- assert.equal((await f.check()).actionGuard.reason, 'prior_effect_unreconciled');- assert.equal(f.calls.length, 0, 'An unreconciled earlier post is never put to the model');+ assert.equal(await f.check(), null, JSON.stringify(resources));+ assert.notEqual(f.guard.steeringPriorSubmissionReconciliation?.verified, true, 'Nothing is reconciled');+ const [question] = f.decisions('deletion_request');+ assert.equal(question.page.earlierResultOfThisTask, undefined, 'The model is not told this is the earlier post');+ assert.equal(f.audits.length, 0);}});test(`${build}: prior publication with media can be exactly deleted and replaced without certifying its original media`, async () => {@@ -105,9 +111,21 @@ for (const build of ['chrome', 'firefox']) {if(failure==='unknown')f.guard.steeringPriorSubmission.dispatched=false;if(failure==='duplicate')f.detected={...f.detected,mutationKind:undefined,publicationControl:true,publicationSnapshot:structuredClone(f.guard.steeringPriorSubmission.publicationSnapshot)};- const blocked=await f.check();- assert.equal(blocked.noDispatch,true,failure);+ const result=await f.check();assert.equal(f.audits.length,0,failure);+ // A duplicate is never published, and another post than the one named+ // goes to the user's card.+ if(['duplicate','resource'].includes(failure)){assert.equal(result.noDispatch,true,failure);continue;}+ // The post the request names may go, never as the earlier post; the+ // replacement stays held to it.+ assert.notEqual(f.guard.steeringPriorSubmissionReconciliation?.verificationKind,'resource_identity',`${failure}: not reconciled`);+ assert.equal(result,null,failure);+ assert.equal(f.decisions('deletion_request')[0].page.earlierResultOfThisTask,undefined,failure);+ f.agent._completionSubmitStates.set(f.tab,{dispatched:true,observedAfterSubmit:true,mutationKind:'delete',+ actionDocument:'owned-document',actionResource:record()});+ f.detected={...f.detected,mutationKind:undefined,publicationControl:true,publicationSnapshot:snap('Corrected'),+ reconciliationResources:[],reconciliationResourceScanComplete:true};+ assert.equal((await f.check()).noDispatch,true,`${failure}: the replacement is held`);}});