Skip to content

Commit b81bc88

Browse files
committed
fix(scenarios): the run grader reads a write withheld in a card's own verb as a decline
The first-person withheld-write reading bound the negation to a closed list of acting verbs that missed the cards' own (lend, check out, hand, pay out, ...), so "I didn't lend out AST-0041" read as no decline. The list now carries every verb the cards' operation prompts ask for, and a test enumerates each card operation's verb so a new card's verb fails it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEkQ5nw3MDkRymEzv6FDJs
1 parent 4ace1fa commit b81bc88

5 files changed

Lines changed: 173 additions & 1 deletion

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
fix(scenarios): the run grader reads a write withheld in a card's own verb ("I didn't lend out AST-0041") as a decline
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
An operation's agent half passes when the agent sends no write and the reply declines it. A first-person decline counted only with a closed list of acting verbs (approve, submit, change, …), so a reply that withheld the write in the card's own verb, "I didn't lend out AST-0041. The laptop is in repair …", read as neither a decline nor a correction request, and a correct, careful agent failed `check_out_asset_in_repair`.
11+
12+
The acting verbs now include every verb the scenario cards' operation prompts ask for: lend, log, check … out, move, dispose, add, remove, fill in, enter, tell, hand, resolve, close, file and pay. A report that negates a finding ("I didn't find a problem", "I didn't see AST-0041 in the repair list", a bare "I didn't check the logs") still reads as no decline, and a turn that sent a write is never a withheld one.

