Repository navigation
Commit f59a4aa
feat(scenarios): restore the seeded rows before each operation, so one failed write does not cascade into the next (#34338)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoRjJUKvHSKGRptLNiD3Nska)_
epic:#33595#1 · os-tesla · session_01L9qibxMxTCsjCeHw2vP5qU
Clause-②: yes (widening) — through `./runner`: new exports
`restoreObjects`, `seededRows`, `restoreSeededRows` and types
`SeededRows` / `RowRestore` (`orchestrate.ts`); `derivedFields`,
`rowDrift`, `driftText`, `RESTORE_UNCOMPARED`, `RESTORE_UNWRITTEN` and
types `HeldRow` / `RowDrift` (`seed.ts`); the new optional member
`AppHarness.deleteRow` and the method `HttpApp.deleteRow` (`app.ts`);
the new optional fields `OperationResult.restored` (`orchestrate.ts`)
and `HalfScores.operations.restored` (`scorecard.ts`). No export entry
moves; `./score`, `./score/full`, `./export` and `.` are untouched.
Operation grades after an earlier turn's write move: an operation that
used to start from the rows the turn before it left now starts from the
seeded rows.
Metadata-protocol: none
Fixes #34294
## 维护者速读
-
改了什么:评测跑分器在每个操作运行之前,先把前面回合改动过的行恢复到种子加载后的状态(以管理员身份:删掉新增行、按种子原样重新插入被删行、把被改的列改回),所以每个操作都从卡片声明的数据出发;无法恢复时该操作记为「未测量」并写明原因。
-
为什么改:原来所有操作在同一份种子数据上按顺序跑,一次写错(或探针被应用错误地存下)会让后面两三个操作一起失败,模型之间的操作分比较就混进了连锁失败,而不只是每个回合自己的表现。
-
风险与回滚:没有任何前面回合写入时不写任何东西,记录和分数表逐字节不变(已钉住);恢复只在操作的第一个回合之前,不会插在「先问后确认」的两个回合之间;问数不受影响。旧录像回放时,依赖前一操作写入的后续操作会读成「未测量」(回放不忠实),不会读成失败。回滚即还原本
PR。
- 先看:`packages/qa/scenarios/src/runner/orchestrate.ts` 的
`restoreSeededRows`(三轮恢复与失败判定)和 `runHalf` 操作循环开头的调用;`src/runner/seed.ts`
的 `rowDrift`(比较哪些列)。
- 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run
--maxWorkers=2 test/runner/orchestrate.test.ts -t 34294`,预期 7 个用例全过。
- 需要你做的:无,席位落地。
## What changes
- **Design point 1, what is restored** (`orchestrate.ts`
`restoreObjects` / `seededRows` / `restoreSeededRows`, `seed.ts`
`rowDrift`): right after the seed loads, the runner reads, as the admin,
the rows of every seeded object and of every object an operation writes
or its outcome reads that the seed does not name. That read is the
seeded state: the app's own answer to the seed, so a row the app
refused, or one it made itself while seeding, is held exactly as the
operations would have met it before this change. This is a superset of
"the objects the operation and its outcome read": the agent's turn may
read any seeded object (it looks an account up by name before it creates
a contact), and the cost is one list per object per operation, against
an agent turn that takes minutes. Before each operation the runner reads
them again and compares by id, every column except `created_at`,
`updated_at`, `updated_by` (stamped anew by every write, the restore's
own included) and the fields the build computes (`COMPUTED_VALUE_TYPES`
from `@objectstack/spec/data`: formula, summary, autonumber, read from
the built artifact through the scorer's one reader). When something
moved it puts it back, as the admin, through the seed path: a row a turn
added is deleted (new `DELETE /api/v1/data/:object/:id`,
`HttpApp.deleteRow`); a seeded row a turn removed is inserted again with
the very body the seed sent (`seedRowBody`, now shared by `seedApp`),
or, for a row the app made itself while seeding, the row as read less
the platform's stamps; a changed column is set back to the value the
seed left. A lookup to a row still missing waits for the next round. Up
to three rounds of writes, so a cascade settles (a delete that takes a
child, a reference set back before a delete is allowed).
- **Design point 2, when**: before every operation, and only when the
read finds something moved. A run where no earlier turn moved a row
writes nothing and records and scores byte for byte as before (pinned).
The first operation restores only when a question turn wrote (questions
are not meant to write; that drift would otherwise reach every
operation), which the order's "after the first that follows a write"
reading covers as the same rule: the check, not the position, decides.
- **Design point 3, a restore that fails**: rows that still differ after
the three rounds make the operation NOT MEASURED, `restore: the rows
could not be restored to the seeded state: OBJECT: 1 added (ID), …
(refused: VERB OBJECT ID: STATUS CODE MESSAGE)`, each refusal named
once. The operation is not asked, so no turn, observation or grade is
recorded, and it counts in neither passed nor total. A list the app
refuses during the restore fails it the same way. A harness without
`deleteRow` (it is optional, so an existing harness keeps compiling)
fails a restore that needs a delete, and says so.
- **Design point 4, interplay**: the restore runs at the head of the
operations loop, before an operation's first turn; a
`pending_confirmation` operation's ask and confirmation (#34293) run
back to back on the same rows, and the confirmed delete is undone before
the next operation (pinned). Questions are unchanged: they all run
before any operation, at every `--ask-repeats` ask, and the seeded state
is read before them. Ask mode runs the same Run half, so it restores the
same way. A replay re-sends each operation's recorded writes against the
restored rows (`RecordedDriver`, #33737); where a later operation leaned
on an earlier one's write, it reads NOT MEASURED (the replay is not
faithful), never a fail.
- **The record and the scorecard**: an operation that started from
restored rows carries `restored: { deleted?, reinserted?, setBack? }`
(each `object/id`; `setBack` maps a row to the columns set back), absent
otherwise. The `Run-operations` cell, and the run record's
`run-operations` note, add `· N started from restored rows` (measured
operations only) when N > 0.
- README: a bullet `Each operation starts from the seeded rows`;
changeset `34294-scenario-restore-seeded-rows.md` (patch).
## Design point 5, measured on eval#1's records
Read-only over the 138 run records under `/mnt/project-files/eval/runs`
(2026-11-14 through the 2026-11-16 M2 close-out; 258 Run halves; 1,290
operations that ran):
- 628 operations ran after an earlier turn in their half wrote (the
agent's write, a probe's, or a confirmed one): the restore would run
before each of them, and the other 662 are untouched.
- 199 of those 628 failed. 198 failed only on checks that read the
turn's own calls and reply (`answer`, `no-write`, `agent`,
`confirmed-by-agent`, `platform`): asking first, refusing, withholding.
They would grade the same on restored rows unless the agent behaved
differently on them, which no record can tell.
- 1 failed on a row-state check after an earlier write on the same row:
`2026-11-15-replay-m1/high/opus`, `invoice_with_line_items`, iterate
Run, `send_invoice` (`state: demoinvoice_invoice#i3.status read
"draft"`, `audit-actor`), after `add_line`'s runner probe stored a line
on `i3`. That is the one grade the restore can plausibly move.
- 0 operations errored after an earlier write.
What the records do not allow: they keep each operation's post-state
rows and write counts, not the rows it started from, so an exact count
of moved grades needs a replay of the recordings on this branch (booted
apps per card); this PR did not run one. The scripts and outputs are in
the project files beside the PR's other evidence
(`out-34294/measure*.mjs`, `out*.txt`).
## Tests
- `test/runner/orchestrate.test.ts`, a new top-level describe (#34294, 5
cases) and one for the pure helpers (2 cases):
- **an operation after a wrong write passes on its own merits**:
`add_contact`'s turn also deletes Eli (`ct5`), the row `move_eli` acts
on; `move_eli` passes with `restored: { deleted: [new-add_contact],
reinserted: [ct5] }`, and `add_contact`, the first operation, restores
nothing;
- the restore runs before an operation, never between its ask and its
confirmation (`remove_ben` sets back `ct5.account`, its confirmed delete
still grades on the rows its ask saw; `contact_bad_email` reinserts
`ct2`; the validation operation wrote nothing, so the next restores
nothing);
- **parity**: with no earlier write the app takes the seed's 8 inserts
and nothing after, and the record and the scorecard carry no `restored`
and no `restored rows`;
- **a refused restore is NOT MEASURED** with the reason, the operation
never asked (403 on delete; and a harness with no `deleteRow`);
- `restoreSeededRows` directly: the clock and a computed field moving
restore nothing and write nothing; a changed name is set back; a removed
seeded row goes back with the seed's body;
- `rowDrift` (clock and last writer not compared, `null` = absent) and
`derivedFields` (formula/summary/autonumber; nothing from an unreadable
artifact).
- `test/runner/app.test.ts` (+1): `HttpApp.deleteRow` sends `DELETE
/api/v1/data/OBJECT/ID` with no body and reads a refusal's code.
- Existing pins that read the app's rows after the run, or the
operations tally, now see the restores: the crm card's clean run reads
`restored: 3` (`move_eli`, `remove_ben`, `contact_bad_email`); the probe
that a broken app stores is deleted before `partner_edits_account`
(`restored: 4`); eval#1's haiku replay deletes `replayed-0` before
`move_eli`, and reinserts `ct2` after a replay whose app applied the
delete. Their grades are unchanged.
- `test/export/fixture.ts`: its `FakeApp` gains `deleteRow`.
## Acceptance notes
- `add_contact` passed in the cascade pin although its turn also deleted
`ct5`: the grader reads the declared post-state, and an extra removal on
the same object is not charged to that turn. That is the grader's
existing reading (`src/score/**`, outside this card); noted, not filed.
- The restore lists up to 1,000 rows per object (`listRows`), as every
read of the runner does; the largest seeded object in the library holds
307.
- `HttpApp.deleteRow`'s route is read from
`packages/rest/src/crud-routes.ts`, not yet measured live, like the
seed's second-pass PATCH beside it; a live run's first restore is that
measurement, and a refusal there reads NOT MEASURED with the code.
- A row an earlier turn deleted and the restore inserts again is a new
row to the platform: its `created_at` and any autonumber are new.
Neither is compared; a card that declares an autonumber value would see
the difference in its own post-state check.
- The four `orchestrate.test.ts` record-note and cell pins that read
`5/5` now read `5/5 · 3 started from restored rows`.
## Verification
<details><summary>Ablation</summary>
- `node scripts/ablation-replace.mjs` on the committed head of the time
(`orchestrate.ts` blob `bc4bc9f62aa2`; the later `dcbc4425` changes only
how a failed restore names its refusals), the restore call in `runHalf`
replaced by "nothing restored"; the tests import `src`, so there is no
build leg. Restored each time with `git diff HEAD` empty and the blob
equal to HEAD.
- The #34294 describe: 3 failed / 4 passed (the cascade pin, the
confirmation-interplay pin, the refused-restore pin; parity and the
helper pins hold, as they should with no restore).
- The cascade pin alone, its grade asserted first: `move_eli` reads
`"Cannot convert undefined or null to object"` (the row it acts on is
gone) instead of a pass.
</details>
<details><summary>Local gates</summary>
- On `dcbc4425`: `pnpm --filter '@objectstack/scenarios^...' build` ::
exit 0 (lock VERDICT command-exit 0); `pnpm --filter
@objectstack/scenarios build && pnpm --filter @objectstack/scenarios
typecheck && pnpm --filter @objectstack/scenarios test` :: exit 0 (lock
VERDICT command-exit 0): Test Files 35 passed (35), Tests 985 passed
(985).
- `eslint --no-inline-config` on the seven touched TS files :: exit 0.
- Derived gates (`dispatch-gates --commands --repo
objectstack-ai/objectstack` at `dcbc4425`, 9 paths, 67 families), each
run with stdin from `/dev/null`: 65 exit 0, and 2 exit 3 (PREREQUISITE
NOT MET):
- `check-plugin-teardown-shape --self-test` could not read its pinned
fixture commit in the shallow clone; after `git fetch origin 621a487…`,
a rerun exited 0 ("48 cases pass"), recorded on its own line; the
first-run record is kept as it was.
- `pnpm check:dual-build-cjs-loads` is NOT MEASURED locally: it needs
every package's `dist/`. CI runs it.
- `--ran` on the first-run record: "67 derived famil(ies) accounted for
— 65 run, 2 NOT-MEASURED (2 DERIVED from a recorded exit 3)".
- Main (`951eceee` → `c9346317`, the objectql cascade-delete batch,
#33887) was merged once before opening (`88929ff3`); it touched nothing
under `packages/qa/scenarios`. After the merge, on `88929ff3`: `pnpm
install --frozen-lockfile && pnpm --filter '@objectstack/scenarios^...'
build && pnpm --filter @objectstack/scenarios build && … typecheck && …
test` :: exit 0 (lock VERDICT command-exit 0), Test Files 35 passed
(35), Tests 985 passed (985); `packages/spec` moved on main's side, so
`pnpm --filter @objectstack/spec check:generated` :: exit 0. The
derived-gate record is the one on `dcbc4425`, whose diff the merge
leaves as it was.
- 616 changed lines (+571/-45) in 9 files. No governed surface;
`packages/spec`, `src/score/**`, `src/schema.ts`, card JSONs and
`src/export/**` untouched (the export test fixture gains `deleteRow`).
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qibxMxTCsjCeHw2vP5qU)_
<!-- signed: epic:#33595#1 · os-tesla · session_01L9qibxMxTCsjCeHw2vP5qU
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent f4f0dfa commit f59a4aa
9 files changed
Lines changed: 571 additions & 45 deletions
File tree
- .changeset
- packages/qa/scenarios
- src/runner
- test
- export
- runner
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
386 | 402 | | |
387 | 403 | | |
388 | 404 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
128 | 139 | | |
129 | 140 | | |
130 | 141 | | |
| |||
272 | 283 | | |
273 | 284 | | |
274 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
275 | 290 | | |
276 | 291 | | |
277 | 292 | | |
| |||
0 commit comments