Repository navigation
Commit f555352
feat(scenarios): the confirm-first line asks the build to lock the change a gated action makes (#36091)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D7UBkcmf1Qy7iEMxarYt8wU)_
Fixes #35908
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 评测场景卡的搭建提示词变了,用户无感:需先确认的操作那一行,现在还要求搭建方把这次改动锁住,只能经该操作改。
- 属于场景卡评测工具;落实维护者「三个问题 同意」里的补充:确认门不扩到直接改记录,所以由搭建方加锁堵住绕行。
- 出错只影响评测跑出的应用:锁错了某人的其他正常改动会被拒,评测分数失真;只改提示词文本,可直接撤回。
- 无
## What changes
`packages/qa/scenarios/src/runner/prompts.ts`: the build contract's line
for each confirm-gated agent action (`run.agentActions[].confirm: true`)
used to end in `(confirm first)` only. The gate
(`ai.requiresConfirmation`) guards the action's own door, and on the
maintainer's ruling it is not widened to `update_record`, so an agent
that met the gate could still write the target state through the raw
data door. The line now also asks the build to lock that change, with
the mechanism the published skills teach (objectstack-ai pitfall "Gating
the action, not the state"; objectstack-data `rules/security.md`,
row-conditioned edit lock):
> (confirm first; the confirmation guards this action’s own door only,
so also lock the change it makes: if it changes fields of its row, make
those fields not editable for each person who runs it, at the stage it
acts on (a field permission `when` in their permission set), and have
the action write them elevated, so a plain record update cannot make
that change while those people’s other changes to the same fields still
land; an action that deletes its row locks nothing, and those people
keep their delete right)
Two limits come from the card audit below, and are why the wording is
not a bare field lock:
1. **Stage-scoped, per person** (a field permission `when`, not
`readonly: true` and not an unconditional field permission). A
whole-field lock on `ticket.status` for the team lead would refuse
`resolve_without_code` with `403 PERMISSION_DENIED` before validation
runs, breaking service_desk's `write_validation` guardrail, which
expects `VALIDATION_FAILED`. `readonly: true` would strip every
non-system write of the field, including the support agent's applied
resolve.
2. **Deletes lock nothing.** Four cards gate a delete action and give
the same persona an applied plain delete of the same object; locking
deletion would deny them.
Lines for actions that are not confirm-gated are unchanged. No card JSON
changes.
## Card audit (the card's ask)
Gated action → the op that exercises it (`pending_confirmation`) → what
the stage-scoped lock covers → the same persona's other operations on
that field.
| Card | Gated action (object) | Runs it | Lock under the new wording |
Same persona's other ops on the field | Verdict |
|:--|:--|:--|:--|:--|:--|
| asset_lifecycle | `dispose_asset` (disposal_request) | asset_admin
(`dispose_scrapped_asset`, dr04 `approved`) | `status`, `disposed_on` at
`approved` | none (asset_admin's applied ops write `asset` and
`checkout`). dept_manager's applied `manager_approves_scrap` writes
`status` too: another persona, its set is not locked | no conflict |
| crm_account_with_contacts | `delete_contact` (contact) | sdr
(`remove_tech_contact`) | nothing: a delete | `remove_ben`: sdr, applied
delete of a contact | no conflict, because the wording exempts deletes |
| invoice_with_line_items | `delete_invoice_line` (invoice_line) |
sales_rep (`remove_inv001_line`) | nothing: a delete | `remove_line`:
sales_rep, applied delete of a line | no conflict, because the wording
exempts deletes |
| leave_balances | `delete_leave_request` (leave_request) | hr_officer
(`delete_zoes_withdrawn_request`) | nothing: a delete |
`delete_withdrawn_request`: hr_officer, applied delete of a request | no
conflict, because the wording exempts deletes |
| order_to_cash | `write_off_balance` (invoice) | ar_clerk
(`write_off_balance`, inv005 `open`) | `status` at the open-balance
stages | none applied. `overpay_invoice` (refused `VALIDATION_FAILED`)
is a `payment` insert, refused before any invoice write | no conflict |
| project_with_tasks | `delete_task` (task) | contractor
(`drop_relaunch_task`) | nothing: a delete | `drop_packing`: contractor,
applied delete of a task | no conflict, because the wording exempts
deletes |
| requisition_to_receipt | `cancel_purchase_order` (purchase_order) |
buyer (`cancel_sent_po`, po116 `sent`) | `status` at `sent` |
`raise_po_from_text` (applied; target state `status: sent`) moves draft
to sent, a different stage. `fix_chair_quantity` writes `po_line` on a
`draft` PO | no conflict, with one hazard: an insert sent straight at
`sent` meets a `when` lock (an insert is judged on the row as sent). The
wording asks that the same people's other changes still land, so the
build routes the raise through draft or an elevated action |
| service_desk | `close_ticket` (ticket) | team_lead (`close_ticket`,
t062 `resolved`) | `status` at `resolved` | `reassign_ticket` (applied)
writes `assignee` only. `resolve_without_code` (refused
`VALIDATION_FAILED`, the `write_validation` guardrail) writes `status`
on t114 at `open`, outside the lock's stage, so validation still answers
| a whole-field lock conflicts; resolved by the stage wording |
| travel_expense | `pay_claim` (expense_claim) | finance_officer
(`pay_claim`, c118 `finance_approved`) | `status`, `paid_on` at
`finance_approved` | none on the card. The finance step's approval moves
the claim at `manager_approved`, a different stage | no conflict |
Result: no card needs an edit. Every conflict is resolved in the prompt
wording: the delete exemption covers crm, invoice, leave and project;
the stage scope covers service_desk and requisition. The PM brief named
three same-persona applied deletes (leave `delete_withdrawn_request`,
crm `remove_ben`, invoice `remove_line`). The audit found a fourth:
project_with_tasks `drop_packing`.
## Tests
- New top-level `describe` in
`packages/qa/scenarios/test/runner/units.test.ts` (the package's prompt
harness):
- service_desk: the confirm-first `close_ticket` line carries the lock,
the stage scope and the delete exemption, and the three plain action
lines carry none of it.
- Across all nine cards, each confirm-gated line asks for the lock and
each plain line does not (9 gated lines counted).
- `pnpm --filter @objectstack/scenarios build && … test && … typecheck`:
Test Files 40 passed (40), Tests 1213 passed (1213), `tsc --noEmit` exit
0. The package tsconfig includes `test/**/*`.
- Ablation: the line restored to ` (confirm first)` through
`scripts/ablation-replace.mjs` (anchor 1 → 0, blob b0cd816 →
582d46117f0c). Result: 2 failed and 77 passed in `units.test.ts`, both
new pins red. Restored: blob equals HEAD and `git diff HEAD` is empty.
The tests import `src/` directly, so no rebuild leg was needed.
## Acceptance notes
- The wording does not name fields or values. The build contract never
states operations or their outcomes (`prompts.ts` header), so the build
reads which fields change, and at which stage, from the action summary
and the app prompt.
- Out of reach of this card: the scorer does not check that the lock
exists. `gradeAgentActions` checks `ai.exposed` and
`ai.requiresConfirmation` only. Whether a build obeys the new line shows
up only in a run's confirm turn.
## Verification
Two-minute check: run `pnpm --filter @objectstack/scenarios exec vitest
run --maxWorkers=2 test/runner/units.test.ts -t "stage-scoped field
lock"`. Expected result: 2 passed.
<details><summary>Dry-run of the build prompt (service_desk,
crm_account_with_contacts): the action section</summary>
```text
== service_desk
Business actions an AI agent may call (expose each to AI; ask before acting where marked):
- `demohelpdesk_log_ticket` on `demohelpdesk_ticket`: Log a ticket for a customer, with its first comment, in the right group's queue.
- `demohelpdesk_reply_to_customer` on `demohelpdesk_ticket_comment`: Post a public reply or an internal note on a ticket, with the minutes spent.
- `demohelpdesk_resolve_ticket` on `demohelpdesk_ticket`: Resolve a ticket with its resolution code; this sends the satisfaction survey.
- `demohelpdesk_close_ticket` on `demohelpdesk_ticket`: Close a resolved ticket for good; irreversible. (confirm first; the confirmation guards this action’s own door only, so also lock the change it makes: if it changes fields of its row, make those fields not editable for each person who runs it, at the stage it acts on (a field permission `when` in their permission set), and have the action write them elevated, so a plain record update cannot make that change while those people’s other changes to the same fields still land; an action that deletes its row locks nothing, and those people keep their delete right)
== crm_account_with_contacts
Business actions an AI agent may call (expose each to AI; ask before acting where marked):
- `democrm_create_contact` on `democrm_contact`: Add a contact, optionally under an account.
- `democrm_reassign_contact` on `democrm_contact`: Move a contact to another account.
- `democrm_delete_contact` on `democrm_contact`: Delete a contact; irreversible. (confirm first; …same line…)
```
</details>
<details><summary>Local gate subset at 274fb5f: 61 derived families,
59 exit 0, 2 NOT MEASURED</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 61 commands. Each was run with its
exit code captured before any pipe. `--ran` reconciliation: "61 derived
famil(ies) accounted for — 59 run, 2 NOT-MEASURED (2 DERIVED from a
recorded exit 3)".
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`, exit 3, PREREQUISITE
NOT MET (reads every package's dist; only the scenarios closure was
built). Left to CI.
- NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs
--self-test`, exit 3 (pinned fixture commit unreachable from a shallow
clone). Left to CI.
- `scripts/pm/overlap-check.mjs` before each push: VERDICT clean exit 0,
0 PR heads overlap.
- Pre-push `check:commit-card-trailers`: 2 commit messages carry no card
relation and no model identifier.
</details>
Files to read first, by risk:
1. `packages/qa/scenarios/src/runner/prompts.ts`: the
`CONFIRM_FIRST_LOCK` text and its docblock. This is the hunk at risk:
the wording decides what every gated build locks.
2. `packages/qa/scenarios/test/runner/units.test.ts`: the new
`describe`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4cypybwgoxE3ZMZy8kt
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent 2b540f4 commit f555352
3 files changed
Lines changed: 77 additions & 1 deletion
File tree
- .changeset
- packages/qa/scenarios
- src/runner
- test/runner
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
423 | 446 | | |
424 | 447 | | |
425 | 448 | | |
| |||
461 | 484 | | |
462 | 485 | | |
463 | 486 | | |
464 | | - | |
| 487 | + | |
465 | 488 | | |
466 | 489 | | |
467 | 490 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
795 | 795 | | |
796 | 796 | | |
797 | 797 | | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
798 | 841 | | |
799 | 842 | | |
800 | 843 | | |
| |||
0 commit comments