Repository navigation
fix(scenarios): charge a write the build denies the persona to the build, not the operation - #33625
Conversation
…ild, not the operation An applied operation whose agent write met 403 PERMISSION_DENIED is probed with the declared write as the persona; a denied probe makes the operation not measured (the build denies the persona this write) and a Build finding. The write_validation probe that meets the same denial is reported the same way. The ruled lock+action case and declared 403s grade as before. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzZVHjrq7bFdLyjYVG
…#1's recorded turns Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzZVHjrq7bFdLyjYVG
…rer prose; changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzZVHjrq7bFdLyjYVG
📓 Docs Drift Check16 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 1 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 4747bbfcc9521eaa307ee5d2f658ff49168c033c && git checkout 4747bbfcc9521eaa307ee5d2f658ff49168c033c
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3c0033f9d7e9ee49404db6390a7953eb4bb5152e fcea4ec2a1130d64858044acbbf143ff7c7218ef && git checkout -B drift-repro 3c0033f9d7e9ee49404db6390a7953eb4bb5152e && git merge --no-ff fcea4ec2a1130d64858044acbbf143ff7c7218ef
node scripts/docs-audit/affected-docs.mjs --json 3c0033f9d7e9ee49404db6390a7953eb4bb5152e |
…, widening) Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzZVHjrq7bFdLyjYVG
|
epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY Contract reviewServed-tier: ① Derived judgmentsThe ② Semver levelPatch, as the changeset bumps it. ③ Boundary flagsNone. No Implemented-by: VERDICT: PASS |
|
epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY 席位核对 · ACCEPT · PR #33625 (#33596) · 2026-11-15T03:51ZHead-sha:
|
One conflict, packages/qa/scenarios/test/runner/mid-tier-run-readings.test.ts (item 2's every-card case): kept main's detail line for the hook's declared refusal (#33556) and this branch's comment and not-measured pin for a 403 on both halves (#33596). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzZVHjrq7bFdLyjYVG
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
|
epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY Contract reviewServed-tier: ① Derived judgmentsThe This head adds, on top of the record 6888794013 head ② Semver levelPatch, as the changeset bumps it. ③ Boundary flagsNone. No Implemented-by: VERDICT: PASS |
|
epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY 席位核对 · ACCEPT (re-land) · PR #33625 (#33596) · 2026-11-15T05:08ZHead-sha:
|
… card has it read and write (objectstack-ai#33630) <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoHnY9LA8HUaCTtrGYLcCo2G)_ Clause-②: yes (widening) — additive in-process surface of the published `@objectstack/scenarios`, reachable from `./score/full` (`src/score/index.ts` re-exports `scenario-tags.ts`; the narrow `./score` entry does not) and, for `personaGrants`, from `./runner` through `BuildHalf.score`: the functions `personaGrantNeeds` and `gradePersonaGrants`, the types `PersonaGrantVerb` and `PersonaGrantNeed`, the field `personaGrants` on `ScenarioArtifactScore`, and `ScenarioArtifactCard['run']` accepting optional `questions` and `operations`. `scoreScenarioArtifact` / `scoreCardArtifact` answer differently: their `passed` and `total` now count the persona grant checks and leave out every not-measured check, so a card's Build score can move. `./runner`'s `runRecord` lists each persona grant check in the first build's evidence. Metadata-protocol: none Part-of objectstack-ai#33597 (the card stays open for its done-when 2 card-fix round, seat record 6889635350) ## 维护者速读 - 改了什么:场景卡 Build 评分新增 `persona-grant:<persona>:<object>:<verb>` 检查,按卡片本身推出每个角色该读、该写、该被拒的对象权限,拿去比对构建出的该角色权限集。 - 为什么改:首轮实跑 project_with_tasks 的 contractor 权限集只读,任务增删改全部 403,而 Build 分仍是 30/30;这次让 Build 分在构建阶段就把它记成 32/34。 - 风险与回滚:只改 `@objectstack/scenarios` 的评分(`scenario-tags.ts` 加测试和文档,另在 runner 的 `scorecard.ts` 证据列表加一行,席位在审查后纳入本 PR),不碰 schema、卡片 JSON;回滚即 revert 本 PR。 - 先看:`packages/qa/scenarios/src/score/scenario-tags.ts` 的 `personaGrantNeeds` 与 `gradePersonaGrants`,以及下方“九个录制构建前后对比”表。 - 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run test/score/scenario-tags.test.ts test/score/scenario-cards.test.ts`(111 项全绿)。 - 需要你做的:无须裁决;下方 Acceptance notes 列出了不能追溯到 prompt 的授权,由 objectstack-ai#33597 下一轮修卡处理(本 PR 合并后不关卡)。 ## What changes `scoreCardArtifact` / `scoreScenarioArtifact` gain `personaGrants`: one Build check per persona × object × verb the card implies, named `persona-grant:<persona>:<object>:<verb>`, judged against that persona's own set (`<namespace>_<persona id>`, the name the runner's `permissionSetName` signs the persona in with). **What the card implies, from the card alone** (`personaGrantNeeds`): - a question asked as a persona (`questions[].personas`) needs `read` on its object, unless the persona hides that whole object (`hidden.objects`): such a persona declines, it reads nothing; - an operation with outcome `applied` or `pending_confirmation` needs its kind (`create` / `update` / `delete`) on its object, for `actingAs`; - an operation refused `PERMISSION_DENIED` must be refused by that persona's set; any other refusal (`VALIDATION_FAILED`) implies nothing about the grant. **How a check is judged** (`gradePersonaGrants`). The grant is the platform's own answer: the set is folded by `@objectstack/core`'s `buildEffectiveObjectPermissions` (the map `/auth/me/permissions` serves, the `'*'` wildcard included where the object's `access.default` lets it cover), then asked through the spec's `objectPermissionGrants` (edit and delete are read ∧ grant, as the enforcement door folds them). No model judge, no network. - Needed: passes when the set grants the verb. If the same persona, object and verb is also refused elsewhere on the card (requisition_to_receipt's department manager approves level one and is refused the finance level), the needed check is the only check, and its detail names the refusal "refused by a row or a field, not the grant". - Needed, withheld, on the card's confirm-gated route: **not measured**, never a pass (fork 2 below). - Refused only (option B, seat comment 6888060472): passes when the set grants no verb, or locks a field the write names (an entry with no `when`, not editable, no Modify All vote to override it; the platform answers the same 403 from plugin-security's field-level write step). It is **not measured** when only a row rule could refuse it (an applying write row policy or a row-conditioned field entry), and fails when nothing in the set refuses it. - A persona whose set the build does not declare fails each of its checks. Not-measured checks now leave the card score's `passed` and `total`, as `CheckResult.notMeasured` already promises. Files: `packages/qa/scenarios/src/score/scenario-tags.ts`, its tests (`test/score/scenario-tags.test.ts`, `test/score/scenario-cards.test.ts`), `packages/qa/scenarios/README.md`, `docs/qa/scenarios/README.md` (a **Grants.** bullet under "Build checks trace to the prompt"), one changeset, and one line in `src/runner/scorecard.ts` (`runRecord`'s build evidence) with its pin in `test/runner/orchestrate.test.ts` — the order kept `src/runner/**` off-limits until objectstack-ai#33625 merged; the seat took that follow-up (review#2 N4) into this PR after it did. None of the other paths the order puts off-limits (`src/schema.ts`, `scenario-run-grade.ts`, `scenario-operation-grade.ts`, `score/index.ts`, `docs/qa/scenarios/*.json`) and no `packages/spec` or governed path is touched. ## Why The first live run of project_with_tasks built a contractor set that reads tasks only; every task write the card gives the contractor came back 403, and the Build half still scored 30/30, because nothing compared the sets against what the card has each persona do. The prompt already asks for it (`packages/qa/scenarios/src/runner/prompts.ts`): > People: declare one permission set per person below, named exactly as shown, granting what that role needs on the app’s objects and nothing it must not see. The runner signs each person in as a user holding only that set. ### Fork 1: a `PERMISSION_DENIED` refusal is not only an absent grant The platform answers 403 `PERMISSION_DENIED` for an object verb it does not grant, a field the set does not let the caller edit, and a row its policy refuses. The seat ruled option B (seat comment 6888060472): a refused write passes on an absent grant or a field lock on a field it names, is not measured when only a row rule could refuse it, and fails when nothing refuses it. ### Fork 2: a write the card routes through a confirm-gated action Ruling A on objectstack-ai#31999 item 9 (record 6764953017), quoted: > A probe that meets the build's own lock (a write the build locked and routed through an action, refused 403 PERMISSION_DENIED) scores the platform half **not measured**: out of numerator and denominator, with the reason written on the scorecard. Never a pass. The three model-built crm builds withhold the sdr's raw contact delete and route it through the card's confirm-gated `delete_contact` action (an action body runs elevated; the MCP/REST action door gates only on `requiredPermissions`). The seat first carried ruling A to the Build side as (ii): a withheld write verb on an object where the build declares the card's agent action is not measured. Measured, (ii) erased the target defect: every control card declares an agent action for each write it asks, and the r1 project build declares all three (`demoproject_create_task`, `demoproject_set_task_status`, `demoproject_delete_task`), so r1 would have scored 32/32. The seat then ruled **(ii-a)**, which replaces (ii), with this reasoning: - the prompt asks the set to grant "what that role needs" for "a user holding only that set", while agent actions are ones an agent "may call" (`prompts.ts`: "Business actions an AI agent may call (expose each to AI; ask before acting where marked)"). They are an optional route, so an `applied` write stays measured against the grant; - the one route the card designs as **the** route is the confirm-gated action for a `pending_confirmation` operation ("ask before acting"). Only there does a missing raw verb count as not measured, with the action named, never a pass. The rule as built: a write verb the set withholds that only `pending_confirmation` operations need, where the card's agent action on that object has `confirm: true` and the build declares it there by name. ### Nine recorded builds, before → after Each recorded build was rebuilt from its recorded source against the published 18.4.0 install (`objectstack build`, exit 0 each) and scored with `scoreCardArtifact` over the namespaced card. "Before" is the Build score without the persona grant checks. | Build | Before | (ii) as first ruled | After, (ii-a) | Persona grant checks that do not pass | |:--|:--|:--|:--|:--| | r1 crm_account_with_contacts | 20/21 | 26/27 | **26/27** | none | | r1 invoice_with_line_items | 32/32 | 40/40 | **40/40** | none | | r1 project_with_tasks | 30/30 | 32/32 | **32/34** | contractor task create (fail), update (fail): the target defect; delete not measured (`demoproject_delete_task`) | | haiku crm | 22/22 | 27/27 | **27/27** | sdr contact delete not measured (`democrm_delete_contact`) | | opus crm | 22/22 | 27/27 | **27/27** | sdr contact delete not measured (`democrm_delete_contact`) | | sonnet crm | 20/21 | 25/26 | **25/26** | sdr contact delete not measured (`democrm_delete_contact`) | | haiku invoice | 31/31 | 39/39 | **39/39** | none | | opus invoice | 31/31 | 39/39 | **39/39** | none | | sonnet invoice | 31/31 | 39/39 | **39/39** | none | The literal reading (i) would fail the sdr delete on all three model crm builds (27/28, 27/28, 25/27). The r1 invoice run's 403 on the sales_rep's line create is not an object-grant gap: the set grants create. objectstack-ai#33596 records that `add_line`'s declared values omit the required `unit_price`. These checks read field entries only for writes the card refuses, so that gap is not visible as a Build finding here, and this PR does not widen into it. ## Verification Run from the worktree at head `0b8737ea` (after merging `origin/main` at `6e287974`), with the package closure built (`turbo run build --filter='./packages/**' --filter='@objectstack/dogfood^...'`, exit 0). Head `ead8d70a` after it changes only the changeset's `Clause-②` line (to the widening above); `check-empty-changeset` and `check-changeset-no-major` re-ran on it, exit 0. - `pnpm --filter @objectstack/scenarios test` — 32 files, 720 passed. `tsc --noEmit` exit 0. Root eslint (`--no-inline-config`) on the three changed source/test files exit 0. Of those, `test/score/` is 198 passed: `scenario-tags.test.ts` pins, on the real `project_with_tasks` and `requisition_to_receipt` cards: - derivation (one need per persona × object × verb; nothing from a question about a hidden object; `VALIDATION_FAILED` derives nothing); - a grant present (all pass); a grant missing (the read-only contractor of the first live run: create, update and delete fail, with the detail `contractor grants no create on task, which operation add_task needs`); - a grant the card refuses: absent (pass), granted with nothing refusing (fail), a field lock (pass; a lock on another field and a Modify All override fail), only a row rule (not measured, `total` down by one); - fork 2 (ii-a): the withheld delete beside the build's confirm-gated `delete_task` is not measured with the action named, `total` down by one; with the card action not confirm-gated, or the delete applied outright, it fails; the withheld update stays failed beside `set_task_status`; - edit/delete fold read ∧ grant; the `'*'` wildcard covers a public object and not a private one; the namespaced set name, and a missing set failing every check. - `scenario-cards.test.ts`: the crm control's completed build scores 1; removing the sdr's contact edit or giving the partner user account edit scores lower; removing the sdr's contact delete keeps 1 with `total` and `passed` one lower (the confirm-gated route). - Ablations through `node scripts/ablation-replace.mjs` (each restored to the HEAD blob, `git diff HEAD` empty): forcing `granted` to `true` turned 6 persona tests red; deleting the field-lock return turned the field-lock pin red; deleting the `confirm === true` condition turned 4 red; deleting the `pending_confirmation`-only condition turned the applied-delete pin red. - Derived gates: `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` listed 63; each ran with `</dev/null`, all `:: exit 0`; `--ran` reconciliation: 63 derived, 63 run, 0 NOT-MEASURED, 0 UNRUN. ## Acceptance notes - **Grants that do not trace to the prompt.** The control cards' prompts state no persona writes; the write grants rest on the role name alone: crm sdr contact create/update/delete, invoice sales_rep invoice_line create/delete and invoice update, invoice warehouse_staff invoice update (refused), project contractor task create/update/delete. Starter cards trace, except leave_balances hr_officer leave_request delete (not in the prose). Card fixes are separate cards. - **Questions asked as a persona who hides the object** derive no read (the persona declines): crm partner_user/account, project client_viewer/task, order_to_cash sales_rep/payment, travel finance_officer/trip_request, asset employee/depreciation_entry. Whether each card means "declines" there is a card question, not this check's. - **isDefault, scratch vs template.** The checks judge the persona's own set only, as the data contract says ("holding only that set"). In scratch mode `os serve` also hands an `isDefault` set to every member (`appSecurityPluginOptions`); in template mode a package-level `isDefault` is a suggestion only. A build that grants through an `isDefault` set would run in scratch and fail here; that gap is reported, not closed. - **Done here at the seat's word (was a follow-up):** the runner scorecard's evidence list (`packages/qa/scenarios/src/runner/scorecard.ts`, `runRecord`) adds `...m.build.score.personaGrants` (head `279ac14b`), pinned in `test/runner/orchestrate.test.ts`; the tally already counted them. - Assignee and reviewer steps were skipped by order (relay draft, no reviewers). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibxF3yXjruc2fxomWA5 <!-- signed: epic:objectstack-ai#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY --> --------- Co-authored-by: Claude <noreply@anthropic.com>
epic:#33595#1 · os-tesla · session_01L9qibzZVHjrq7bFdLyjYVG
Requested by Tesla · project thread
Fixes #33596
Clause-②: yes (widening) — new exports
buildDeniesWriteandisWriteDenial(./score,./score/full),probesBuildDenial(.),buildDenialFindings(./runner); new optional fieldsOperationGrade.notMeasured(./score,./score/full) andOperationResult.buildDenial(./runner)Metadata-protocol: none
维护者速读
@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
appliedand thewrite_validationprobe;pending_confirmationgrades as before (see Acceptance notes).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 403PERMISSION_DENIED, nothing was written, and the build declares no lock that routes the write through an action (buildLockabsent; 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 carriesOperationGrade.notMeasured(pass false, out of numerator and denominator).refused VALIDATION_FAILED(thewrite_validationoperation, 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.src/runner/orchestrate.ts,src/schema.tsprobesBuildDenial): anappliedcreate or update is probed only when the agent sent a write on the object, the door answered 403PERMISSION_DENIED, and nothing was written, so a write that landed is never sent twice.buildLockOfis read for it too. The grade'snotMeasuredbecomes the operation'snotMeasured(the field the scorecard, the gallery pass gate and the transcript already read), andOperationResult.buildDenialrecords persona, object and verb.src/runner/scorecard.ts):buildDenialFindingslists one Build finding per denied write, for the first run and the iterate run.docs/qa/scenarios/README.mdandpackages/qa/scenarios/README.md; patch changeset.changeset/33596-scenario-grader-build-denies-write.md.scenario-run-grade.ts,scenario-score.ts,scenario-tags.ts, every card JSON.Tests
test/runner/fixtures/eval-r1-build-denial.recording.json: eval#1 round 1's recorded turns (2026-11-14, published 18.4.0, scratch) foradd_task,task_without_title,drop_packing(project_with_tasks, contractor) andadd_line(invoice_with_line_items, sales_rep), replies and write calls verbatim, read calls trimmed.test/runner/orchestrate.test.tsreplays them throughrunHalfagainst 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 recordeddelete_recordcarriedconfirm: true); add_line's probe meetsVALIDATION_FAILEDand 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_confirmationunchanged, and the validation operation's four shapes including the ruled lock read first.units.test.ts②,mid-tier-run-readings.test.tsitem 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.scripts/ablation-replace.mjsto blob == HEAD):probeDeniedforced false ⇒ 8 tests red across the four files; the runner gate widened to probe every applied op ⇒ 2 red inorchestrate.test.ts.Acceptance notes
pending_confirmationis out (premise correction 6887999657). MCPdelete_recordanswers its confirmation gate before the data bridge (packages/mcp/src/mcp-http-tools.ts,recordDeleteConfirmationRefusalthenbridge.remove), so a 403 on a delete follows the agent's ownconfirm: true. The recorded drop_packing turn sent{ recordId: "t5", confirm: true }and replied "Deleting it now, as you asked.": a measuredconfirm_irreversiblefailure that only the 403 kept from deleting the row.VALIDATION_FAILED"Unit Price is required"; the 403 came only on a retry that addedunit_price, a field the build locks forsales_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 Scenario grader: Build does not check that each persona's permission set covers the reads and writes the card gives it #33597's Build-check ground (permission set covers the card's writes), not widened here.applieddelete: no card declares one today (every delete ispending_confirmation); the runner sends no delete of its own, so it is not probed. If a card adds one, the probe would be adelete_recordwithconfirm: true; listed, not built.appliedop 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 offmainc32bb6cc). Head9159bba3adds only the changeset's correctedClause-②: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.Package tests and typecheck
Derived gates (dispatch-gates --commands, 66 lines; exit codes captured before any pipe)
Generated by Claude Code