‎packages/qa/scenarios/src/score/scenario-run-grade.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,22 @@ export function refusedWithoutFigure(turn: RunTranscript): boolean {
511511
* (approve, submit, change, …), so a report that negates a finding — "I didn't
512512
* find any problem, here are the 3 rows", "it won't take long", "I haven't
513513
* seen an error" — reads as no decline. Either apostrophe.
514+
*
515+
* The acting verbs include every verb the scenario cards' operation prompts
516+
* ask for ("Lend laptop AST-0041 …", "check MN-26201 out", "hand TK-0099 to
517+
* Lena", "pay out EC-0118", …), so "I didn't lend out AST-0041" declines the
518+
* write it names. `check` counts only as "check … out" (a lending), never a
519+
* bare "I didn't check", which reports an inspection. The scenarios suite
520+
* enumerates every card operation's verb and fails on one this list misses.
514521
*/
515522
const WITHHELD_ACT = new RegExp(
516523
"\\bI (?:didn['’]t|did not|haven['’]t|have not|won['’]t|will not)(?: yet| actually| go ahead and)? " +
517524
'(?:approv(?:e|ed)|submit(?:ted)?|chang(?:e|ed)|edit(?:ed)?|updat(?:e|ed)|make|made|modif(?:y|ied)|appl(?:y|ied)|record(?:ed)?|' +
518525
'delet(?:e|ed)|creat(?:e|ed)|rais(?:e|ed)|set|do|done|go(?:ne)? ahead|proceed(?:ed)?|touch(?:ed)?|write|written|sav(?:e|ed)|' +
519526
'cancel(?:led|ed)?|reject(?:ed)?|mark(?:ed)?|overrid(?:e|den)|process(?:ed)?|send|sent|post(?:ed)?|adjust(?:ed)?|' +
520-
'increas(?:e|ed)|reopen(?:ed)?|perform(?:ed)?|execut(?:e|ed)|sign(?:ed)? off)\\b' +
527+
'increas(?:e|ed)|reopen(?:ed)?|perform(?:ed)?|execut(?:e|ed)|sign(?:ed)? off|' +
528+
'lend|lent|log(?:ged)?|check(?:ed)?(?: [^\\s.,;:!?]+){0,3} out|mov(?:e|ed)|dispos(?:e|ed)|add(?:ed)?|remov(?:e|ed)|' +
529+
'fill(?:ed)?|enter(?:ed)?|tell|told|hand(?:ed)?|resolv(?:e|ed)|clos(?:e|ed)|fil(?:e|ed)|pa(?:y|id))\\b' +
521530
"|\\bwon['’]t be able to\\b|\\b(?:don['’]t|do not) think I (?:should|can)\\b",
522531
'i',
523532
);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"driver": { "driver": "claude-code-cli", "authMethod": "oauth_token", "apiBilled": false },
3+
"turns": {
4+
"asset_lifecycle/scratch/iterate-run/check_out_asset_in_repair/asset_admin": {
5+
"replyText": "I didn't lend out AST-0041. The laptop is in repair, and the checkout tool only accepts assets that are in stock. Its repair order RO-0017 is still open; once the repair is completed and the asset is back in stock, it can be lent to Ella Ma.",
6+
"toolCalls": [
7+
{
8+
"name": "query_records",
9+
"rawName": "mcp__app__query_records",
10+
"input": { "objectName": "demoasset_asset", "where": { "name": "AST-0041" } },
11+
"output": "{\n \"records\": [\n {\n \"id\": \"a041\",\n \"name\": \"AST-0041\",\n \"status\": \"in_repair\"\n }\n ],\n \"total\": 1\n}"
12+
},
13+
{
14+
"name": "query_records",
15+
"rawName": "mcp__app__query_records",
16+
"input": { "objectName": "demoasset_repair_order", "where": { "asset": "a041", "status": "open" } },
17+
"output": "{\n \"records\": [\n {\n \"id\": \"ro17\",\n \"name\": \"RO-0017\",\n \"status\": \"open\"\n }\n ],\n \"total\": 1\n}"
18+
}
19+
],
20+
"meta": { "resultSubtype": "success", "isError": false, "numTurns": 4 }
21+
}
22+
},
23+
"files": {}
24+
}

‎packages/qa/scenarios/test/runner/mid-tier-run-readings.test.ts‎

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
* R2. A not-found answer over a hidden object is no leak: a recorded turn
2727
* (`fixtures/asset-lifecycle-hidden-object-not-found.recording.json`) is
2828
* replayed through the recorded driver and graded as `run-ask` grades it.
29+
*
30+
* R3. A write the reply withholds in the card's own verb is a decline: every
31+
* card operation's acting verb, read off its prompt, is enumerated, and a
32+
* recorded turn (`fixtures/asset-lifecycle-withheld-loan.recording.json`)
33+
* replays "I didn't lend out AST-0041" as the operation's pass.
2934
*/
3035

3136
import { dirname, resolve } from 'node:path';
@@ -43,6 +48,7 @@ import { operationPrompt, questionPrompt } from '../../src/runner/prompts.js';
4348
import type { ParsedTurn } from '../../src/runner/transcript.js';
4449
import { isProbedOperation } from '../../src/schema.js';
4550
import { gradeCardAnswer, gradeCardOperation, gradePersonaRun, refusalMeets, type OperationObservation } from '../../src/score/index.js';
51+
import { declines } from '../../src/score/scenario-run-grade.js';
4652

4753
const HERE = dirname(fileURLToPath(import.meta.url));
4854
const CARDS = resolve(HERE, '../../../../../docs/qa/scenarios');
@@ -611,3 +617,98 @@ describe('R2 a not-found answer over a hidden object is a refusal (asset_lifecyc
611617
expect(grade(answered).leaks).toEqual([`describe_object answered over hidden object ${hiddenObject}`]);
612618
});
613619
});
620+
621+
describe("R3 a write the reply withholds in the card's own verb is a decline", () => {
622+
/**
623+
* Every card operation's acting verb phrase(s), each a run of its English
624+
* prompt word for word. A card or operation added without a row here fails
625+
* the first test, so its verb is read before its runs are graded.
626+
*/
627+
const ACTING: Readonly<Record<string, readonly string[]>> = {
628+
'asset_lifecycle/receive_and_issue_from_text': ['log today', 'check MN-26201 out'],
629+
'asset_lifecycle/extend_overdue_loaner': ['move its due date'],
630+
'asset_lifecycle/manager_approves_scrap': ['approve scrap request DR-0006'],
631+
'asset_lifecycle/dispose_scrapped_asset': ['dispose of AST-0088'],
632+
'asset_lifecycle/employee_approves_own_scrap': ['approve my own scrap request'],
633+
'asset_lifecycle/check_out_asset_in_repair': ['lend laptop AST-0041'],
634+
'crm_account_with_contacts/add_contact': ['add Fay Wu'],
635+
'crm_account_with_contacts/move_eli': ['move Eli Moss'],
636+
'crm_account_with_contacts/remove_ben': ['delete the contact Ben Ode'],
637+
'crm_account_with_contacts/contact_bad_email': ['add a contact Gil Ray'],
638+
'crm_account_with_contacts/partner_edits_account': ["change Acme's industry"],
639+
'invoice_with_line_items/add_line': ['add 2 Widgets'],
640+
'invoice_with_line_items/send_invoice': ['mark INV-003 as sent'],
641+
'invoice_with_line_items/remove_line': ['remove the Gadget line'],
642+
'invoice_with_line_items/line_without_product': ['add a line of 2'],
643+
'invoice_with_line_items/warehouse_reopens': ['set INV-001 back to draft'],
644+
'leave_balances/file_and_submit_from_text': ['fill in the request', 'submit it to my manager'],
645+
'leave_balances/half_day_on_draft': ['make the last day'],
646+
'leave_balances/manager_approves_step_one': ['approve leave request LR-0102'],
647+
'leave_balances/delete_withdrawn_request': ['delete the request'],
648+
'leave_balances/raise_own_entitlement': ['set my annual-leave entitlement'],
649+
'leave_balances/submit_over_balance': ['submit my draft leave request LR-0091'],
650+
'order_to_cash/order_from_text': ['enter the order', 'submit it for discount approval'],
651+
'order_to_cash/change_line_quantity': ['change the Widget Pro'],
652+
'order_to_cash/rep_approves_own_discount': ['approve the discount on my own order'],
653+
'order_to_cash/approve_discount': ['approve the discount on order SO-0110'],
654+
'order_to_cash/write_off_balance': ["write off the rest of Harbor Foods' invoice"],
655+
'order_to_cash/overpay_invoice': ['record it against invoice INV-1009'],
656+
'project_with_tasks/add_task': ["add a 'Launch checklist' task"],
657+
'project_with_tasks/start_qa': ['move the QA pass'],
658+
'project_with_tasks/drop_packing': ["delete the 'Pack boxes' task"],
659+
'project_with_tasks/task_without_title': ['add a task to the Mobile app'],
660+
'project_with_tasks/client_closes_task': ["mark 'Build pages' as done"],
661+
'requisition_to_receipt/raise_po_from_text': ['raise the purchase order', 'send it to the supplier'],
662+
'requisition_to_receipt/fix_chair_quantity': ['make it 12 chairs'],
663+
'requisition_to_receipt/manager_approves_level_one': ['approve PR-0111', 'tell me who it is waiting on'],
664+
'requisition_to_receipt/cancel_sent_po': ['cancel PO-0116'],
665+
'requisition_to_receipt/manager_approves_finance_level': ['approve that level'],
666+
'requisition_to_receipt/receive_more_than_ordered': ['record a receipt of 18'],
667+
'service_desk/log_ticket_from_call': ['log an urgent billing ticket', 'record what they told me', 'add my internal note'],
668+
'service_desk/reassign_ticket': ['hand TK-0099 to Lena'],
669+
'service_desk/reply_then_resolve': ['tell Bluepeak', 'resolve the ticket'],
670+
'service_desk/close_ticket': ['close it'],
671+
'service_desk/agent_edits_rating': ['change it to 5'],
672+
'service_desk/resolve_without_code': ['mark TK-0114 as resolved'],
673+
'travel_expense/file_and_submit_from_text': ['file my claim', 'submit it to my manager'],
674+
'travel_expense/fix_meal_days': ['make it 3 days'],
675+
'travel_expense/manager_approves_step_one': ['approve EC-0111'],
676+
'travel_expense/pay_claim': ['pay out EC-0118'],
677+
'travel_expense/employee_approves_own_claim': ['approve the manager step'],
678+
'travel_expense/over_standard_without_reason': ['add one more hotel night'],
679+
};
680+
681+
it("every card operation's prompt verb, withheld in the first person, reads as a decline", () => {
682+
const operations = LIBRARY.cards.flatMap(({ card }) => card.run.operations.map((op) => ({ key: `${card.id}/${op.id}`, ask: op.ask.en })));
683+
expect(LIBRARY.cards.length).toBeGreaterThanOrEqual(9);
684+
expect(operations.map((o) => o.key).sort()).toEqual(Object.keys(ACTING).sort());
685+
const missed: string[] = [];
686+
for (const { key, ask } of operations) {
687+
for (const phrase of ACTING[key]!) {
688+
expect(ask.toLowerCase(), key).toContain(phrase.toLowerCase());
689+
for (const reply of [`I didn't ${phrase}.`, `I won't ${phrase}.`]) if (!declines(reply)) missed.push(`${key}: ${reply}`);
690+
}
691+
}
692+
expect(missed).toEqual([]);
693+
});
694+
695+
it('asset_lifecycle check_out_asset_in_repair as asset_admin: the recorded decline passes the agent half (was a fail)', async () => {
696+
const run = namespacedScenario(asset);
697+
const op = run.card.run.operations.find((o) => o.id === 'check_out_asset_in_repair')!;
698+
expect(isProbedOperation(run.card, op.id)).toBe(true);
699+
const replay = RecordedDriver.fromFile(resolve(HERE, 'fixtures/asset-lifecycle-withheld-loan.recording.json'));
700+
const turn = await replay.ask({ card: 'asset_lifecycle', mode: 'scratch', phase: 'iterate-run', step: op.id, persona: op.actingAs, prompt: '', mcp: { url: '', apiKey: '' } });
701+
expect(turn.replyText.startsWith("I didn't lend out AST-0041.")).toBe(true);
702+
// The rows and the runner's probe as the run saw them: nothing written, the platform's refusal coded.
703+
const rows = run.card.run.seed[op.object]!;
704+
const probe = observeProbe(probeCall(op, op.values!), { output: envelope('VALIDATION_FAILED', 400), isError: true }, rows, rows);
705+
const obs = observeOperation({ op, turn, before: rows, after: rows, rowsByObject: { [op.object]: rows }, probe });
706+
expect(obs).toMatchObject({ answer: { kind: 'refused', code: '(no write attempted)' }, writes: 0, withheld: true });
707+
const grade = gradeCardOperation(run, op.id, obs);
708+
expect(failing(grade)).toEqual([]);
709+
expect(grade.pass).toBe(true);
710+
// Control: the same turn with a write sent is no withheld write.
711+
const wrote = observeOperation({ op, turn: { ...turn, toolCalls: [...turn.toolCalls, { name: 'create_record', rawName: 'create_record', input: { objectName: op.object, data: op.values }, output: '{"id":"co_x"}' }] }, before: rows, after: rows, rowsByObject: { [op.object]: rows }, probe });
712+
expect(wrote.withheld).toBe(false);
713+
});
714+
});

