Skip to content

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

Guard policy: a commit that can rewrite its message keeps the split while one is requested

Barack Sokullub9dcd31a6b94
diff --git a/docs/guards.md b/docs/guards.md
index f3166689f..946d96c02 100644
--- a/docs/guards.md
+++ b/docs/guards.md
@@ -42,6 +42,12 @@ the action is wrong (`onDecided`) and when it cannot tell (`onCannotDecide`):
an exact reader reads back as a different value is reported the same
way, but it ends a batch: the next action is planned once the model has
seen it.
+ - A GitHub commit sent by an action that can also rewrite the fields
+ (`set_field` with a submit, Enter, `execute_js`) goes through with a note
+ when the verified file binding covers it: the committed file is checked
+ after the commit. While the request names a commit message, which is
+ proven only before the commit, it is still refused, and the commit takes
+ a separate click.
- A quality guard whose `onCannotDecide` is `ask` asks the user when it
cannot verify a consequential step, such as a commit or a post. Where
that guard has no card, it refuses.
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 8af43eb73..100a966ac 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -3190,9 +3190,12 @@ export class Agent extends LoopDetector {
// activation may use an existing binding. Anything else must split into
// a plain write (verified on its own) followed by a separate click.
// github-commit-split-write-required (quality): when the action does look
- // like the commit and the verified file and message binding a commit click
- // would need is in place, Strict checks off lets it run with a note; the
- // committed raw file is then checked against that binding after the commit.
+ // like the commit and the verified file binding a commit click would need
+ // is in place, Strict checks off lets it run with a note; the committed
+ // raw file is then checked against that binding after the commit. A
+ // requested commit message is proven only before the commit
+ // (commitMessageVerified), and this action could rewrite it while it
+ // commits, so while the request names one the action keeps refusing.
// An inconclusive detection is the cannot-decide case and keeps refusing,
// and so does a missing binding (github-commit-evidence-binding).
if (name !== 'click' && name !== 'click_ax' && name !== 'iframe_click') {
@@ -3200,11 +3203,13 @@ export class Agent extends LoopDetector {
const pageUrl = await this._currentUrl(tabId);
await this._refreshGithubTextReplacementProofs(tabId, pageUrl);
const binding = this._workflowSubmitBindingForAttempt(tabId, pageUrl, {}, detectedSubmit);
- if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit
+ const messageRequested = (Array.isArray(binding?.metadataRequirements) ? binding.metadataRequirements : [])
+ .some(requirement => requirement?.field === 'commit_message');
+ if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit && !messageRequested
&& this._guardAdvisesFor(advisories, 'github-commit-split-write-required',
name === 'execute_js'
- ? 'This script may change the editor or commit message while it commits, so the earlier verified file and message proofs do not cover it. It ran anyway; read the committed file and commit message back before reporting success.'
- : 'This action can change field values while it submits the commit, so the earlier verified file and message proofs do not cover it. It ran anyway; read the committed file and commit message back before reporting success.')) {
+ ? 'This script may change the editor while it commits, so the earlier verified file proof does not cover it. It ran anyway; the committed file is checked against that proof after the commit.'
+ : 'This action can change field values while it submits the commit, so the earlier verified file proof does not cover it. It ran anyway; the committed file is checked against that proof after the commit.')) {
return null;
}
}
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 663ce506e..ec3241a07 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -2747,9 +2747,12 @@ export class Agent extends LoopDetector {
// activation may use an existing binding. Anything else must split into
// a plain write (verified on its own) followed by a separate click.
// github-commit-split-write-required (quality): when the action does look
- // like the commit and the verified file and message binding a commit click
- // would need is in place, Strict checks off lets it run with a note; the
- // committed raw file is then checked against that binding after the commit.
+ // like the commit and the verified file binding a commit click would need
+ // is in place, Strict checks off lets it run with a note; the committed
+ // raw file is then checked against that binding after the commit. A
+ // requested commit message is proven only before the commit
+ // (commitMessageVerified), and this action could rewrite it while it
+ // commits, so while the request names one the action keeps refusing.
// An inconclusive detection is the cannot-decide case and keeps refusing,
// and so does a missing binding (github-commit-evidence-binding).
if (name !== 'click' && name !== 'click_ax' && name !== 'iframe_click') {
@@ -2757,11 +2760,13 @@ export class Agent extends LoopDetector {
const pageUrl = await this._currentUrl(tabId);
await this._refreshGithubTextReplacementProofs(tabId, pageUrl);
const binding = this._workflowSubmitBindingForAttempt(tabId, pageUrl, {}, detectedSubmit);
- if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit
+ const messageRequested = (Array.isArray(binding?.metadataRequirements) ? binding.metadataRequirements : [])
+ .some(requirement => requirement?.field === 'commit_message');
+ if (binding?.metadataRequirementsIncomplete !== true && binding?.githubFileCommit && !messageRequested
&& this._guardAdvisesFor(advisories, 'github-commit-split-write-required',
name === 'execute_js'
- ? 'This script may change the editor or commit message while it commits, so the earlier verified file and message proofs do not cover it. It ran anyway; read the committed file and commit message back before reporting success.'
- : 'This action can change field values while it submits the commit, so the earlier verified file and message proofs do not cover it. It ran anyway; read the committed file and commit message back before reporting success.')) {
+ ? 'This script may change the editor while it commits, so the earlier verified file proof does not cover it. It ran anyway; the committed file is checked against that proof after the commit.'
+ : 'This action can change field values while it submits the commit, so the earlier verified file proof does not cover it. It ran anyway; the committed file is checked against that proof after the commit.')) {
return null;
}
}
diff --git a/test/guard-advisory-actions.mjs b/test/guard-advisory-actions.mjs
index f85c5471f..29cd5cb93 100644
--- a/test/guard-advisory-actions.mjs
+++ b/test/guard-advisory-actions.mjs
@@ -585,7 +585,7 @@ for (const build of ['chrome', 'firefox']) {
}
// ── github-commit-split-write-required ──────────────────────────────────
- function githubCommitAgent(strict, { bound = true } = {}) {
+ function githubCommitAgent(strict, { bound = true, message = false } = {}) {
const agent = new Agent({ getVisionProvider: async () => null });
agent.strictGuards = strict;
const tab = nextTab++;
@@ -597,7 +597,9 @@ for (const build of ['chrome', 'firefox']) {
agent._refreshGithubTextReplacementProofs = async () => {};
// The verified file and commit-message binding a commit click would use.
agent._workflowSubmitBindingForAttempt = () => (bound
- ? { githubFileCommit: { repository: 'example/repo', branch: 'main', path: 'docs/plan.md' } }
+ ? { githubFileCommit: { repository: 'example/repo', branch: 'main', path: 'docs/plan.md',
+ ...(message ? { commitMessageVerified: true } : {}) },
+ metadataRequirements: message ? [{ field: 'commit_message', value: 'Fix typo' }] : [] }
: { metadataRequirementsIncomplete: true });
return { agent, tab };
}
@@ -627,6 +629,25 @@ for (const build of ['chrome', 'firefox']) {
assert.deepEqual(advisories, []);
});
+ test(`${build}: github-commit-split-write-required ${mode} mode keeps a commit-with-write refused while the request names a commit message`, async () => {
+ // The requested message is proven only before the commit; an action
+ // that can rewrite it while it commits cannot use that proof.
+ const { agent, tab } = githubCommitAgent(strict, { message: true });
+ for (const [name, args, detected] of [
+ ['set_field', { ref_id: 'ref_message', text: 'Fix typo', submit: true }, { isSubmit: true, host: 'github.com' }],
+ ['press_keys', { key: 'Enter' }, { isSubmit: true, host: 'github.com' }],
+ ]) {
+ const advisories = [];
+ const block = await agent._workflowPreSubmitDispatchBlock(tab, name, args, detected, null, advisories);
+ assert.equal(block?.splitWriteRequired, true, name);
+ assert.deepEqual(advisories, [], name);
+ }
+ // A plain click on the commit control still uses the binding.
+ const advisories = [];
+ assert.equal(await agent._workflowPreSubmitDispatchBlock(tab, 'click_ax', { ref_id: 'ref_commit' },
+ { isSubmit: true, host: 'github.com' }, null, advisories), null);
+ });
+
test(`${build}: github-commit-split-write-required ${mode} mode keeps an inconclusive script refused`, async () => {
const { agent, tab } = githubCommitAgent(strict);
assert.equal(agent._isFormValidationCandidate('execute_js', { code: 'void 0' }), true);