Skip to content

fix(scenarios): charge a write the build denies the persona to the build, not the operation - #33625

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-dkbsgf
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/project-thread-dkbsgf

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

epic:#33595#1 · os-tesla · session_01L9qibzZVHjrq7bFdLyjYVG

Requested by Tesla · project thread

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 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.
  • 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 Eval scoring v2: attribute scenario-card losses to the right owner, then compare haiku / sonnet / opus #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.

Package tests and typecheck
head 5a673b52 (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
Derived gates (dispatch-gates --commands, 66 lines; exit codes captured before any pipe)
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

Generated by Claude Code

…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
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

16 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/qa/scenarios/README.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/qa/scenarios/README.md) — pages documenting those are invisible to this run
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 1 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 3c0033f9d7e9ee49404db6390a7953eb4bb5152e → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4747bbfcc9521eaa307ee5d2f658ff49168c033c — the merge of head fcea4ec2a1130d64858044acbbf143ff7c7218ef into base 3c0033f9d7e9ee49404db6390a7953eb4bb5152e, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# 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

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 9159bba3b1bc115edd3bf25cd3406d4e7e55907e
Local-runs: none

① Derived judgments

The Clause-②: yes (widening) line on the PR body and changeset is true and complete against the diff: buildDeniesWrite and isWriteDenial (src/score/scenario-operation-grade.ts) and buildDenialFindings (src/runner/scorecard.ts) are new exported names, probesBuildDenial is new in src/schema.ts, and OperationGrade.notMeasured / OperationResult.buildDenial are new optional fields; every one is additive. The one answer that moves is declared in the changeset: an applied operation whose agent write and the runner's probe both met 403 PERMISSION_DENIED with nothing written, and no routed lock, now grades not measured instead of failed; the write_validation probe's no-lock 403 moves the same way (card #33596 done-when 2, premise correction 6887999657 on its pending_confirmation half). Ruling A on #31999 item 9 (record 6764953017) is untouched: probeDenied requires buildLock absent and the ruled lock pins are unchanged.

② Semver level

Patch, as the changeset bumps it. Metadata-protocol: none holds: nothing a metadata author writes (spec, app metadata) is added, narrowed or changed in meaning; the widening is additive exports of the evaluation package @objectstack/scenarios and no existing export is removed, renamed or narrowed in type.

③ Boundary flags

None. No packages/spec/src/**, no governed path, no runtime or security behaviour: the new probe is sent by the evaluation runner as the card's persona against the throwaway app it boots, only after the agent's own write met 403 with nothing written, so a landed write is never re-sent. The scorer stays deterministic (cloud#3600 cost ruling).

Implemented-by: claude/project-thread-dkbsgf
Reviewed-by: session_01L9qiby1cctpVpRbJzjccvY

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY

席位核对 · ACCEPT · PR #33625 (#33596) · 2026-11-15T03:51Z

Head-sha: 9159bba3b1bc115edd3bf25cd3406d4e7e55907e · report 6888449572 · claim 6887957030 (Clause-② corrected 6888513806) · premise correction 6887999657 · contract review 6888794013 PASS

  • Form: draft → main, body opens with the attribution block then Fixes #33596 (the card's corrected done-when is met in full: the applied case and the write_validation probe; pending_confirmation out per 6887999657). No closing keyword beside another open card. 13 files (the review-round commit on 5a673b52 changes the changeset only), all inside the claimed surface: src/runner/{orchestrate,scorecard}.ts, src/schema.ts, src/score/scenario-operation-grade.ts, tests + one recorded fixture, the two scorer READMEs, .changeset/33596-scenario-grader-build-denies-write.md. Off-limits files (scenario-run-grade.ts, scenario-score.ts, scenario-tags.ts, card JSON) untouched.
  • Premise measured: on 4bba8b8f the seat read isProbedOperation (refused create/update only) and buildLockOf (lock + declared action only); the thread's fixture replays eval#1 round 1's recorded add_task / task_without_title / drop_packing / add_line turns verbatim.
  • Diff read (seat): ① the applied probe is gated on the agent's own write on the object meeting 403 PERMISSION_DENIED with zero writes (agentDenied), so a landed write is never re-sent; ② probeDenied requires buildLock absent, so ruling A's lock + action case (record 6764953017) keeps its own reason and is read first — the R1.8 lock pins are unchanged; ③ a grade with every check not measured returns notMeasured, pass: false, never a pass; ④ buildDenialFindings lists one Build finding per denied write for the first and the iterate run. Re-pinned on purpose, all four the card's done-when 2 asks for: a no-lock probe 403 on the validation operation moves from the platform's measured fail to "the build denies the persona this write"; the status-less denial, the probe that wrote, and the other-answer controls stay measured fails.
  • Gates: check-runs at this head: 55 — 37 success, 18 skipped, 0 other (read this act; Lint & Repo Gates and TypeScript Type Check success); mergeable_state clean. Local: package 720/720, typecheck 0, dispatch-gates 65/66 with check:dual-build-cjs-loads NOT MEASURED locally (needs every package's dist; CI's Lint & Repo Gates covers it). Two ablations red (probeDenied forced false ⇒ 8 red; probe on every applied op ⇒ 2 red), restored.
  • Contract review: the declaration face alone (no packages/spec/src/**, no governed path, no (narrowing) arm; Clause-②: yes (widening) for new exports of the published @objectstack/scenarios): record 6888794013, TIER_DEFAULT, PASS at this head. The claim's original no was the seat's error, corrected on the card (6888513806) and in the PR body and changeset.
  • Changeset read sentence by sentence against the diff: the summary line; "counted as the operation's failure … landed on the asking side" (old applied path); "The runner now sends … only when the agent's own write … was denied 403 and nothing was written" (matches agentDenied + probesBuildDenial); "out of passed and total, and the scorecard lists a Build finding" (matches notMeasured + buildDenialFindings); "The write_validation probe … reported the same way" (matches probeChecks branch); "A 403 the card declares … and a pending_confirmation operation grade as before, and the probe that meets the build's routed lock keeps its own not-measured reason" (matches). All hold.
  • 维护者速读: line 3 corrected by the thread at this seat's review (the package is published, the change additive); the six lines match the diff.
  • Accepted deviations: none beyond the seat's premise correction 6887999657.
  • Out-of-scope findings: add_line (a required unit_price the build locks for sales_rep) → Acceptance notes, Build-check ground of sibling Scenario grader: Build does not check that each persona's permission set covers the reads and writes the card gives it #33597; an applied delete (no card declares one) → Acceptance notes; probe state impact → M3 row "restore the seed before each operation" on Eval scoring v2: attribute scenario-card losses to the right owner, then compare haiku / sonnet / opus #33595 (carrier); lock + action on an applied op stays the agent's (ruling A's routing reading) → Acceptance notes.
  • Landing: K = 4 (git rev-list --count --first-parent 41b64bb0..origin/main, PRBASE = Test Core's printed Affected-set diff base); no locale pack. Landed on the maintainer's standing word 「按 pm-dispatch 审过的pr你可以自主落地」 (2026-10-30 14:20Z, spec seat 2 thread): pr_ready + automerge_enable in this stroke.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 15, 2026 03:52
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 15, 2026
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
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY

Contract review

Served-tier: TIER_DEFAULT
Head-sha: fcea4ec2a1130d64858044acbbf143ff7c7218ef
Local-runs: none

① Derived judgments

The Clause-②: yes (widening) line on the PR body and changeset is true and complete against the diff: buildDeniesWrite and isWriteDenial (src/score/scenario-operation-grade.ts) and buildDenialFindings (src/runner/scorecard.ts) are new exported names, probesBuildDenial is new in src/schema.ts, and OperationGrade.notMeasured / OperationResult.buildDenial are new optional fields; every one is additive. The one answer that moves is declared in the changeset: an applied operation whose agent write and the runner's probe both met 403 PERMISSION_DENIED with nothing written, and no routed lock, now grades not measured instead of failed; the write_validation probe's no-lock 403 moves the same way (card #33596 done-when 2, premise correction 6887999657 on its pending_confirmation half). Ruling A on #31999 item 9 (record 6764953017) is untouched: probeDenied requires buildLock absent and the ruled lock pins are unchanged.

This head adds, on top of the record 6888794013 head 9159bba3, a merge of origin/main 3c0033f9 (d1f74ece: one test-file conflict resolved keeping both sides) and fcea4ec2: isWriteDenial now also requires no declaredCode, so a hook's own refusal served at 403 after #33556 is graded as the app's rule (both halves measured) and never as the build's denial; the changeset says so in one added sentence. No export or type is added or changed.

② Semver level

Patch, as the changeset bumps it. Metadata-protocol: none holds: nothing a metadata author writes (spec, app metadata) is added, narrowed or changed in meaning; the widening is additive exports of the evaluation package @objectstack/scenarios and no existing export is removed, renamed or narrowed in type.

③ Boundary flags

None. No packages/spec/src/**, no governed path, no runtime or security behaviour: the new probe is sent by the evaluation runner as the card's persona against the throwaway app it boots, only after the agent's own write met 403 with nothing written, so a landed write is never re-sent. The scorer stays deterministic (cloud#3600 cost ruling).

Implemented-by: claude/project-thread-dkbsgf
Reviewed-by: session_01L9qiby1cctpVpRbJzjccvY

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

epic:#33595#1 · os-tesla · session_01L9qiby1cctpVpRbJzjccvY

席位核对 · ACCEPT (re-land) · PR #33625 (#33596) · 2026-11-15T05:08Z

Head-sha: fcea4ec2a1130d64858044acbbf143ff7c7218ef · supersedes ACCEPT 6888802552 (head 9159bba3) for the delta only; that record's form, premise, diff read and changeset read stand · contract review 6889562294 PASS at this head

  • Why re-land: the merge queue removed the PR at 04:45Z with MERGE_CONFLICT (test/runner/mid-tier-run-readings.test.ts against main's e4113887, fix(scenarios): the run grader reads a hook's declared refusal off the door's declaredCode #33556).
  • Delta read (seat): ① d1f74ece merges origin/main 3c0033f9 (no rebase); the one conflict keeps main's detail line for the hook's declared refusal and this PR's not-measured pin for a 403 on both halves; the READMEs auto-merged. ② fcea4ec2: isWriteDenial also requires kind: 'refused' with no declaredCode. After fix(scenarios): the run grader reads a hook's declared refusal off the door's declaredCode #33556 a hook's own refusal at 403 carries its code there; it is the app's rule, so it is graded measured on both halves and never charged to the build. The guard also reaches the agent-side gate (orchestrate.ts agentDenied), so such a refusal sends no probe. One test pins a validation op (passes, measured) and an applied op (fails, measured); ablating the guard reds 2 (thread). One changeset sentence added, matching. No export or type change; Clause-② line unchanged.
  • Gates: check-runs at this head: 51 — 35 success, 16 skipped, 0 other (read this act; Lint & Repo Gates and TypeScript Type Check success); mergeable_state clean. Local (thread): package 731/731, typecheck 0.
  • Accepted deviations: the PR body's Verification line names the old head 9159bba3; this record names the landed head instead of a body patch.
  • Landing: K = 7 (git rev-list --count --first-parent 3c0033f9..origin/main, PRBASE = Test Core's printed Affected-set diff base); no locale pack. Landed on the maintainer's standing word 「按 pm-dispatch 审过的pr你可以自主落地」 (2026-10-30 14:20Z, spec seat 2 thread): automerge_enable in this stroke.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 1e77fef Nov 15, 2026
51 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-dkbsgf branch November 15, 2026 05:29
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
… 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scenario grader: a 403 on an operation whose declared outcome is applied is charged to the operation, not to the build that denied it

2 participants