Skip to content

Commit fcea4ec

Browse files
committed
fix(scenarios): a hook's declared refusal at 403 is no build denial
After #33556 the door serves a hook's own refusal at 403 as PERMISSION_DENIED with the hook's code on declaredCode. isWriteDenial now requires no declaredCode, so that refusal is graded as the app's rule (both halves measured) and never read as the build denying the persona the write. Pinned in the grader test; ablating the guard reds 2 tests. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzZVHjrq7bFdLyjYVG
1 parent d1f74ec commit fcea4ec

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎.changeset/33596-scenario-grader-build-denies-write.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Metadata-protocol: none
99

1010
An operation declared `applied` whose agent write was refused 403 `PERMISSION_DENIED` counted as the operation's failure, even when the built app's permission set denied the persona a write the card gives it: the loss landed on the asking side for a build error.
1111

12-
The runner now sends the declared write itself as the persona when the agent's own write on an `applied` create or update was denied 403 and nothing was written. When the door denies the probe too, and the build declares no lock that routes the write through an action, the operation is not measured ("the build denies the persona this write"): out of passed and total, and the scorecard lists a Build finding naming the persona, the object and the verb. The `write_validation` probe that meets the same 403 is reported the same way. A 403 the card declares (`refused PERMISSION_DENIED`) and a `pending_confirmation` operation grade as before, and the probe that meets the build's routed lock keeps its own not-measured reason.
12+
The runner now sends the declared write itself as the persona when the agent's own write on an `applied` create or update was denied 403 and nothing was written. When the door denies the probe too, and the build declares no lock that routes the write through an action, the operation is not measured ("the build denies the persona this write"): out of passed and total, and the scorecard lists a Build finding naming the persona, the object and the verb. The `write_validation` probe that meets the same 403 is reported the same way. A 403 the card declares (`refused PERMISSION_DENIED`) and a `pending_confirmation` operation grade as before, and the probe that meets the build's routed lock keeps its own not-measured reason. A hook's own refusal served at 403 (its code on `declaredCode`) is the app's rule, not a denial, and grades as before.

‎packages/qa/scenarios/src/score/scenario-operation-grade.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,13 @@ const isLockRefusal = (a: ObservedAnswer): boolean =>
291291

292292
/**
293293
* The door denied a write and nothing was written: `PERMISSION_DENIED` at 403
294-
* with no record changed. The runner probes an `applied` operation only when
295-
* the agent's own write met this ({@link buildDeniesWrite}).
294+
* with no record changed and no `declaredCode` (a hook's own refusal served at
295+
* 403 carries its code there, and is the app's rule, not the build's denial).
296+
* The runner probes an `applied` operation only when the agent's own write met
297+
* this ({@link buildDeniesWrite}).
296298
*/
297299
export function isWriteDenial(answer: ObservedAnswer, writes: number | undefined): boolean {
298-
return writes === 0 && isLockRefusal(answer);
300+
return writes === 0 && isLockRefusal(answer) && answer.kind === 'refused' && answer.declaredCode === undefined;
299301
}
300302

301303
/**

‎packages/qa/scenarios/test/score/scenario-operation-grade.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ describe('gradeOperation — a write the build denies the persona (#33596)', ()
160160
expect(isWriteDenial(DENIED, undefined)).toBe(false);
161161
expect(isWriteDenial({ kind: 'refused', code: 'PERMISSION_DENIED' }, 0)).toBe(false);
162162
expect(isWriteDenial({ kind: 'refused', code: 'VALIDATION_FAILED', status: 400 }, 0)).toBe(false);
163+
// A hook's own refusal served at 403 (#31407 demotes its code to declaredCode) is the app's rule, not the build's denial.
164+
expect(isWriteDenial({ ...DENIED, declaredCode: 'NOT_REQUESTER' }, 0)).toBe(false);
165+
});
166+
167+
it("⛔ a hook's declared refusal at 403 is measured on both halves, never charged to the build", () => {
168+
const HOOK = { ...DENIED, declaredCode: 'OVER_RECEIPT' } as const;
169+
const invalid = gradeOperation({ kind: 'refused', code: 'VALIDATION_FAILED' }, { answer: HOOK, writes: 0, withheld: false, probe: { answer: HOOK, writes: 0 } }, { probed: true });
170+
expect([invalid.pass, invalid.notMeasured]).toEqual([true, undefined]);
171+
expect(invalid.checks.every((c) => c.notMeasured === undefined)).toBe(true);
172+
const applied = gradeOperation(APPLIED, { ...BOTH_DENIED, answer: HOOK, probe: { answer: HOOK, writes: 0 } });
173+
expect([applied.pass, applied.notMeasured]).toEqual([false, undefined]);
174+
expect(applied.checks.every((c) => c.notMeasured === undefined)).toBe(true);
163175
});
164176

165177
it('applied: the agent and the probe both denied leaves the operation not measured, every check, never a pass', () => {

0 commit comments

Comments
 (0)