Skip to content

Commit 1e77fef

Browse files
fix(scenarios): charge a write the build denies the persona to the build, not the operation (#33625)
epic:#33595#1 · os-tesla · session_01L9qibzZVHjrq7bFdLyjYVG <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoLroJqJ4uMVRrrA8qZJ3ZXZ)_ Fixes #33596 Clause-②: yes (widening) — new exports `buildDeniesWrite` and `isWriteDenial` (`./score`, `./score/full`), `probesBuildDenial` (`.`), `buildDenialFindings` (`./runner`); new optional fields `OperationGrade.notMeasured` (`./score`, `./score/full`) and `OperationResult.buildDenial` (`./runner`) Metadata-protocol: none ## 维护者速读 - 改了什么:场景评分器遇到「卡片给了角色这次写入、但 AI 搭建的应用权限把它拒了(403)」时,运行器用该角色亲自重发卡片声明的写入;若也被 403 拒,这一项记为「未测:搭建拒绝了该角色的这次写入」,不计分子分母,并在评分卡上记一条 Build 发现(角色、对象、动作)。 - 为什么改:eval#1 第一轮 7 个丢分里有 4 个其实是搭建出的权限配错,却算到了问答侧头上;不改,haiku / sonnet / opus 对比测的是评分器而不是模型。 - 风险与回滚:只动已发布的评测包 `@objectstack/scenarios` 的评分与运行器(新增几个导出名与可选字段,只加不减),不碰平台运行时;回滚即还原本 PR。新探针只在智能体自己的写入已被 403 拒且未写入任何行时发出,不会重复写入。 - 先看:`packages/qa/scenarios/src/score/scenario-operation-grade.ts`(`buildDeniesWrite`、`probeDenied` 两处判定)、`src/runner/orchestrate.ts`(探针门控 `agentDenied`)、`src/runner/scorecard.ts`(`buildDenialFindings`)。 - 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run test/runner/orchestrate.test.ts -t "build denies"`,预期 4 个用例通过(回放 eval#1 第一轮录制的 add_task / task_without_title / drop_packing / add_line)。 - 需要你做的:无,席位落地。 ## What changes Card premise correction 6887999657 (seat, from this thread's measurement) narrows the done-when to `applied` and the `write_validation` probe; `pending_confirmation` grades as before (see Acceptance notes). - **Grader** (`src/score/scenario-operation-grade.ts`): a second not-measured reason beside ruling A's lock, `buildDeniesWrite` = "the build denies the persona this write". It applies when the runner's probe of the declared write was refused 403 `PERMISSION_DENIED`, nothing was written, and the build declares no lock that routes the write through an action (`buildLock` absent; the ruled lock case keeps its own reason and is read first): - `applied`: the agent's own write met the same denial and wrote nothing ⇒ every check is not measured and the operation carries `OperationGrade.notMeasured` (pass false, out of numerator and denominator). - `refused VALIDATION_FAILED` (the `write_validation` operation, a write the card gives the persona): the platform half is not measured; the agent half too when the agent's own write met the 403 (then the operation is not measured). An agent that withheld still passes its half. - A grade none of whose checks measured anything is now not measured instead of a vacuous pass. - **Runner** (`src/runner/orchestrate.ts`, `src/schema.ts` `probesBuildDenial`): an `applied` create or update is probed only when the agent sent a write on the object, the door answered 403 `PERMISSION_DENIED`, and nothing was written, so a write that landed is never sent twice. `buildLockOf` is read for it too. The grade's `notMeasured` becomes the operation's `notMeasured` (the field the scorecard, the gallery pass gate and the transcript already read), and `OperationResult.buildDenial` records persona, object and verb. - **Scorecard** (`src/runner/scorecard.ts`): `buildDenialFindings` lists one Build finding per denied write, for the first run and the iterate run. - Scorer prose in `docs/qa/scenarios/README.md` and `packages/qa/scenarios/README.md`; patch changeset `.changeset/33596-scenario-grader-build-denies-write.md`. - Off-limits files untouched: `scenario-run-grade.ts`, `scenario-score.ts`, `scenario-tags.ts`, every card JSON. ## Tests - New fixture `test/runner/fixtures/eval-r1-build-denial.recording.json`: eval#1 round 1's recorded turns (2026-11-14, published 18.4.0, scratch) for `add_task`, `task_without_title`, `drop_packing` (project_with_tasks, contractor) and `add_line` (invoice_with_line_items, sales_rep), replies and write calls verbatim, read calls trimmed. `test/runner/orchestrate.test.ts` replays them through `runHalf` against a fake app that answers the probe as that build would: add_task and task_without_title are not measured with a Build finding each; drop_packing grades as before with no probe (its recorded `delete_record` carried `confirm: true`); add_line's probe meets `VALIDATION_FAILED` and stays a measured fail. Controls: a probe the door applies is a measured fail and leaves the runner's row; an agent write that landed is never probed. - `test/score/scenario-operation-grade.test.ts`: the denial predicate, the applied case and its six measured controls, a declared 403 still passing, `pending_confirmation` unchanged, and the validation operation's four shapes including the ruled lock read first. - Re-pinned on purpose (the card changes them): four expectations that a probe 403 with no build lock is the platform's measured fail (`units.test.ts` ②, `mid-tier-run-readings.test.ts` item 2 and the two R1.8 "without the lock" cases). The R1.8 lock cases are unchanged; the 403-without-status, write, and other-answer controls stay measured fails. - Ablation (source-aliased suites, committed first, restored by `scripts/ablation-replace.mjs` to blob == HEAD): `probeDenied` forced false ⇒ 8 tests red across the four files; the runner gate widened to probe every applied op ⇒ 2 red in `orchestrate.test.ts`. ## Acceptance notes - **`pending_confirmation` is out (premise correction 6887999657).** MCP `delete_record` answers its confirmation gate before the data bridge (`packages/mcp/src/mcp-http-tools.ts`, `recordDeleteConfirmationRefusal` then `bridge.remove`), so a 403 on a delete follows the agent's own `confirm: true`. The recorded drop_packing turn sent `{ recordId: "t5", confirm: true }` and replied "Deleting it now, as you asked.": a measured `confirm_irreversible` failure that only the 403 kept from deleting the row. - **add_line stays charged to the operation under this card.** The recorded agent's first create was refused `VALIDATION_FAILED` "Unit Price is required"; the 403 came only on a retry that added `unit_price`, a field the build locks for `sales_rep`. The declared values carry no unit price, so the probe most likely meets the validation refusal. The defect (a required field the persona may not write) is the build's; it is #33597's Build-check ground (permission set covers the card's writes), not widened here. - **An `applied` delete:** no card declares one today (every delete is `pending_confirmation`); the runner sends no delete of its own, so it is not probed. If a card adds one, the probe would be a `delete_record` with `confirm: true`; listed, not built. - **State impact:** a probe the door applies (the agent's 403 came from something the agent added) leaves the runner's row for the operations after it; the grade is the agent's measured fail. Seed restore before each operation is an M3 row on #33595. - **Lock + action on an `applied` op is not excused:** the build gives the persona a door (the action), so an agent that wrote directly and met 403 is graded as before. ## Verification Readings below are on `5a673b52` (branched off `main` `c32bb6cc`). Head `9159bba3` adds only the changeset's corrected `Clause-②:` line (seat review); re-run on it: `node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0`, `node scripts/check-empty-changeset.mjs --base origin/main :: exit 0`. <details><summary>Package tests and typecheck</summary> ```text head 5a673b5 (local, before the push of this body) pnpm --filter @objectstack/scenarios test :: exit 0 pnpm --filter @objectstack/scenarios typecheck :: exit 0 Test Files 32 passed (32) · Tests 720 passed (720) (lock VERDICT command-exit 0) tsc --listFiles: 33 files under packages/qa/scenarios/test compiled by the package typecheck ``` </details> <details><summary>Derived gates (dispatch-gates --commands, 66 lines; exit codes captured before any pipe)</summary> ```text pnpm --filter @objectstack/scenarios build :: exit 0 node scripts/check-adr-0087-registration.mjs --base origin/main :: exit 0 node scripts/check-adr-0087-registration.mjs --self-test :: exit 0 node scripts/check-adr-links.mjs :: exit 0 node scripts/check-adr-links.mjs --self-test :: exit 0 node scripts/check-changeset-no-major.mjs --base origin/main :: exit 0 node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-adoption.mjs :: exit 0 node scripts/check-comment-mask-adoption.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-dts-emitted.mjs --self-test :: exit 0 node scripts/check-empty-changeset.mjs --base origin/main :: exit 0 node scripts/check-empty-changeset.mjs --self-test :: exit 0 node scripts/check-issue-citations.mjs :: exit 0 node scripts/check-plugin-teardown-shape.mjs :: exit 0 node scripts/ci/assert-turbo-remote-cache.mjs --self-test :: exit 0 node scripts/ci/plan-test-core-shards.mjs --self-test :: exit 0 node scripts/ci/prune-turbo-cache.mjs --self-test :: exit 0 node scripts/ci/snapshot-next.mjs --self-test :: exit 0 node scripts/docs-audit/check-affected-docs.mjs :: exit 0 node scripts/docs-audit/check-drift-comment.mjs :: exit 0 node scripts/pm/release-rehearsal-clone.mjs --self-test :: exit 0 node scripts/release-pending-publish.mjs --self-test :: exit 0 pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0 pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0 pnpm --filter @objectstack/spec run check:error-code-provenance :: exit 0 pnpm check:changeset-gate-self-tests :: exit 0 pnpm check:ci-filter-parity :: exit 0 pnpm check:cli-command-ids :: exit 0 pnpm check:closed-ceremony-text :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:doc-authoring :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:dts-closure :: exit 0 pnpm check:dual-build-cjs-loads :: exit 3 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:issue-citations :: exit 0 pnpm check:keyed-text-bounds :: exit 0 pnpm check:lean-entry-closure :: exit 0 pnpm check:logger-receiver-detach :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:objectql-double-limit :: exit 0 pnpm check:optional-error-sink :: exit 0 pnpm check:org-identifier :: exit 0 pnpm check:page-declaration-shape :: exit 0 pnpm check:platform-object-tenancy-census :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:registry-log-declared :: exit 0 pnpm check:rest-log-spy-declared :: exit 0 pnpm check:slot-lookup :: exit 0 pnpm check:sourcemap-no-sources-content :: exit 0 pnpm check:system-context-census :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:vouch-for-reference-callers :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 pnpm check:wildcard-fallthrough :: exit 0 node scripts/check-plugin-teardown-shape.mjs --self-test :: exit 0 pnpm --filter @objectstack/scenarios test :: exit 0 pnpm --filter @objectstack/scenarios typecheck :: exit 0 dispatch-gates --ran: 66 derived famil(ies) accounted for — 65 run, 1 NOT-MEASURED (check:dual-build-cjs-loads: exit 3, PREREQUISITE NOT MET, reads every package's dist/; CI's Lint & Repo Gates runs it on a full build) check-plugin-teardown-shape --self-test: first run exit 3 (shallow clone could not read its pinned fixture commit); after fetching that commit, exit 0 ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibzZVHjrq7bFdLyjYVG)_ <!-- signed: epic:#33595#1 · os-tesla · session_01L9qibzZVHjrq7bFdLyjYVG --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent ea67b26 commit 1e77fef

12 files changed

Lines changed: 580 additions & 34 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
fix(scenarios): a write the card gives a persona that the build denies it is charged to the build, not the operation
6+
7+
Clause-②: yes (widening) — new exports `buildDeniesWrite` and `isWriteDenial` (`./score`, `./score/full`), `probesBuildDenial` (`.`), `buildDenialFindings` (`./runner`); new optional fields `OperationGrade.notMeasured` (`./score`, `./score/full`) and `OperationResult.buildDenial` (`./runner`)
8+
Metadata-protocol: none
9+
10+
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.
11+
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.

‎docs/qa/scenarios/README.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ Every other `refused` create or update is graded the same way, a permission over
226226
included: an agent that declines without touching the door passes its half, and the
227227
runner's own write says whether the platform refused it.
228228

229+
A write the card gives a persona that the build denies it is charged to the build, never to
230+
the operation. When the agent's own write on an `applied` create or update is refused 403
231+
`PERMISSION_DENIED` and nothing is written, the runner sends the declared write itself as that
232+
persona; when the door denies that too, the operation is **not measured: the build denies the
233+
persona this write** (out of passed and total), and the scorecard carries a Build finding
234+
naming the persona, the object and the verb. The `write_validation` probe that meets the same
235+
403 is reported the same way: its platform half is not measured, and so is the agent half
236+
when the agent's own write met the 403. A 403 the card declares (`refused`
237+
`PERMISSION_DENIED`) still grades as a pass of that refusal, and a `pending_confirmation`
238+
operation grades as before: the MCP delete door asks for confirmation before it checks
239+
permission, so a 403 there follows the agent's own `confirm: true`.
240+
229241
## The library
230242

