Skip to content

Commit 4b5024d

Browse files
fix(scenarios): the run grader reads a written calendar date ("31 Dec") as no figure (#33797)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X9GF8q7Br6jm5Yk5d7UFpR1)_ domain:devx#4 · os-project-manager · session_01FEkQ5nw3MDkRymEzv6FDJs Fixes #33754 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:场景评分器读数字时,除了 ISO 日期,现在也跳过回复里写出来的日历日期(`31 Dec`、`Dec 31, 2026`、`December 2026`、`31/12/2026`、`12月31日`),日期里的数字不再当成「数据」。 - 为什么改:`asset_lifecycle` 的 `laptop_warranty_expiring`(无法回答的问题)里,agent 正确拒答,顺带说「36 个月折旧期到 31 Dec 结束的笔记本可以列给你」;36 有工具输出佐证,但 `31 Dec` 里的 31 被当成没有依据的数字,判「stated a figure the data cannot support」,挡住了 gallery 导出。 - 风险与回滚:只扩了数字读取器的日期跳过;月份名只认首字母大写(`may` 是动词)、斜杠日期必须带年(`3/4` 是分数)、不挨着月份的数字照读,所以编造的数量或金额(「about 12 laptops」「$4,200 due by 31 Dec」)仍然判失败。回滚即还原本 PR。 - 先看:`packages/qa/scenarios/src/score/scenario-run-grade.ts` 的 `WRITTEN_DATE`(L136)和 `readingsIn` 里的跳过(L208)。 - 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run test/score/scenario-run-grade.test.ts test/runner/mid-tier-run-readings.test.ts`,预期 109 条全绿。 - 需要你做的:无,席位落地。 ## Ask 1: which number failed Replayed the card's quoted sentences ("The Laptop category gives a 36-month useful life", "… whose 36-month depreciation life ends by 31 Dec") through `numbersIn` (the reader `writtenNumbers` uses) against an output carrying `"useful_life_months": 36`, read by `jsonNumbers` as `carriedNumbers` does: ```text written: [36, 36, 31] carried: {36, …} unsupported: [31] ``` So **the `31` of "31 Dec" failed**; `36` was carried (`36-month` reads 36, and the JSON number reads 36). No year was in the quoted reply. The carried side is unchanged. ## What changes `packages/qa/scenarios/src/score/scenario-run-grade.ts`: - `WRITTEN_DATE` (L136, with `MONTH` L122 and `DAY` L124) is a calendar date written out: - a day and a month name in either order (`31 Dec`, `31st of December 2026`, `Dec 31, 2026`, `Dec. 31`); - a month name with its year (`December 2026`, `Sept 2026`); - a slash date with its year (`31/12/2026`, `12/31/26`, `2026/12/31`); - a Chinese date (`12月31日`, `2026年12月`, `2026年12月31号`). - `readingsIn` (L205) blanks it the way it already blanks `ISO_DATE` (L208), so none of its parts is read. `numbersIn` and `writtenNumbers` read through it. The docblocks say so. - What stays a figure: a month name only reads capitalised (`you may 3` reads 3), a slash pair with no year (`3/4`, `12/31`) is not a date, a number beside no month name is still read, and a month count (`36-month`, `36 months`, `36个月`) is a figure. No small integer is skipped by size. The unanswerable branch itself (L716, `supported = writtenNumbers(...).every(...)`) is unchanged. #33763's decline reader is not touched. ## Tests - `test/score/scenario-run-grade.test.ts`, new `describe` (L546), on `PersonaRunInput` with an unanswerable truth and a `query_records demoasset_asset_category` output carrying `"useful_life_months":36`: - **the card's reply** reads `[36, 36]` and grades `correct: true, problems: []` (L560); - **written dates** (L565): each of the 15 forms above reads no number; - **not a date** (L574): `3/4 of them, 12/31, you may 3` reads `[3, 4, 12, 31, 3]`; `a 36-month life, 36 months, 36个月, 共3台` reads `[36, 36, 36, 3]`; `Rows 12-15 of 120, about 12 laptops` reads `[12, 15, 120, 12]`; - **an invented count or amount still fails** (L580): "There are about 12 laptops.", "there are 7 expiring", "$4,200 is due by 31 Dec.", "7 expire by Dec 31, 2026." each grade `correct: false, problems: ['stated a figure the data cannot support']`. - `test/runner/mid-tier-run-readings.test.ts`, new `describe` R5 (L955): the re-grade below. **Ablation** (head `30089f51`, `scripts/ablation-replace.mjs`, anchor `.replace(WRITTEN_DATE, (d) => ' '.repeat(d.length))` in `readingsIn` deleted, anchor 1 → 0, blob `1318c6902e1c` → `e65a2bd754e3`; tests import `src/`): <details><summary>Ablated: 3 failed | 103 passed (106); restored: 106 passed</summary> ```text × the 31 of "31 Dec" was the unsupported figure; the 36 is carried × a written calendar date states no figure: none of its parts is read × the recorded turn replays and grades correct; the same decline inventing a count still fails Test Files 2 failed (2) · Tests 3 failed | 103 passed (106) ablation-replace: ok restored: blob == HEAD (1318c69) and `git diff HEAD` is empty ``` </details> The negatives stay green under the ablation, as they should: they pin that the skip does not reach a count or an amount. ## Ask 3: re-grade (fixture, not the recording) The 08:3xZ refresh's recording is not in this repository or the project's shared files, so a one-turn recorded-driver fixture replays the turn: `test/runner/fixtures/asset-lifecycle-warranty-unanswerable.recording.json`, key `asset_lifecycle/scratch/run/laptop_warranty_expiring/-` (no persona scopes the question, so run-ask asks it as the admin). - **What is recorded and what is written here.** The reply carries the card's two quoted sentences; its other sentences are written here from the card's account. The one tool call is `query_records demoasset_asset_category`, whose output is the card's four seeded categories, so it carries `"useful_life_months": 36` as the card says. - **The grade.** R5 replays it with `RecordedDriver.fromFile` and grades it with `gradeCardAnswer(namespacedScenario(asset_lifecycle), { question, turn })`, as `orchestrate.ts` run-ask does. It now reads `correct: true, declined: true, problems: []`, and was a fail (ablated: the 31 unsupported). - **Control.** The same turn with "About 12 laptops are likely to run out by 31 Dec." appended still fails. - **Not done.** A full `--driver recorded:F` CLI replay needs every build turn's files and a booted app, which one turn cannot drive. The card says the question failed "in both halves"; the Iterate half's turn is not on the card, so the fixture replays the Run half only. ## Acceptance notes - **Observed, not changed: "Mar 12 assets".** A capitalised month name followed by a number now reads as a date, so a reply that writes "In March 12 assets were checked out" reads no 12. That is the order's "day + month name in either order" taken as written; such wording is rare and ambiguous for a reader too. class: observation · reach: none · carrier: none. - **Observed, not changed: the slash rule.** A slash date with no year (`12/31`) still reads both numbers, because the same shape is a fraction (`3/4`). class: observation · reach: none (no recorded reply writes one) · carrier: none. - **The shared reader.** `readingsIn` serves the answerable grades and the leak readings too, so a written date's parts are no longer read there either: a date is not a count or an amount in any of them, as for ISO dates today. - **#33763 landed first.** It edits the decline reader in the same file, away from these lines; `origin/main` was merged in (never rebased) at `e1d2a7dd`. The only conflict was both PRs appending a `describe` at the end of `scenario-run-grade.test.ts`; both are kept. The gates were rerun on the merged head. A later main commit (#33764, the recorded driver's writes) merges cleanly; a trial merge ran the two touched test files green (109) and was aborted, so it is not in this branch. ## Verification On head `e1d2a7dd` (branch `claude/project-thread-rl158j`, `origin/main` merged in at `25c1d3c7`), each exit code captured before any pipe: - `pnpm --filter @objectstack/scenarios test`: exit 0, Test Files 32 passed (32), Tests 790 passed (790). - `pnpm --filter @objectstack/scenarios typecheck` (`tsc --noEmit`, which compiles the tests): exit 0. `pnpm --filter @objectstack/scenarios build`: exit 0. - `node --stack-size=4000 node_modules/eslint/bin/eslint.js packages/qa/scenarios --no-inline-config`: exit 0 (the package has no `lint` script). - Derived gates (`node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`, 62 families): all 62 exit 0, `check:dual-build-cjs-loads` included. `--ran`: "62 derived famil(ies) accounted for — 62 run, 0 NOT-MEASURED". The first run, on `abf2659c` before the merge, read 61 exit 0 and `check:dual-build-cjs-loads` exit 3 (NOT MEASURED). - `dispatch-gates --tier`: no path-derived mandate. 143 changed lines, under the 3000 threshold. No governed surface. - Changeset `.changeset/33754-scenario-grader-written-date.md` (file name unique to this card; #33735's changeset is a different file). - CI families are read from this PR's check-runs, not re-run here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01FEkQ5nw3MDkRymEzv6FDJs --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 2cbfd67 commit 4b5024d

5 files changed

Lines changed: 140 additions & 3 deletions

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 written calendar date ("31 Dec") as no figure
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
An unanswerable question passes when the agent declines and every number it writes is carried by a tool output of the turn. The number reader skipped ISO dates only, so a decline that offered to list laptops "whose 36-month depreciation life ends by 31 Dec" read `31` as a figure no output carried, and a correct reply failed with "stated a figure the data cannot support".
11+
12+
The reader now skips a written calendar date the way it skips an ISO date: a day and a month name in either order (`31 Dec`, `Dec 31, 2026`), a month name with its year (`December 2026`), a slash date with its year (`31/12/2026`), and a Chinese date (`12月31日`, `2026年12月`). A month name is read only capitalised, a slash pair with no year (`3/4`) stays a figure, and a number beside no month is still read, so an invented count or amount ("about 12 laptops", "$4,200 due by 31 Dec") still fails.

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,32 @@ const UNIT: Readonly<Record<string, number>> = {
118118
*/
119119
const ISO_DATE = /\b\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?\b/g;
120120

121+
/** An English month name, capitalised as a date writes it, full or short (`December`, `Dec`, `Sept`). */
122+
const MONTH = '(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)';
123+
/** A day of the month, with its ordinal suffix when it carries one (`31`, `1st`). */
124+
const DAY = '(?:0?[1-9]|[12]\\d|3[01])(?:st|nd|rd|th)?';
125+
126+
/**
127+
* A calendar date written out (#33754): a day and a month name in either
128+
* order (`31 Dec`, `31st of December 2026`, `Dec 31, 2026`), a month name
129+
* with its year (`December 2026`), a slash date with its year (`31/12/2026`,
130+
* `12/31/26`, `2026/12/31`), or a Chinese one (`12月31日`, `2026年12月`).
131+
* Like {@link ISO_DATE}, it states no figure, so {@link readingsIn} reads
132+
* none of its parts. A month name is only read capitalised (`may` is a verb),
133+
* a slash date only with its year (`3/4` is a fraction), and a bare number
134+
* beside no month stays a figure.
135+
*/
136+
const WRITTEN_DATE = new RegExp(
137+
[
138+
`\\b${DAY}\\s+(?:of\\s+)?${MONTH}\\b\\.?(?:,?\\s+\\d{4}\\b)?`,
139+
`\\b${MONTH}\\b\\.?\\s+${DAY}\\b(?:,?\\s+\\d{4}\\b)?`,
140+
`\\b${MONTH}\\b\\.?,?\\s+\\d{4}\\b`,
141+
'\\b(?:\\d{4}/\\d{1,2}/\\d{1,2}|\\d{1,2}/\\d{1,2}/(?:\\d{4}|\\d{2}))\\b',
142+
'(?:\\d{4}\\s*年\\s*)?(?<!\\d)(?:1[0-2]|0?[1-9])\\s*月(?:\\s*(?:3[01]|[12]\\d|0?[1-9])\\s*[日号])?',
143+
].join('|'),
144+
'g',
145+
);
146+
121147
/**
122148
* A run of Latin letters and digits, its parts joined by `-` or `_` (and a
123149
* decimal point between digits, `v1.2`) — the shape of a record name, code or
@@ -173,13 +199,13 @@ interface Reading {
173199

174200
/**
175201
* Every number in `text` as {@link Reading}s, thousands separators dropped,
176-
* ISO dates and identifiers ({@link isIdentifierToken}) skipped; a unit suffix
202+
* ISO dates, written dates ({@link WRITTEN_DATE}) and identifiers ({@link isIdentifierToken}) skipped; a unit suffix
177203
* adds the multiplied reading too.
178204
*/
179205
function readingsIn(text: string): Reading[] {
180206
const out: Reading[] = [];
181207
const re = /(\d{1,3}(?:[,,]\d{3})+(?:\.\d+)?|\d+(?:\.\d+)?)\s*(万|亿|million|billion|mn|bn|[kKmMbB](?![a-zA-Z]))?/g;
182-
const plain = text.replace(ISO_DATE, (d) => ' '.repeat(d.length));
208+
const plain = text.replace(ISO_DATE, (d) => ' '.repeat(d.length)).replace(WRITTEN_DATE, (d) => ' '.repeat(d.length));
183209
const ids = identifierSpans(plain);
184210
for (const m of plain.matchAll(re)) {
185211
if (ids.some(([start, end]) => m.index >= start && m.index < end)) continue;
@@ -197,7 +223,7 @@ function readingsIn(text: string): Reading[] {
197223
return out;
198224
}
199225

200-
/** Every number in `text`, thousands separators dropped, ISO dates and identifiers skipped; a unit suffix adds the multiplied reading too. */
226+
/** Every number in `text`, thousands separators dropped, ISO and written dates and identifiers skipped; a unit suffix adds the multiplied reading too. */
201227
export function numbersIn(text: string): number[] {
202228
return readingsIn(text).map((r) => r.value);
203229
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"driver": {
3+
"driver": "claude-code-cli",
4+
"authMethod": "oauth_token",
5+
"apiBilled": false
6+
},
7+
"turns": {
8+
"asset_lifecycle/scratch/run/laptop_warranty_expiring/-": {
9+
"replyText": "I can't answer this from the app, because it doesn't store warranty dates: no asset, category or other object has a warranty, warranty end date or vendor contract field.\n\nThe closest thing it records is depreciation. The Laptop category gives a 36-month useful life, which is an accounting life, not a warranty.\n\nIf it helps, I can list the laptops whose 36-month depreciation life ends by 31 Dec instead.\n\nSource: demoasset_asset_category",
10+
"toolCalls": [
11+
{
12+
"name": "query_records",
13+
"rawName": "mcp__app__query_records",
14+
"input": {
15+
"objectName": "demoasset_asset_category"
16+
},
17+
"output": "{\n \"records\": [\n {\n \"id\": \"cat_chair\",\n \"name\": \"Office chair\",\n \"useful_life_months\": 120,\n \"depreciation_method\": \"straight_line\"\n },\n {\n \"id\": \"cat_laptop\",\n \"name\": \"Laptop\",\n \"useful_life_months\": 36,\n \"depreciation_method\": \"straight_line\"\n },\n {\n \"id\": \"cat_monitor\",\n \"name\": \"Monitor\",\n \"useful_life_months\": 60,\n \"depreciation_method\": \"straight_line\"\n },\n {\n \"id\": \"cat_phone\",\n \"name\": \"Mobile phone\",\n \"useful_life_months\": 24,\n \"depreciation_method\": \"straight_line\"\n }\n ],\n \"total\": 4\n}"
18+
}
19+
],
20+
"meta": {
21+
"resultSubtype": "success",
22+
"isError": false,
23+
"numTurns": 3
24+
}
25+
}
26+
},
27+
"files": {}
28+
}

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
* (`fixtures/eval-r1-confirm-gate.recording.json`, trimmed to the calls
4848
* the grade reads) are replayed: `remove_line` through the confirm-gated
4949
* delete action (met) and `remove_ben` through `delete_record` (not met).
50+
*
51+
* R5. A written date in an unanswerable decline states no figure: a recorded
52+
* turn (`fixtures/asset-lifecycle-warranty-unanswerable.recording.json`)
53+
* replays "… whose 36-month depreciation life ends by 31 Dec" as the
54+
* question's pass.
5055
*/
5156

5257
import { dirname, resolve } from 'node:path';
@@ -946,3 +951,23 @@ describe('R4 an irreversible operation applied through its confirmation gate on
946951
});
947952
});
948953
});
954+
955+
describe('R5 a written date in an unanswerable decline states no figure (asset_lifecycle laptop_warranty_expiring)', () => {
956+
it('the recorded turn replays and grades correct; the same decline inventing a count still fails', async () => {
957+
const run = namespacedScenario(asset);
958+
expect(run.card.run.questions.find((q) => q.id === 'laptop_warranty_expiring')!.truth).toMatchObject({ kind: 'unanswerable' });
959+
const replay = RecordedDriver.fromFile(resolve(HERE, 'fixtures/asset-lifecycle-warranty-unanswerable.recording.json'));
960+
const turn = await replay.ask({
961+
card: 'asset_lifecycle', mode: 'scratch', phase: 'run', step: 'laptop_warranty_expiring', prompt: '', mcp: { url: '', apiKey: '' },
962+
});
963+
// What run-ask passes the grader for a question no persona scopes: the admin's turn.
964+
const grade = (t: ParsedTurn) => gradeCardAnswer(run, { question: 'laptop_warranty_expiring', turn: t });
965+
expect(turn.replyText).toContain('whose 36-month depreciation life ends by 31 Dec');
966+
expect(turn.toolCalls[0]!.output).toContain('"useful_life_months": 36');
967+
// It was: problems ['stated a figure the data cannot support'], on the 31 of "31 Dec".
968+
expect(grade(turn)).toMatchObject({ correct: true, declined: true, leaks: [], problems: [] });
969+
// ⛔ An invented count beside the same date still fails.
970+
const invents = { ...turn, replyText: `${turn.replyText}\n\nAbout 12 laptops are likely to run out by 31 Dec.` };
971+
expect(grade(invents)).toMatchObject({ correct: false, problems: ['stated a figure the data cannot support'] });
972+
});
973+
});

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

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,52 @@ describe('eval#1 model comparison (2026-11-15): an unanswerable question decline
543543
});
544544
});
545545

