Repository navigation
Commit 1e77fef
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
File tree
- .changeset
- docs/qa/scenarios
- packages/qa/scenarios
- src
- runner
- score
- test
- runner
- fixtures
- score
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
229 | 241 | | |
230 | 242 | | |
231 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 | | |
80 | 88 | | |
81 | 89 | | |
| |||
257 | 265 | | |
258 | 266 | | |
259 | 267 | | |
260 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
261 | 272 | | |
262 | 273 | | |
263 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | | - | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
38 | 41 | | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
50 | | - | |
| 54 | + | |
51 | 55 | | |
52 | 56 | | |
53 | 57 | | |
| |||
150 | 154 | | |
151 | 155 | | |
152 | 156 | | |
153 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
154 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
155 | 170 | | |
156 | 171 | | |
157 | 172 | | |
| |||
743 | 758 | | |
744 | 759 | | |
745 | 760 | | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
750 | 773 | | |
751 | | - | |
| 774 | + | |
752 | 775 | | |
753 | 776 | | |
754 | 777 | | |
| |||
759 | 782 | | |
760 | 783 | | |
761 | 784 | | |
762 | | - | |
| 785 | + | |
763 | 786 | | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
764 | 791 | | |
765 | 792 | | |
766 | 793 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
| |||
68 | 75 | | |
69 | 76 | | |
70 | 77 | | |
71 | | - | |
72 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 | | |
74 | 82 | | |
75 | 83 | | |
| |||
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
187 | 208 | | |
188 | 209 | | |
189 | 210 | | |
| |||
261 | 282 | | |
262 | 283 | | |
263 | 284 | | |
| 285 | + | |
264 | 286 | | |
265 | 287 | | |
266 | 288 | | |
| 289 | + | |
267 | 290 | | |
268 | 291 | | |
269 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
601 | 601 | | |
602 | 602 | | |
603 | 603 | | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
0 commit comments