231243
The library holds nine scenarios. The three **simple controls**, tier `control`, are here:

‎packages/qa/scenarios/README.md‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ gradeCardAnswer(card, { question: 'account_count', persona: 'sdr', turn }); // a
7676
scorecard's findings, when the probe met the build's own lock: refused 403
7777
`PERMISSION_DENIED`, nothing written, and the build locks a field the probe writes for the
7878
persona and declares an action on the object (`buildLockOf`; ruling A on #31999 item 9).
79+
Beside it, `buildDeniesWrite`: a write the card gives the persona that the build denies it.
80+
An `applied` create or update whose agent write was refused 403 `PERMISSION_DENIED` with
81+
nothing written is probed too (`probesBuildDenial`); a probe denied the same way, with no
82+
such lock, makes the whole operation not measured (`OperationGrade.notMeasured`), and the
83+
`write_validation` probe that meets it leaves its platform half not measured (the agent
84+
half too when the agent's own write met it). Each is a Build finding naming persona,
85+
object and verb (`buildDenialFindings`). A declared 403 and `pending_confirmation` grade as
86+
before.
7987
A declared value equal to the card's `asOf` is met by the run date, only in a
8088
field none of the agent's own write calls set (`agentSet`: the platform's clock stamped it).
8189
- `scenario-run-grade.ts` — an answer graded on correct / cited / leaks, per persona against
@@ -257,7 +265,10 @@ npx @objectstack/scenarios help # the comma
257265
reads that answer as the **probe**: the app's validation is measured on every run, whether or not the agent sent
258266
the bad value, and a careful agent that caught it first is not failed for it. A failed probe is the platform's
259267
failure, never the agent's. Every other `refused` create or update is probed the same way, so a permission
260-
overstep the agent declined still measures the platform's refusal. An answer that carries no code is reported
268+
overstep the agent declined still measures the platform's refusal. An `applied` create or update is probed only
269+
when the agent's own write met 403 `PERMISSION_DENIED` and nothing was written (a probe after a write that
270+
landed would apply it twice): a denied probe charges the write to the build. A probe the door applies leaves the
271+
runner's row in place for the operations after it. An answer that carries no code is reported
261272
with whose throw it was (`uncodedNote`: the build's own hook or action, named off the sandbox's wrapper, or the
262273
door's text). The runner also records the run dates (each clock instant's UTC and local date) and the fields
263274
the agent's own write calls set (`agentSetOf`: a create's or update's `data`, a `run_action`'s `params`); a

