You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 529ed7d
Browse filesBrowse the repository at this point in the historyBrowse files
fix(scenarios): keep a working-day card's dates on working days on every run date (#33999)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9KP2AnyfX9ZJYh48bUsyqbo)_Fixes#33793
Clause-②: yes (widening) — new optional key
`ScenarioCardSchema.workingDays` (`.`)
Metadata-protocol: none
## 维护者速读
- 改了什么:场景卡可以声明 `workingDays:
true`;运行器平移这种卡的日期时,今天仍落在运行当天,其余日期按整工作日平移,不再按整天。请假卡 `leave_balances`
声明了它,并把 31 条落在周末的审批日期挪到下一个工作日。
- 为什么改:上一个 PR 按整天平移后,7 个运行日里有 6 天会把请假日落到周末(最多 126/307 条),应用只算周一到周五,于是 6
条真值和余额跟卡上的数字对不上,问句里的「周三」也会变成「周日」。
- 风险与回滚:只动 `packages/qa/scenarios`(运行器、加载器、卡格式多一个可选键,属放宽)和这张卡;别的 6
张带日期的卡不声明,行为不变。回滚即 revert 本 PR。
- 先看:`packages/qa/scenarios/src/runner/run-date.ts` 的
`moveFor`(两种平移的分叉点),`src/loader.ts` 的 `checkWorkingDays`,卡里 31 行
`decided_on`。
- 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run
test/runner/run-date.test.ts`,34 项全过;其中连续 7 个运行日(2026-11-15 到 11-21)各一项。
- 需要你做的:无,席位落地。
## What changes
**Step 1, measured first.** On `origin/main` (895783a), over seven
consecutive run dates 2026-11-15 (a Sunday) to 11-21, the whole-day
rebase puts this card's working days on weekends on six of the seven:
only 11-18 (delta 49, whole weeks) is clean. When a working day lands on
a weekend, the meaning changes in three places:
- **Request days.** The card's prompt has the app sum a request's day
lines "Monday to Friday only". Read that way over the moved seed, 60 to
84 of the 120 requests no longer have the seeded `days`.
- **Balances and truths.** 17 to 22 balances' `used_days` move with
them, and 6 of the 10 truths change: `approved_days`,
`top_annual_takers`, `approved_days_last_month`,
`annual_days_by_department`, `remaining_annual_by_department`,
`lowest_annual_remaining`. The persona truths change too. Only the two
approval-step questions, the medical-note count and the unanswerable one
hold.
- **Asks.** `file_and_submit_from_text` asks for weekend leave on 3 of
the 7 dates ("Sunday 13 December" on 11-15). `half_day_on_draft` targets
a line that falls on a Saturday or Sunday on 2 of the 7, and its request
has a weekend line on a third.
The other dated cards: the open library has 7 dated cards, not 9
(`crm_account_with_contacts` and `project_with_tasks` have no `asOf`).
Searching the 6 others for weekday names, `weekday`/`weekend`/`working
day`/`business day`, `周X`, `工作日` and `周末` gives **0 hits**. Their seeds
already hold 2 to 256 weekend dates each, so none keeps to working days.
`leave_balances` is the only one, with 12 hits.
**Step 2, the fix.** Three ways to fix this, with the measured reason
for the choice:
- **A whole-week delta** is ruled out by the card. It keeps weekdays
only by putting the prompt's today up to three days off the run date.
- **Snapping each moved date to its nearest working day** breaks
multi-day leave. On the same seven dates, 36 to 62 requests get two day
lines on one date (0 only on 11-18).
- **Moving the card by whole working days** keeps every Monday-to-Friday
span intact. This is the one shipped.
Changes:
- **The card format** (`src/schema.ts`): an optional card key,
`workingDays: true`, declared by the author, never inferred. It widens
what `ScenarioCardSchema` (exported from `.`) accepts, hence `Clause-②:
yes (widening)`. The new helpers in `run-date.ts` (`shiftWorkingDays`,
`workingDaysBetween`, `onWorkingDay`) reach no `exports` subpath:
`run-date.ts` is imported only by `src/runner/cli.ts`, and the built
`index`, `runner`, `score`, `score-full` and `export` declarations hold
none of them (`ScenarioCardSchema` found in `index.d.ts` as the positive
control).
- **The loader** (`src/loader.ts`, `checkWorkingDays`) refuses such a
card in two cases:
- it has no `asOf`;
- `asOf`, or any ISO date under `run` or `iterate`, falls on a Saturday
or Sunday. The refusal names the path and the weekday. A weekend `asOf`
would be counted as the Friday before it, so that Friday and `asOf`
would both move onto the run date.
- **The rebase** (`src/runner/run-date.ts`, `moveFor`). A card without
the key moves exactly as before. A card with it moves like this:
- `asOf` goes onto the run date itself, so the prompt's today is still
the run date. The rebase also refuses a weekend `asOf` on such a card
(it throws) rather than map two dates onto one.
- Every other date moves by `workingDaysBetween(asOf, runDate)` whole
working days (`shiftWorkingDays`). A weekend run date is read as the
Friday before it.
- So a date before the card's today lands before the run date, and a
date after it lands after the run date. Consecutive working days stay
consecutive, and N working days between two dates stay N.
- Ask-text dates move the same way, and their weekday names are written
again (`shiftTextDates` now takes either a day count or the card's
move).
- Truths are recomputed over the moved seed, as before. `scopeFigures`
still stay, because the move maps distinct dates to distinct dates.
- **`docs/qa/scenarios/leave_balances.json`:**
- It declares `workingDays: true`.
- The seed rule said "decided the day after submission" and "two days
after", which put 31 approval decisions on a Saturday or Sunday. It now
says "the working day after" and "two working days after".
- Exactly those 31 `decided_on` values move. A recomputation of every
step from its request's `submitted_on` changes no other row, and no
truth reads `decided_on`.
- **The two READMEs:**
- `docs/qa/scenarios/README.md`, the card authors' guide, gains a
paragraph. The runner moves a card's dates onto the run date, so an
author must not rely on a fixed calendar date or a weekday name. A card
on working days declares `workingDays`.
- `packages/qa/scenarios/README.md`: its run-date bullet stated the old
limit ("keeps to them only when the delta is whole weeks"). It now
states the contract.
- `.changeset/33793-working-day-rebase.md`: `@objectstack/scenarios`
patch.
## Tests
`packages/qa/scenarios/test/runner/run-date.test.ts`, 34 tests (was 18).
**New: whole working days.** These check `shiftWorkingDays` and
`workingDaysBetween`:
- across a weekend, a month end, a leap day and a year boundary, and
around the epoch week;
- each against an independent walk over the calendar, one day at a time.
**New: `leave_balances` on seven consecutive run dates (2026-11-15 to
11-21).** For each date:
- `asOf` is the run date.
- Every moved date, apart from a value that is the card's today, is a
working day.
- A date before the card's today lands before the run date, and a date
after it lands after.
- Each request's Monday-to-Friday day lines, read independently over the
moved seed, sum to its `days`. Each balance's `used_days` equals its
approved requests' days.
- Every non-calendar truth and every persona truth equals the card's own
figure.
- The English and Chinese asks name working days only. Each named
weekday is that date's own, and the dates are the ones the operation's
values and expected day lines carry.
- The half day the draft's ask names is the date of the line it targets.
**New: loader refusals.** A copy of the card with one leave day on
Saturday 2026-07-04 is refused once, at
`run.seed.leave_day[0].leave_date`. The same copy without `workingDays`
is not refused for it. A copy whose `asOf` is Saturday 2026-10-03 is
refused once, at `asOf`. A copy without `asOf` is refused.
**New: a weekend `asOf` counterexample.** A copy with `asOf` Saturday
2026-11-14 and a leave day on Friday 2026-11-13, run on Wednesday
2026-11-18: counted from that Friday, the Friday itself would move onto
11-18 with `asOf`. The rebase throws on it (`asOf 2026-11-14 is a
weekend`), and the loader refuses the same card once, at `asOf`.
**Forced edits to existing tests**, named:
- `every dated card, rebased onto each run date › run on DATE` (nine
tests). The leaf check and the calendar-window reading-back used one
whole-day delta for every card. They now read each card's move
independently: whole days, or for a `workingDays` card a walk over
working days. Only the title words changed otherwise.
- `the asks that write a date say the moved one…`: the leave pins were
the defect. On 2026-11-15 they now read "Friday 11 December and the
morning of Monday 14 December" (was Sunday 13) and "(3 December)" (was 5
December).
**Ablations**, each through `scripts/ablation-replace.mjs`, each
restored with blob equal to HEAD and an empty `git diff HEAD`:
- The loader's `asOf` check deleted: 2 of 34 red, the two loader
refusals of a weekend `asOf`.
- The rebase's weekend-`asOf` guard disabled: 1 of 34 red, the rebase
counterexample.
- At the first round's head, with `moveFor` forced to the whole-day
branch, 16 of the 31 tests went red. Those were the 9 every-dated-card
runs, the ask pins, and 6 of the 7 seven-day runs; 11-18 stayed green,
as the measurement predicts (blob 500440c to 2899d999).
## Deviations
- `packages/qa/scenarios/src/schema.ts` is outside the claim's file
surface. The card-level flag the claim allows can only live there,
because the card is a strict object the loader parses against that
schema (+6 lines, one optional key). The seat accepted this.
- The key's name, `workingDays: true`, was proposed here with `rebase:
"working_days"` and `dates: "working_days"` as alternatives. The seat
chose `workingDays`.
## Acceptance notes
- **Weekend run dates.** On a Saturday or Sunday run, the card's other
dates move as they would for the Friday before it. So 11-20 and 11-21
seed identically, and the moved data ends up to two days nearer the run
date than the card wrote it. Nothing seeded before the card's today
moves past the run date, which is #33753's invariant.
- **Hire dates still move.** The rebase moves `hire_date` (whole days
before, working days now). `leave_year` (`2026/27`) and the 1 July
service rule live in the prompt and the strings, which are not moved. On
a run date about nine months or more after `asOf`, the moved leave falls
into the next leave year while the balances still say 2026/27. This was
the same before this change and is a property of the shipped rebase, not
of the weekday defect. Noted, not filed.
- The `$comment` seed rule ("working day … of July") still describes the
card's own dates. Like the prompt, it is never moved.
## Verification
<details><summary>Step 1 readings (origin/main 895783a, then this
head)</summary>
Measured with a throwaway script over `loadScenarios` +
`rebaseScenario`, not committed.
```text
origin/main, whole-day rebase:
2026-11-15 Sun delta=46 leave_day_weekend=126/307 req_days_changed=84 balances_changed=20 truths_changed=6 weekend_ask=file_and_submit_from_text
2026-11-16 Mon delta=47 leave_day_weekend=123/307 req_days_changed=82 balances_changed=22 truths_changed=6
2026-11-17 Tue delta=48 leave_day_weekend=60/307 req_days_changed=60 balances_changed=19 truths_changed=6
2026-11-18 Wed delta=49 leave_day_weekend=0/307 req_days_changed=0 balances_changed=0 truths_changed=0
2026-11-19 Thu delta=50 leave_day_weekend=60/307 req_days_changed=60 balances_changed=17 truths_changed=6
2026-11-20 Fri delta=51 leave_day_weekend=121/307 req_days_changed=81 balances_changed=20 truths_changed=6 weekend_ask=file_and_submit_from_text
2026-11-21 Sat delta=52 leave_day_weekend=124/307 req_days_changed=83 balances_changed=20 truths_changed=6 weekend_ask=file_and_submit_from_text
per-date nearest-working-day snap, requests with two lines on one date: 62 39 39 0 36 37 62
this head, working-day rebase: every one of the seven reads 0 / 0 / 0 / 0 / 0, no weekend ask
other dated cards (weekday words · weekend dates in the seed): asset_lifecycle 0·216, invoice_with_line_items 0·2, order_to_cash 0·133, requisition_to_receipt 0·147, service_desk 0·172, travel_expense 0·256
```
</details>
Head `6588d4fe1` merges `origin/main` b4ce310 (clean, merge not
rebase) on top of patch round 1 (`977f6bf6e`). The earlier merge,
`1b082ce44`, took in `origin/main` b8ac0e2 cleanly after PR #33872
landed; that PR also edits `packages/qa/scenarios/README.md`.
- At `6588d4fe1`, after `pnpm install --frozen-lockfile` (the merge
moved `pnpm-lock.yaml`) and a rebuild of `@objectstack/scenarios` with
its dependency closure: `vitest run` 34 files, 881 tests, exit 0; `tsc
--noEmit` exit 0.
- At `977f6bf6e`, derived by `node scripts/pm/dispatch-gates.mjs
--commands --repo objectstack-ai/objectstack` on this diff (the same 65
families at every head): `dispatch-gates --ran` 65 derived, 65 run, 0
NOT-MEASURED, every one exit 0. The full `pnpm build` (119/119 tasks)
was done at `1b082ce44`. At `bc00b2a13`, two families had first answered
exit 3 (prerequisite not met) and passed once it was built:
`check-plugin-teardown-shape.mjs --self-test` after `git fetch
--unshallow`, and `pnpm check:dual-build-cjs-loads` after the full
build.
- `pnpm exec eslint` on `run-date.ts`, `loader.ts`, `schema.ts` and
`run-date.test.ts`: exit 0 (no diff of these since `977f6bf6e`).
- CI families are read off this PR's check runs by the seat.
Full record: `/mnt/project-files/devx-seat1/33793-gates-ran.txt`.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(the card key is a Zod field in `packages/qa/scenarios/src/schema.ts`;
`packages/spec` not touched)
- [x] 2. Every name I added uses the casing for its kind. (`workingDays`
card key and `shiftWorkingDays`, `workingDaysBetween`, `onWorkingDay`:
camelCase)
- [x] 3. No formatter ran; `pnpm lint` passes. (eslint on the four
touched source and test files: exit 0; the repo-wide run is CI's)
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
(`.changeset/33793-working-day-rebase.md`, `@objectstack/scenarios`
patch)
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed. (not touched)
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English. (the 维护者速读 block is
the seat's required Chinese summary)
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRWUrXgua6hAwuKweu)_
<!-- signed: domain:devx#2 · os-steve · session_01ADHkmQTVjryTSkqydKVS6z
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
refuse(at,`\`${v}\` is a ${w===0 ? 'Sunday' : 'Saturday'}, but the card declares \`workingDays\`: move it to a working day, or drop \`workingDays\` if the card does not keep to them`);
0 commit comments