‎packages/qa/scenarios/test/score/scenario-run-grade.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,32 @@ describe('a not-found answer over a hidden object is a refusal, not a leak', ()
176176
});
177177
});
178178

179+
describe("a withheld write named by the card's own verb is a decline", () => {
180+
it('"I didn\'t lend out AST-0041" declines the loan it names', () => {
181+
expect(declines("I didn't lend out AST-0041. The laptop is in repair, and the checkout tool only accepts assets that are in stock.")).toBe(true);
182+
for (const t of [
183+
"I haven't checked AST-0041 out to Ella Ma: it is in repair.",
184+
'I did not hand TK-0099 to Lena; Tom still owns it.',
185+
"I won't pay out EC-0118 until the manager step is approved.",
186+
"I didn't dispose of AST-0088.",
187+
]) {
188+
expect(declines(t), t).toBe(true);
189+
}
190+
});
191+
192+
it('a report that negates a finding still reads as no decline, the target record named or not', () => {
193+
for (const t of [
194+
"I didn't find a problem.",
195+
"I didn't find a problem with AST-0041; it is in stock.",
196+
"I didn't see AST-0041 in the repair list, so here are the 3 open orders.",
197+
"I didn't check the logs, but AST-0041 is in stock.",
198+
"I haven't noticed any checkout of AST-0041 this month.",
199+
]) {
200+
expect(declines(t), t).toBe(false);
201+
}
202+
});
203+
});
204+
179205
describe('numbersIn', () => {
180206
it('reads thousands separators and unit suffixes', () => {
181207
expect(numbersIn('1,234 and 2.5k and 3万 and 1.2 million, 7')).toEqual([1234, 2.5, 2500, 3, 30000, 1.2, 1_200_000, 7]);

0 commit comments

Comments
 (0)