Repository navigation
Commit 4df62e6
fix(scenarios): load the card seed through the platform's seed path (#34985)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} -->
_Requested by **Yibo Wang** · [project
thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBQ3DFv6XZAspQRYGQoEWhr8)_
Fixes #34897
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:场景卡运行器不再用数据 API 逐行写入种子数据,改为把卡片种子打成一个只含 `data[]`
的包,经托管安装门交给平台自己的种子加载器写入;恢复已删除种子行也走同一条路。
- 为什么改:构建按 skill 指引声明了 `initialStates: ['draft']` 的状态机,数据 API 属于用户写入,于是
travel_expense 卡 120 张报销单中 114 张(已付款/已提交等)被拒,其下 470 条明细与审批步骤连带被拒,584/757
行丢失,问数轮次在错误的数据上进行。
- 风险与回滚:种子行不再触发构建的记录触发流(平台种子语义如此);已普查 9
张卡,没有一张的答案依赖种子时触发流。拒收记录不再带错误码,只有加载器原文。回滚即 revert 本 PR。
- 先看:`packages/qa/scenarios/src/runner/orchestrate.ts` 的 `loadSeedRows`
与 `seedApp`(风险最高:错误清单到拒收记录的映射);同文件 `restoreSeededRows` 第 2
步;`packages/qa/scenarios/test/runner/orchestrate.test.ts` 新增的
`TravelRulesApp` 一组用例。
- 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run
--maxWorkers=2 test/runner/orchestrate.test.ts -t "past its entry
state"`,预期 6 个用例全部通过。
- 需要你做的:无,席位落地。
## What changes
- `seedApp` builds one dataset per object in its existing load order
(the card's own `id` on each row; persona user ids, `owner_id` and
rewritten handles as before; deferred cycle lookups still left out) and
hands them to a new module-private `loadSeedRows`.
- `loadSeedRows` installs a data-only package (`data[]`, `externalId:
'id'`, `mode: 'insert'`, its own namespace per load) through the
harness's existing `installManaged` door. The platform's seed loader
writes package data under `SEED_WRITE_EXECUTION_CONTEXT`: the
`state_machine` rule is skipped, every other rule and hook still runs,
and record-change flows are suppressed. It maps the answer's
`data.seeded.errorList` into the same `seed.refused` records: one per
row the loader could not write, plus `fields` for a written row whose
reference did not resolve. A refused package, a harness with no managed
door, or a load that did not run inline refuses every row, with the
reason.
- The second pass (PATCH of the lookups that close a reference cycle) is
unchanged.
- `restoreSeededRows` step 2 re-inserts the round's missing seeded rows
as one load through the same path.
- No exported signature or type changes: the harness interface gains no
member, and the new helpers are module-private. The `installManaged` doc
comment and the door table in `app.ts` say the seed loads through it.
- README: the Seed paragraph names the door and the posture. It states
that seed rows fire no record-triggered flow and that no card relies on
one.
- Test doubles: both `FakeApp`s give the managed door the measured
answer shape (`test/runner/seed-door.ts`).
### Route A, and one place the mechanism moved
The seat ruled route A: load the rows as declared `data[]` under the
seed posture, and keep the PATCH pass for runtime-id fields. I measured
that assumption before building (condition 1, below). `data[]` carries
runtime user ids as sent: `owner_id` and the `user` field landed, and
the persona read its own 10 claims (M3). The seat then ruled on that
deviation (A, 21:58Z): persona ids ride in the load, and the PATCH pass
now sets only the deferred cycle lookups. Re-patching the persona ids
would put a user-door update, with its update triggers and hooks, back
on every persona-owned seed row, and the seed posture exists to avoid
exactly that. The README's Seed paragraph says the same.
## Tests
- New block `seedApp — a card row already past its entry state loads
through the seed path…`, run on the travel_expense card with a double of
the kept build's rules (`TravelRulesApp`):
- the user door refuses a paid claim;
- through `seedApp`, all 757 rows load: 114 non-draft claims, and
`ln_001_hotel` / `as_001_1` hold `claim: 'c001'`;
- control: a trip that breaks `end_after_start` is refused with the
loader's message and no code, and its claim, two lines and two steps go
with it (751 inserted);
- `restoreSeededRows` puts a removed paid claim back;
- a reference the loader drops from a row it wrote (an `errorList` entry
whose `field` is the lookup): the row is refused with `fields:
['parent']`, `inserted` drops by one (755), and its deferred `manager`
patch still runs (`secondPass` 3); a row with both a write entry and a
reference entry counts once, without `fields`; and a restore counts the
written row as reinserted. The double (`test/runner/seed-door.ts`) can
now drop a reference from a row it writes, as the real loader reports
one (`referencesDropped`).
- a harness with no managed door refuses every row, saying so.
- Updated: the partial-tally test (one load, which throws, counts
nothing); two refusal expectations now read the loader's message and no
code; the fresh-copy seed-difference regex; `UnmanagedOnly` now drops
the managed door explicitly.
## Gates and test runs (head 1c5dbc3)
- `pnpm --filter @objectstack/scenarios build && … test && … typecheck`,
under the verify lock: `Test Files 39 passed (39)`, `Tests 1092 passed
(1092)`, typecheck clean, `VERDICT command-exit 0`.
- S1 round (1c5dbc3, two commits: a README sentence and the S1 test):
the package run above is on this head. The README path derives 42 gate
families and the two test paths add 7; all exit 0 except the two
standing NOT MEASURED (`check-plugin-teardown-shape --self-test` and
`check:dual-build-cjs-loads`, both exit 3). `overlap-check`: VERDICT
clean exit 0.
- Derived gate list: `node scripts/pm/dispatch-gates.mjs --repo
objectstack-ai/objectstack --commands` gives 67 families at 81b6323.
That is the same list as on the earlier head. The reconciliation
(`--ran` with each exit code captured before any pipe) reads `67
derived, 65 run, 2 NOT-MEASURED, 0 UNRUN`.
- `pnpm check:dispatcher-error-vocabulary` was red on the first head. It
flagged a refusal helper that took a `code` parameter it could not name
as a literal. 81b6323 removes it: a refused seed package now puts the
door's code in the message. The gate was re-run on that tree and exited
0.
- NOT MEASURED: `node scripts/check-plugin-teardown-shape.mjs
--self-test`. It exited 3 because the shallow clone lacks the commit it
needs ("Deepen the clone"). The scan itself, `node
scripts/check-plugin-teardown-shape.mjs`, exited 0.
- NOT MEASURED: `pnpm check:dual-build-cjs-loads`. It exited 3 with
`PREREQUISITE NOT MET`: other packages have no `dist/` in this worktree.
CI builds them and runs it.
- Not run locally: `test:repo` and the repo-wide scans. Both belong to
CI.
<details><summary>Derived families, exit codes</summary>
```text
exit 0 · node scripts/check-adr-0087-registration.mjs --base origin/main
exit 0 · node scripts/check-adr-0087-registration.mjs --self-test
exit 0 · node scripts/check-changeset-no-major.mjs --base origin/main
exit 0 · node scripts/check-closing-keyword-parity.mjs
exit 0 · node scripts/check-closing-keyword-parity.mjs --self-test
exit 0 · node scripts/check-comment-mask-adoption.mjs
exit 0 · node scripts/check-comment-mask-adoption.mjs --self-test
exit 0 · node scripts/check-comment-mask-corpus.mjs
exit 0 · node scripts/check-dts-emitted.mjs --self-test
exit 0 · node scripts/check-empty-changeset.mjs --base origin/main
exit 0 · node scripts/check-empty-changeset.mjs --self-test
exit 0 · node scripts/check-issue-citations.mjs
exit 0 · node scripts/check-plugin-teardown-shape.mjs
exit 3 · node scripts/check-plugin-teardown-shape.mjs --self-test
exit 0 · node scripts/ci/assert-turbo-remote-cache.mjs --self-test
exit 0 · node scripts/ci/plan-test-core-shards.mjs --self-test
exit 0 · node scripts/ci/prune-turbo-cache.mjs --self-test
exit 0 · node scripts/ci/snapshot-next.mjs --self-test
exit 0 · node scripts/docs-audit/check-affected-docs.mjs
exit 0 · node scripts/docs-audit/check-drift-comment.mjs
exit 0 · node scripts/pm/check-governed-queue-guard.mjs --self-test
exit 0 · node scripts/pm/release-rehearsal-clone.mjs --self-test
exit 0 · node scripts/release-pending-publish.mjs --self-test
exit 0 · pnpm --filter @objectstack/spec run check:duration-unit-keys
exit 0 · pnpm --filter @objectstack/spec run check:error-code-provenance
exit 0 · pnpm check:adr-anchors
exit 0 · pnpm check:changeset-gate-self-tests
exit 0 · pnpm check:ci-filter-parity
exit 0 · pnpm check:cli-command-ids
exit 0 · pnpm check:closed-ceremony-text
exit 0 · pnpm check:cross-package-test-inputs
exit 0 (re-run on 81b6323; 1 on the first head) · pnpm check:dispatcher-error-vocabulary
exit 0 · pnpm check:doc-authoring
exit 0 · pnpm check:driver-memory-census
exit 0 · pnpm check:dts-closure
exit 3 · pnpm check:dual-build-cjs-loads
exit 0 · pnpm check:engine-double-contract
exit 0 · pnpm check:error-status-conformance
exit 0 · pnpm check:gitlink-declared
exit 0 · pnpm check:issue-citations
exit 0 · pnpm check:keyed-text-bounds
exit 0 · pnpm check:lean-entry-closure
exit 0 · pnpm check:logger-receiver-detach
exit 0 · pnpm check:nul-bytes
exit 0 · pnpm check:object-def-param-keys
exit 0 · pnpm check:objectql-double-limit
exit 0 · pnpm check:optional-error-sink
exit 0 · pnpm check:org-identifier
exit 0 · pnpm check:page-declaration-shape
exit 0 · pnpm check:platform-object-tenancy-census
exit 0 · pnpm check:published-files
exit 0 · pnpm check:query-options-erasure
exit 0 · pnpm check:refd-timer-probe
exit 0 · pnpm check:registry-log-declared
exit 0 · pnpm check:rest-log-spy-declared
exit 0 · pnpm check:settings-bind-window
exit 0 · pnpm check:slot-lookup
exit 0 · pnpm check:sourcemap-no-sources-content
exit 0 · pnpm check:system-context-census
exit 0 · pnpm check:test-source-alias
exit 0 · pnpm check:tier-file-adoption
exit 0 · pnpm check:type-check-coverage
exit 0 · pnpm check:type-check-debt
exit 0 · pnpm check:undeclared-dep-imports
exit 0 · pnpm check:vouch-for-reference-callers
exit 0 · pnpm check:watch-hint-literal
exit 0 · pnpm check:where-matcher
```
</details>
<details><summary>Ablation: the seed path and the restore path, one leg
each</summary>
The scenarios tests import the runner from `src/` by relative path, so
neither leg needs a dist rebuild. Each leg was written with `node
scripts/ablation-replace.mjs` from the HEAD blob `a8c96bc92dd1` of
`orchestrate.ts` and restored the same way. After each restore, the blob
equalled HEAD and `git diff HEAD` was empty.
- Leg 1: the seed loop goes back to one data-API insert per row (blob
`a8c96bc92dd1 -> 1ff43a1b3708`, anchor 1 -> 0). 4 of the 5 new tests go
red: all 757 load, the control, the restore (its seed already failed)
and the missing-door case. The user-door test stays green, as it should.
- Leg 2: only the restore re-insert goes back to the data API (blob
`a8c96bc92dd1 -> 0aaa6d7a3034`). Only the restore test goes red:
`failed: … demotravel_expense_claim: 1 missing (c001) (refused: insert
demotravel_expense_claim c001: This status change is not allowed; a paid
claim cannot be changed.)`.
- Leg 3 (S1, head 1c5dbc3): the reference branch ignores entries
(`unheld.set(key, held)` replaced by `void held`, blob `004bb0c7c0f6 ->
21619f29c539`, anchor 1 -> 0). Only the S1 test goes red (`expected {
inserted: 756 } to deeply equal { inserted: 755 }`), 5 pass. Restored:
blob == HEAD `004bb0c7c0f6`, `git diff HEAD` empty.
</details>
## Acceptance notes
- Seed refusals now carry the seed loader's sentence (`Failed to write
OBJECT record #N (id=ID): …`) and no `code`, because the door's
`errorList` names none. `seedDifference` and the scorecard read them
unchanged.
- In the re-run, the replayed ask turns score `Run-问数 3/13` and
`Run-operations 2/6`. Those answers were recorded over the old 173-row
seed and are now graded against the full truth. This is not a
regression: the old round had 8 turns not measured, and those turns are
now asked.
- Not exercised live: the write-back restore (`restoreSeededRows`). Ask
mode took the fresh-copy route, whose copy seeded alike. The write-back
restore is covered by the unit test and its ablation.
## Verification
Condition 1 asked whether `data[]` keeps the card's ids as lookup
targets. I measured it before writing code, on a blank 18.5.0 host with
the kept `template.json` installed, through `POST
/api/v1/marketplace/install-local` (`installMode: 'managed'`):
- M1, the template plus the card seed as `data[]` (`externalId: 'id'`,
`mode: 'insert'`): `seeded.mode inline, inserted 757, errors 0`. The ids
are kept: `c001` exists, `ln_001_hotel.claim = c001`, `dep_eng.manager =
e05`.
- M2, a separate data-only package with trip `t001` broken (end before
start): `inserted 751, errors 11`. The trip is refused with the rule's
message, and its claim, two lines and two steps go with it (two entries
per dependent row: write plus lookup).
- M3: `owner_id` and the `user` field carry persona user ids as sent,
and the employee persona reads its own 10 claims. A second data-only
package with its own namespace installs. The same namespace again is
refused with 422.
Condition 3 is the re-run on the round's kept build. That is
`template.json`, sha256 `b7ab31a715d4e83c…`, in ask mode with the
round's recorded ask turns (`--driver
recorded:…/issue-34687/ask-round-2026-11-17/proof-managed/ask.rec.json`,
`--create-version 18.5.0`). The record is on the project mount:
`issue-34897/rerun-replay/` (`rerun.sh`, `run.log`, `started`, `exit`,
`out/2026-11-17-scenario-travel_expense.json`).
- It started at 2026-11-17T21:19:04Z on runner head 8308c29 and
exited with `EXIT=0` at 21:22:39Z.
- Template: `installMode managed`, after the unmanaged attempt was
refused `422 UNMANAGED_INSTALL_UNCOPYABLE`.
- Seed: `inserted 757, refused [], secondPass
{demotravel_department.manager: 4}`. The scorecard reads `seed {inserted
757, total 757, refused 0}`.
- Before: the same build seeded through the data API refused 114 claims
at the root and 470 lines and steps in cascade, 584 of 757 rows. Now 0
of the 114 root rows are refused, and all 470 cascaded rows are
inserted.
- What changed after 8308c29 does not touch this path: the README, the
changeset, and the message of a refused seed package, which this run
never met.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH)_
<!-- signed: repo:objectstack#3 · os-support-ai ·
session_01WGufzgNCAXyGfBQFZBwixH -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 13fbf94 commit 4df62e6
7 files changed
Lines changed: 407 additions & 44 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 | |
|---|---|---|---|
| |||
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
490 | 502 | | |
491 | 503 | | |
492 | | - | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
493 | 508 | | |
494 | 509 | | |
495 | 510 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
21 | 30 | | |
22 | 31 | | |
23 | 32 | | |
| |||
149 | 158 | | |
150 | 159 | | |
151 | 160 | | |
| 161 | + | |
| 162 | + | |
152 | 163 | | |
153 | | - | |
| 164 | + | |
154 | 165 | | |
155 | 166 | | |
156 | 167 | | |
| |||
0 commit comments