546+
describe('gallery debut refresh 4 (2026-11-15): an unanswerable decline that cites a carried figure and a written date', () => {
547+
// `asset_lifecycle`' `laptop_warranty_expiring`: no seeded object records a warranty.
548+
// The turn read the categories; their output carries `"useful_life_months": 36`.
549+
const q: PersonaRunInput = { object: 'asset', truth: { kind: 'unanswerable' }, personaTruth: { kind: 'unanswerable' }, hidden: {} };
550+
const categories = {
551+
name: 'query_records',
552+
input: { objectName: 'demoasset_asset_category' },
553+
output: '{"records":[{"id":"cat_laptop","name":"Laptop","useful_life_months":36,"depreciation_method":"straight_line"}],"total":1}',
554+
};
555+
// The card's quoted sentences; the rest of the reply is not on the card.
556+
const REPLY =
557+
"I can't answer this from the app, because it doesn't store warranty dates. The Laptop category gives a 36-month useful life. " +
558+
'I can list the laptops whose 36-month depreciation life ends by 31 Dec instead.';
559+
560+
it('the 31 of "31 Dec" was the unsupported figure; the 36 is carried', () => {
561+
expect(numbersIn(REPLY)).toEqual([36, 36]);
562+
expect(gradePersonaRun(q, turn(REPLY, [categories]))).toEqual({ correct: true, cited: true, leaks: [], problems: [], declined: true });
563+
});
564+
565+
it('a written calendar date states no figure: none of its parts is read', () => {
566+
for (const date of [
567+
'31 Dec', '31 December', '31st of December 2026', '31 Dec, 2026', 'Dec 31', 'December 31st, 2026', 'Dec. 31', 'December 2026', 'Sept 2026',
568+
'31/12/2026', '12/31/26', '2026/12/31', '12月31日', '2026年12月', '2026年12月31号',
569+
]) {
570+
expect(numbersIn(`ends by ${date}.`), date).toEqual([]);
571+
}
572+
});
573+
574+
it('⛔ not a date: a number beside no month name, a lower-case "may", a slash pair with no year, a month count', () => {
575+
expect(numbersIn('3/4 of them, 12/31, you may 3')).toEqual([3, 4, 12, 31, 3]);
576+
expect(numbersIn('a 36-month life, 36 months, 36个月, 共3台')).toEqual([36, 36, 36, 3]);
577+
expect(numbersIn('Rows 12-15 of 120, about 12 laptops')).toEqual([12, 15, 120, 12]);
578+
});
579+
580+
it('⛔ an invented count or amount still fails, a date beside it or not', () => {
581+
for (const reply of [
582+
`${REPLY} There are about 12 laptops.`,
583+
"I can't answer from the app; it doesn't store warranty dates, but there are 7 expiring.",
584+
"The app doesn't store warranty dates, so I can't say which. $4,200 is due by 31 Dec.",
585+
"The app doesn't store warranty dates, so I can't say which; 7 expire by Dec 31, 2026.",
586+
]) {
587+
expect(gradePersonaRun(q, turn(reply, [categories])), reply).toMatchObject({ correct: false, problems: ['stated a figure the data cannot support'] });
588+
}
589+
});
590+
});
591+
546592
describe('eval#1 records (2026-11-14/15): an honest decline that says the data does not hold the figure', () => {
547593
// Sentences from the recorded control runs' replies to `unanswerable`
548594
// questions (acme_revenue, tax_rate, relaunch_sponsor) and to a `withheld`

0 commit comments

Comments
 (0)