Repository navigation
Commit a3e216e
fix(scenarios): a replay maps the row a recorded run_action created to its live id (#35064)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_
Fixes #35048
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:场景卡回放(`--driver recorded:F`)现在会把录制里 `run_action` 新建出来的记录
id(答案里的 `result.id`)映射到回放应用给的新 id,原来只认 `create_record` 顶层 `id`。
- **为什么改**:travel_expense 的 `file_and_submit_from_text` 由动作建单、再按 id
提交;回放时提交带着旧 id 被拒 RECORD_NOT_FOUND,这道操作题每次回放都读成「未测」,问数技能迭代只能离线评分。
- **风险与回滚**:只动回放驱动里一个私有函数和一个判断,不影响真实运行与评分逻辑;回滚即 revert 本 PR。
- **先看**:`packages/qa/scenarios/src/runner/driver.ts`(`createdIdOf` 与
`CREATING_TOOLS`
判断);`packages/qa/scenarios/test/runner/orchestrate.test.ts`(新增两条回放用例)。
- **两分钟验证**:`pnpm --filter @objectstack/scenarios exec vitest run
test/runner/orchestrate.test.ts -t "replay re-sends"`,预期 10 条全绿。
- **需要你做的**:无,席位落地。
## What changes
`RecordedDriver` re-sends a replayed turn's recorded writes and, for a
row the recorded run created, sends later writes with the id the
replayed app gave that row. It learned that id only from `create_record`
answers (top-level `id`). `run_action` answers what the action body
returned under `result` (`{ ok, action, objectName, result: { id } }`),
so a row an action created kept its recorded id, and the follow-up write
naming it was refused `RECORD_NOT_FOUND` on replay. That made the turn
not faithful, and the operation read NOT MEASURED.
- `createdIdOf(tool, output)` reads `result.id` on a `run_action` answer
and the top-level `id` on a `create_record` answer, as before.
- The remap runs for an applied answer of either door
(`CREATING_TOOLS`), and still only for an applied one.
- No other nested create shape (for example `result.record.id`) is read:
nothing in the package knows such a shape.
- `createdIdOf` and `CREATING_TOOLS` are module-private, so no published
export changes (`Clause-②: no`). Changeset: patch
`@objectstack/scenarios`.
## Tests
Two cases go into the existing driver block of
`test/runner/orchestrate.test.ts` (the `runHalf` replay describe), using
a stand-in door modelled on the travel_expense build. Filing creates a
claim. Submitting it is refused `HOOK_ABORTED`, or `RECORD_NOT_FOUND`
for an id the app never gave.
- **Pin:** a recorded `run_action` files a claim (`result.id` =
`cl-rec`), the live app gives `cl-live-0`, and the recorded `run_action
submit_claim` (same turn) plus a later turn's `update_record` naming
`cl-rec` are re-sent naming `cl-live-0`.
- **Control:** a `create_record` row is still remapped from its
top-level id into a later `update_record` and a later `run_action`.
Ablation (`scripts/ablation-replace.mjs`, fix committed first, test
imports `src/` directly so no build sits between): each of the fix's two
halves, ablated on its own, turns the pin red with the live failure
text. The control stays green. Both restores are proven: blob equals
HEAD and `git diff HEAD` is empty.
## Acceptance notes
- The live replay after the fix grades `file_and_submit_from_text` and
fails it only on `status` (`read "draft", declared "submitted"`). The
build's own `demotravel_submit_claim` answers `HOOK_ABORTED`
(`update('demotravel_expense_claim') does not recognise option
'status'`) in the recording as on replay. That is the authored action's
defect, which the score now measures. It is not the replay's.
- The first live "before" attempt was a no-op. It mutated the guard to
`c.name === 'create_record'`, which left `CREATING_TOOLS` unused, so the
workspace build's DTS step refused (`TS6133`) before anything ran. It
was redone with a compile-clean mutation (`CREATING_TOOLS` =
`['create_record']`), which is the pre-fix behaviour on this path.
- `node scripts/check-plugin-teardown-shape.mjs --self-test` exited 3
locally (PREREQUISITE NOT MET: its positive-control commit is not in
this shallow clone). That is NOT MEASURED locally and is CI's to read.
It is unrelated to this diff.
## Verification
All readings were taken on head `4aa292ec`.
<details><summary>Live replay, before and after (travel_expense, ask,
iter2 recording, --packages workspace)</summary>
Command: `run-scenarios --only travel_expense --modes ask --template
/mnt/project-files/issue-34687/ask-round-2026-11-17/build/travel_expense/template.json
--ask-repeats 5 --packages workspace --driver
recorded:/mnt/project-files/issue-34869/skill-iter/iter2/ask.rec.json`
(scratch `--work`/`--out`), under the shared verify lock.
| | Run-operations | `file_and_submit_from_text` |
|:---|:---|:---|
| before (`CREATING_TOOLS` ablated to `create_record`; `workspace @
4aa292e + uncommitted changes`) | 2/2 · 4 not measured · 2 started from
restored rows | NOT MEASURED: `run_action` was refused HOOK_ABORTED in
the recorded run and refused RECORD_NOT_FOUND on replay (x2) |
| after (`workspace @ 4aa292e`) | 2/3 · 3 not measured · 2 started from
restored rows | graded, fail:
`state:demotravel_expense_claim[trip="t121"].status` read "draft",
declared "submitted" (the only failed check) |
The other five operations are the same in both runs: `fix_meal_days`
pass, `over_standard_without_reason` pass, and three NOT MEASURED
because the seed refused their rows. Run-问数 is 25/25 · 40 not measured
in both.
</details>
<details><summary>Unit tests, typecheck, ablation</summary>
- `pnpm --filter @objectstack/scenarios typecheck`, then `vitest run
--maxWorkers=2`: VERDICT command-exit 0, Test Files 39 passed (39),
Tests 1095 passed (1095). `tsc --listFiles` includes
`test/runner/orchestrate.test.ts`.
- Block run (`-t "replay re-sends"`): Tests 10 passed | 127 skipped.
- Ablation A: anchor `const holder = tool === 'run_action' ?
answer.result : answer;` was replaced with `const holder = answer;`
(anchor 1 to 0, blob 8051b98 to 474a9f0f). Result: Tests 1 failed | 9
passed. The pin fails with ReplayNotFaithfulError: "`run_action` was
refused HOOK_ABORTED in the recorded run and refused RECORD_NOT_FOUND on
replay". Restored to blob 8051b98 == HEAD.
- Ablation B: anchor `if (CREATING_TOOLS.includes(c.name) && recorded
=== 'applied') {` was replaced with `if (c.name === 'create_record' ...`
(blob 8051b98 to b7f4e29d). Result: Tests 1 failed | 9 passed, with the
same failure. Restored to blob 8051b98 == HEAD.
</details>
<details><summary>Gates</summary>
- `pnpm --filter '@objectstack/scenarios^...' build`: VERDICT
command-exit 0.
- `dispatch-gates --commands` derived 64 commands. Each was run with its
exit captured before any pipe. 63 exited 0 and
`check-plugin-teardown-shape.mjs --self-test` exited 3 (shallow clone).
`dispatch-gates --ran`: "64 derived famil(ies) accounted for — 63 run, 1
NOT-MEASURED (1 DERIVED from a recorded exit 3)".
- `overlap-check`: `origin/main` merges cleanly, and no open PR head
shares a file. VERDICT clean exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufziH9rnXEpD9ne7yFhD)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufziH9rnXEpD9ne7yFhD -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 4240719 commit a3e216e
3 files changed
Lines changed: 106 additions & 11 deletions
File tree
- .changeset
- packages/qa/scenarios
- src/runner
- test/runner
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
621 | 621 | | |
622 | 622 | | |
623 | 623 | | |
624 | | - | |
625 | | - | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
626 | 635 | | |
| 636 | + | |
627 | 637 | | |
628 | | - | |
629 | | - | |
630 | | - | |
| 638 | + | |
631 | 639 | | |
632 | 640 | | |
633 | 641 | | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
634 | 647 | | |
635 | 648 | | |
636 | 649 | | |
| |||
654 | 667 | | |
655 | 668 | | |
656 | 669 | | |
657 | | - | |
658 | | - | |
659 | | - | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
660 | 674 | | |
661 | 675 | | |
662 | 676 | | |
| |||
790 | 804 | | |
791 | 805 | | |
792 | 806 | | |
793 | | - | |
794 | | - | |
795 | | - | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
796 | 810 | | |
797 | 811 | | |
798 | 812 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2086 | 2086 | | |
2087 | 2087 | | |
2088 | 2088 | | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
| 2135 | + | |
| 2136 | + | |
| 2137 | + | |
| 2138 | + | |
| 2139 | + | |
| 2140 | + | |
| 2141 | + | |
| 2142 | + | |
| 2143 | + | |
| 2144 | + | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
2089 | 2160 | | |
2090 | 2161 | | |
2091 | 2162 | | |
| |||
0 commit comments