From 4e4e291a8c6dcf353c3d329033a3ef4997351f2b Mon Sep 17 00:00:00 2001 From: rebuildup Date: Sat, 21 Nov 2026 15:05:17 +0900 Subject: [PATCH] fix(dev-loop): forward consentAudit through verify() so verify dispatches are audited (Issue #403) --- packages/ae-devtools-cli/dev-loop/devloop.mjs | 9 ++++++-- .../dev-loop/tests/devloop.test.mjs | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/ae-devtools-cli/dev-loop/devloop.mjs b/packages/ae-devtools-cli/dev-loop/devloop.mjs index 08fc069..5c59a1a 100644 --- a/packages/ae-devtools-cli/dev-loop/devloop.mjs +++ b/packages/ae-devtools-cli/dev-loop/devloop.mjs @@ -178,7 +178,7 @@ export async function verify(input = {}) { const { runner, pin, projectIdentity, consentProvider, trustedScriptOptIn, scriptProvenance, readOpId = "read.projectSummary", readArgs = {}, requestId, - hostProjectGuard, hostProjectGuardRequired, + hostProjectGuard, hostProjectGuardRequired, consentAudit, } = input ?? {}; const op = (() => { try { return getOperation(readOpId); } catch { return null; } })(); if (!op || op.mutating) { @@ -190,9 +190,14 @@ export async function verify(input = {}) { : `readOpId '${readOpId}' is a mutating op; verify requires a read-only op`; return { status: "refused", stage: "adapter", reason: "VERIFY_REQUIRES_READ_OP", detail, opId: readOpId }; } + // Explicit forward list — consentAudit MUST be here: verify dispatches + // are execute-class dispatches and their consent decisions are audit + // events (Issue #403). confirmRender/confirmDestructive/targetGuard + // are intentionally absent: verify only admits non-mutating ops, and + // runOperation's confirm gates and targetGuard never fire for them. return runOperation({ opId: readOpId, args: readArgs, runner, pin, projectIdentity, consentProvider, trustedScriptOptIn, scriptProvenance, requestId, - hostProjectGuard, hostProjectGuardRequired, + hostProjectGuard, hostProjectGuardRequired, consentAudit, }); } diff --git a/packages/ae-devtools-cli/dev-loop/tests/devloop.test.mjs b/packages/ae-devtools-cli/dev-loop/tests/devloop.test.mjs index 7a9614c..e53eb0c 100644 --- a/packages/ae-devtools-cli/dev-loop/tests/devloop.test.mjs +++ b/packages/ae-devtools-cli/dev-loop/tests/devloop.test.mjs @@ -152,6 +152,28 @@ test("execute/verify on null input produce structured refusals, not TypeErrors", assert.equal(typeof v.reason, "string"); }); +test("verify forwards consentAudit — verify dispatches record consent decisions (Issue #403)", async () => { + const f = fixture(); + const entries = []; + const consentAudit = { + recordConsentDecision(entry) { entries.push(entry); }, + }; + const v = await verify({ ...f, consentAudit, requestId: "req-verify-1" }); + assert.equal(v.outcome, "COMPLETED"); + assert.equal(entries.length, 1); + assert.equal(entries[0].decision, "approved"); + assert.equal(entries[0].opId, "read.projectSummary"); + assert.equal(entries[0].requestId, "req-verify-1"); + assert.equal(entries[0].mutating, false); +}); + +test("verify surfaces a malformed consentAudit as CONSENT_AUDIT_INVALID (Issue #403)", async () => { + const f = fixture(); + const v = await verify({ ...f, consentAudit: { bogus: true } }); + assert.equal(v.status, "refused"); + assert.equal(v.reason, "CONSENT_AUDIT_INVALID"); +}); + test("execute adds no approval path: denial still refuses before transport", async () => { const f = fixture(); const origSend = f.transport.send.bind(f.transport);