Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/36206-unicode-hyphen-date.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@objectstack/scenarios': patch
---

fix(scenarios): an ISO date written with a Unicode hyphen states no figure

Clause-②: no
Metadata-protocol: none

The run grader skips the parts of an ISO date when it reads the figures a reply states, but it matched only the ASCII `-`. A reply that wrote a date with the non-breaking hyphen U+2011 (or the hyphen U+2010), as a typeset answer does, had its year, month and day read as three figures, so a correct decline was graded "stated a figure the data cannot support". Such a date is now read as a date; a figure range joined by the same hyphen still reads as figures.
5 changes: 4 additions & 1 deletion packages/qa/scenarios/src/score/scenario-run-grade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@ const UNIT: Readonly<Record<string, number>> = {
* An ISO date, with its time when it carries one (`2026-07-06`,
* `2026-07-06T09:30:00Z`). A date states no figure: its year, month and day
* are not counts or amounts, so {@link readingsIn} reads none of its parts.
* Its parts may be joined by the Unicode hyphens a typeset reply writes in
* place of `-` (U+2010 hyphen, U+2011 non-breaking hyphen): such a date is the
* same date, and reading its parts would charge the reply with three figures.
*/
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;
const ISO_DATE = /\b\d{4}[-\u2010\u2011]\d{2}[-\u2010\u2011]\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?\b/g;

/** An English month name, capitalised as a date writes it, full or short (`December`, `Dec`, `Sept`). */
const MONTH = '(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)';
Expand Down
8 changes: 8 additions & 0 deletions packages/qa/scenarios/test/score/scenario-run-grade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,14 @@ describe('QA scenario round 1 (2026-11-09): correct replies the scorer failed',
expect(numbersIn('Rows 12-15 of 120.')).toEqual([12, 15, 120]);
});

it('an ISO date joined by a Unicode hyphen states no figure either', () => {
// A typeset reply writes U+2011 (non-breaking hyphen) or U+2010 between the parts.
expect(numbersIn('September orders, 2026\u201109\u201101 to 2026\u201109\u201130, total 28.')).toEqual([28]);
expect(numbersIn('Filed on 2026\u201010\u201003 for 3 days.')).toEqual([3]);
// Not a date: a figure range joined by the same hyphen still reads.
expect(numbersIn('Rows 12\u201115 of 120.')).toEqual([12, 15, 120]);
});

it("a date in the reply is no figure outside the persona's scope", () => {
const input: PersonaRunInput = { object: 'leave_request', truth: { kind: 'scalar', value: 7 }, personaTruth: { kind: 'scalar', value: 3 }, hidden: {} };
const g = gradePersonaRun(input, turn('You have 3 leave requests; the latest starts on 2026-07-06.\nSource: leave_request'));
Expand Down
Loading