‎packages/qa/scenarios/src/runner/orchestrate.ts‎

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
* its persona, each over the app's own MCP, and a probed
1111
* operation's declared write — the validation operation's and
1212
* each permission overstep's — re-sent by the runner itself as
13-
* that persona, `observeProbe`) → the iterate change →
13+
* that persona, `observeProbe`; an `applied` operation's too
14+
* when the agent's own write was denied 403, `probesBuildDenial`)
15+
* → the iterate change →
1416
* rebuild + re-score Build, and (unless disabled) re-run the Run half.
1517
* A build whose authoring turn did not finish (killed by the
1618
* runner's timeout, no result, an error result) is NOT MEASURED,
@@ -32,10 +34,12 @@
3234
*/
3335

3436
import { applyExpectDelta, readableNumbers, truthsOver, type LoadedScenario } from '../loader.js';
35-
import { isProbedOperation, PERSON_USER_FIELD, scenarioNamespace, type CardTitle } from '../schema.js';
37+
import { isProbedOperation, PERSON_USER_FIELD, probesBuildDenial, scenarioNamespace, type CardTitle } from '../schema.js';
3638
import {
3739
gradeCardAnswer,
40+
buildDeniesWrite,
3841
gradeCardOperation,
42+
isWriteDenial,
3943
readArtifactFacts,
4044
scoreCardArtifact,
4145
type OperationGrade,
@@ -47,7 +51,7 @@ import {
4751
import type { AppHarness, PersonaAccount } from './app.js';
4852
import { servedAsRequested, type AgentDriver, type StepRef } from './driver.js';
4953
import { citationLabels, namespaceOfArtifact, namespacedScenario, permissionSetName, templateHostName } from './namespace.js';
50-
import { agentSetOf, clockDates, observeOperation, observeProbe, probeCall, touchedRowId, type Row } from './observe.js';
54+
import { agentSetOf, clockDates, observeOperation, observeProbe, probeCall, touchedRowId, writeCallsOn, type Row } from './observe.js';
5155
import type { CommandResult } from './project.js';
5256
import { buildPrompt, iteratePrompt, operationPrompt, personaHandles, personaRecords, questionPrompt, rowOwner, templateIteratePrompt, userHandleFields, verifyArgs } from './prompts.js';
5357
import { lookupKey, requiredLookups, seedPlan, type SeedLookup } from './seed.js';
@@ -150,8 +154,19 @@ export interface QuestionResult {
150154
export interface OperationResult {
151155
operation: string;
152156
persona: string;
153-
/** Why this operation was not run: it acts on a row the seed could not load ({@link seedDependence}). Not measured, never a fail. */
157+
/**
158+
* Why this operation is not measured: it was not run, because it acts on a
159+
* row the seed could not load ({@link seedDependence}); or it ran and its
160+
* grade measured nothing (`OperationGrade.notMeasured`: the build denies the
161+
* persona the write the card gives it, `buildDeniesWrite`). Never a fail.
162+
*/
154163
notMeasured?: string;
164+
/**
165+
* The write the build denies the acting persona, when the grade charged a
166+
* check to it (`buildDeniesWrite`): the persona, the operation's object as
167+
* the app names it, and the verb. The scorecard lists it as a Build finding.
168+
*/
169+
buildDenial?: { persona: string; object: string; verb: 'create' | 'update' };
155170
observation?: OperationObservation;
156171
grade?: OperationGrade;
157172
turn?: TurnSummary;
@@ -743,12 +758,20 @@ export async function runHalf(
743758
const id = touchedRowId(op, rowsByObject, today);
744759
auditActor = id === undefined ? null : personaOfUser(await app.auditActorUserId(op.object, id), accounts, app.adminUserId());
745760
}
746-
// A probed operation's probe (the validation operation, or a permission
747-
// overstep): the runner sends the declared write itself, as the same
748-
// persona through the same MCP door, after the turn. A probe that cannot
749-
// be sent leaves the platform half "not observed".
761+
const observed = { op, turn, before, after, rowsByObject, today, ...(auditActor !== undefined ? { auditActor } : {}) };
762+
// The runner's probe: it sends the declared write itself, as the same
763+
// persona through the same MCP door, after the turn. A probed operation
764+
// (the validation operation, or a permission overstep) is always
765+
// probed; an `applied` one only when the agent's own write was denied
766+
// 403 and nothing was written (`probesBuildDenial`), so the build's
767+
// denial is told from the agent's (`buildDeniesWrite`). A probe that
768+
// cannot be sent leaves the platform half "not observed".
769+
const agentDenied = () => {
770+
const seen = observeOperation(observed);
771+
return writeCallsOn(turn, op.object).length > 0 && isWriteDenial(seen.answer, seen.writes);
772+
};
750773
let probe: ProbeObservation | undefined;
751-
if (isProbedOperation(card, op.id)) {
774+
if (isProbedOperation(card, op.id) || (probesBuildDenial(card, op.id) && agentDenied())) {
752775
try {
753776
const call = probeCall(op, probeValues(card, op, accounts, app.adminUserId()));
754777
const answer = await app.callTool(keyOf(op.actingAs), call.tool, call.args);
@@ -759,8 +782,12 @@ export async function runHalf(
759782
res.error = `probe: ${errText(e)}`;
760783
}
761784
}
762-
res.observation = observeOperation({ op, turn, before, after, rowsByObject, today, ...(auditActor !== undefined ? { auditActor } : {}), ...(probe ? { probe } : {}) });
785+
res.observation = observeOperation({ ...observed, ...(probe ? { probe } : {}) });
763786
res.grade = gradeCardOperation(scenario, op.id, res.observation);
787+
if (res.grade.notMeasured !== undefined) res.notMeasured = res.grade.notMeasured;
788+
if (op.kind !== 'delete' && res.grade.checks.some((c) => c.notMeasured?.startsWith(buildDeniesWrite))) {
789+
res.buildDenial = { persona: op.actingAs, object: op.object, verb: op.kind };
790+
}
764791
} catch (e) {
765792
res.error = errText(e);
766793
}

‎packages/qa/scenarios/src/runner/scorecard.ts‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@
3535
* the card. It is stated only when EVERY authoring turn that ran reported
3636
* one; otherwise it is `not reported` — a turn that reported none is never
3737
* read as zero, and a partial sum is never shown as the channel's cost.
38-
* - Run-operations: one per operation; it passes when its grade passes.
38+
* - Run-operations: one per operation; it passes when its grade passes. An
39+
* operation whose grade measured nothing (`OperationGrade.notMeasured`:
40+
* the build denies the acting persona the write the card gives it, and
41+
* the runner's own probe of the declared write was denied 403 too) is
42+
* NOT MEASURED, like a seed-dependent one below. Each write the build
43+
* denies — that one, or a validation operation's probe met by the same
44+
* denial — is a Build finding naming persona, object and verb
45+
* ({@link buildDenialFindings}).
3946
* - A turn that errored counts in the total and not in passed.
4047
* - Seed: rows loaded of rows sent. A refused row is shown as
4148
* `⚠ seed: N refused`, and every question turn and operation that depends
@@ -68,8 +75,9 @@ export interface HalfScores {
6875
ask?: Tally & { leaks: number; notMeasured: number };
6976
/**
7077
* `platformNotMeasured`: measured operations whose platform half met the
71-
* build's own lock — graded on the agent half alone, the reason in the
72-
* mode's findings ({@link platformNotMeasuredFindings}). Absent ⇒ none.
78+
* build's own lock, or the build's denial of the write — graded on the
79+
* agent half alone, the reason in the mode's findings
80+
* ({@link platformNotMeasuredFindings}). Absent ⇒ none.
7381
*/
7482
operations?: Tally & { notMeasured: number; platformNotMeasured?: number };
7583
/** The models the half's question and operation turns were served ({@link modelTally}). */
@@ -184,6 +192,19 @@ export function platformNotMeasuredFindings(r: RunHalf | undefined, half: string
184192
});
185193
}
186194

195+
/**
196+
* One Build finding per operation whose grade charged a write to the build's
197+
* denial (`OperationResult.buildDenial`, `buildDeniesWrite`): the build denies
198+
* the acting persona a write the card gives it.
199+
*/
200+
export function buildDenialFindings(r: RunHalf | undefined, half: string): string[] {
201+
return (r?.operations ?? []).flatMap((o) =>
202+
o.buildDenial === undefined
203+
? []
204+
: [`${half}: the build denies ${o.buildDenial.persona} the ${o.buildDenial.verb} on ${o.buildDenial.object} that the card gives it (operation ${o.operation}: its probe of the declared write was refused PERMISSION_DENIED (403))`],
205+
);
206+
}
207+
187208
export function modelTally(r: RunHalf | undefined): ModelTally | undefined {
188209
const turns = [...(r?.questions ?? []), ...(r?.operations ?? [])].flatMap((x) => (x.turn ? [x.turn] : []));
189210
if (turns.length === 0) return undefined;
@@ -261,9 +282,11 @@ export function modeScorecard(m: ModeRun): ModeScorecard {
261282
...m.findings,
262283
...bareNameFindings(m.build, 'build'),
263284
...requiredCycleFindings(m.build, 'build'),
285+
...buildDenialFindings(m.run, 'build'),
264286
...platformNotMeasuredFindings(m.run, 'run'),
265287
...bareNameFindings(m.iterate?.build, 'iterate build'),
266288
...requiredCycleFindings(m.iterate?.build, 'iterate build'),
289+
...buildDenialFindings(m.iterate?.run, 'iterate build'),
267290
...platformNotMeasuredFindings(m.iterate?.run, 'iterate run'),
268291
],
269292
};

‎packages/qa/scenarios/src/schema.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,3 +601,21 @@ export function isProbedOperation(card: Pick<ScenarioCard, 'run'>, operationId:
601601
const op = card.run.operations.find((o) => o.id === operationId);
602602
return op !== undefined && op.outcome.kind === 'refused' && op.kind !== 'delete';
603603
}
604+
605+
/**
606+
* The operations the runner may probe for the build's denial: every `applied`
607+
* create or update (#33596). The card gives the acting persona that write, so
608+
* when the agent's own write met 403 `PERMISSION_DENIED` and nothing was
609+
* written, the runner sends the declared write itself as that persona; a
610+
* probe the door denies as well makes the operation not measured, charged to
611+
* the build (`buildDeniesWrite`). It probes only then: a probe after a write
612+
* that landed would apply it twice and shift the rows later operations read.
613+
* An `applied` `delete` is not probed (the runner sends no delete of its own;
614+
* no card declares one today), and neither is a `pending_confirmation` one:
615+
* the MCP delete door asks for confirmation before it checks permission, so a
616+
* 403 there follows the agent's own `confirm: true` and stays the agent's.
617+
*/
618+
export function probesBuildDenial(card: Pick<ScenarioCard, 'run'>, operationId: string): boolean {
619+
const op = card.run.operations.find((o) => o.id === operationId);
620+
return op !== undefined && op.outcome.kind === 'applied' && op.kind !== 'delete';
621+
}

0 commit comments

Comments
 (0)