Repository navigation
Commit 4b5024d
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
- .changeset
- packages/qa/scenarios
- src/score
- test
- runner
- fixtures
- score
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
121 | 147 | | |
122 | 148 | | |
123 | 149 | | |
| |||
173 | 199 | | |
174 | 200 | | |
175 | 201 | | |
176 | | - | |
| 202 | + | |
177 | 203 | | |
178 | 204 | | |
179 | 205 | | |
180 | 206 | | |
181 | 207 | | |
182 | | - | |
| 208 | + | |
183 | 209 | | |
184 | 210 | | |
185 | 211 | | |
| |||
197 | 223 | | |
198 | 224 | | |
199 | 225 | | |
200 | | - | |
| 226 | + | |
201 | 227 | | |
202 | 228 | | |
203 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
946 | 951 | | |
947 | 952 | | |
948 | 953 | | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
546 | 592 | | |
547 | 593 | | |
548 | 594 | | |
| |||
0 commit comments