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 3fb7025
Browse filesBrowse the repository at this point in the historyBrowse files
fix(scenarios): template mode's iterate Run half runs an operation after a write on a fresh copy of the served app (#35291)
<!-- claude-projects-attribution: {"github_login":"os-bill"} -->
_Requested by **Bill** · [project
thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg1XdbbGasMNVx41tq3hZKV4)_Fixes#34497
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:场景评测的 template 模式,在迭代后的 Run
半程里,某个操作若会碰到前一步写入留下的改动,现在改在一份新起的副本上跑。副本是一台空白宿主,装入迭代后应用实际对外提供的元数据(去掉读时装饰键)。不再通过应用自己的接口把数据写回。
- 为什么改:写回会被应用自己的单向状态规则拒绝(例如 asset_lifecycle 的报废申请批准后不能退回
submitted),后续操作全部记为 NOT MEASURED,评分卡上就没有对 agent 的结论。
- 风险与回滚:只影响评测工具(已发布的评测包的运行器),不影响产品和用户。每份副本多一次启动和一次种子加载。回滚就是 revert 本
PR,template 模式回到写回。
- 先看:`packages/qa/scenarios/src/runner/orchestrate.ts` 中的
`iteratedManifest` 和 `withInstalledBuild` 的 `copyOf`;再看
`test/runner/orchestrate.test.ts` 里 #34448 describe 的 template 用例。
- 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run
test/runner/orchestrate.test.ts -t 34497`,预期 1 passed。
- 需要你做的:无,席位落地。
## What changes
- `templateMode` now gives its iterate Run half a `FreshCopy`
(`orchestrate.ts`). The copy is the same blank host, booted again, with
the iterated app installed unmanaged the way the run's own install
landed. Before, template mode wrote moved rows back through the app's
doors (`restoreSeededRows`), and an app's one-way state rule refused
that write-back.
- `iteratedManifest` (module-private) builds what the copy installs: the
manifest the run's install sent, with each served collection replaced by
the items the host serves after the iterate. Each item goes through
`stripReadDecorations` (`@objectstack/spec/kernel`) first. The spec says
a served body is no valid input to its own schema until its read
decorations are removed, and the unmanaged install door refuses a served
flow carrying `_diagnostics` (measured below).
- `withInstalledBuild` now hands `use` both `copyOf(manifest)` and
`manifest`. `fresh` is `copyOf(landed.manifest)`, as before. Ask mode is
unchanged.
- README bullet "Each operation starts from the seeded rows": scratch,
template and ask modes run the operation on a fresh copy, and door mode
(or any half given no copy) writes back. Changeset:
`@objectstack/scenarios` patch.
## Premise measurement (the card's gate, run before any change)
This was a live measurement on blank hosts scaffolded with
`create-objectstack@18.6.0`. No model ran. Host A installed
`docs/qa/scenarios/builds/travel_expense.json` unmanaged and then took
an iterate through `PUT /api/v1/meta/object/NAME`: a new object
`demotravel_travel_advance` with a `state_machine` validation, plus a
new lookup field `advance` on `demotravel_expense_claim`. Host B was a
fresh boot of the same project with A's served metadata installed
unmanaged. Both then got the card's personas and seed.
<details><summary>Readings</summary>
- Raw served items, as `metadataAsArtifact` returns them: B's install
answered `422 INVALID_METADATA`, refusing 3 flows for
`unrecognized_keys: _diagnostics`.
- With `stripReadDecorations` applied: B's install answered 200
(`copiedCount` 31). All 11 collections had the same names on A and B
(objects 8/8 including the iterate's new object, apps 1, views 6,
dashboards 1, reports 1, datasets 3, actions 4, flows 3, permissions 3,
skills 1, hooks 1). The per-item deep diff (fields, validations,
actions) found 0 differences. The only difference is
`objects/demotravel_travel_advance._packageId`, which reads
`sys_metadata` on A and `com.example.demotravel-copy` on B. That is the
protection envelope, not the item.
- Seed: A 757 inserted / 0 refused, B 757 / 0. Personas employee,
dept_manager and finance_officer were assigned on both. `seedDifference`
empty.
</details>
## Tests
- `#34448` describe: the case "without a fresh copy the same rule
refuses the write-back" is now "template mode: the iterate Run half
measures all six operations…". It runs `runCard` with `modes:
['template']` on `asset_lifecycle`. All six operations are asked and
measured. `dispose_scrapped_asset` carries `restored: { freshCopy:
['demoasset_disposal_request/dr06'] }`. No rule refusal happens, and the
iterated host took only its seed's writes. Every copy installed the same
objects as the iterated host, including the scripted iterate's object.
Every boot stopped.
- The one-way double (`OneWayApp`) now serves `_diagnostics` on metadata
reads, and its unmanaged install door refuses an item carrying it, as
the real door does.
- The `#34294` case "with no fresh copy (template mode)" is retitled "(a
Run half given none)". It still pins the write-back path, which door
mode uses.
<details><summary>Ablations (scripts/ablation-replace.mjs; tests import
src, no build leg)</summary>
- Template mode given no copy (`…opts.promptChoice, fresh);` changed to
`…opts.promptChoice);` in `templateMode`, blob b3da89c to ac741fb0).
The first attempt was refused with ANCHOR AMBIGUOUS (x2) and wrote
nothing. Rerun with a longer anchor: `-t 34497` gave 1 failed, with 3
operations NOT MEASURED: `restore: the rows could not be restored to the
seeded state: demoasset_disposal_request: 1 changed (dr06: status,
decided_on) (refused: update … 400 VALIDATION_FAILED …)`. Restored blob
equals HEAD, and `git diff HEAD` is empty.
- No read-decoration strip (`items.map(stripReadDecorations)` changed to
`items`, blob to fad3c78b): 1 failed, with 5 operations NOT MEASURED:
`restore: no fresh copy of the app could be seeded for it (unmanaged
install refused: 422 INVALID_METADATA …)`. Restored blob equals HEAD,
and `git diff HEAD` is empty.
</details>
## Verification
<details><summary>At head 89ea8b1 (after merging origin/main
0c047d0)</summary>
- `pnpm --filter '@objectstack/scenarios...' build`, then `pnpm --filter
@objectstack/scenarios test`: Test Files 40/40, Tests 1182/1182.
`typecheck` (`tsc --noEmit`) exit 0. Lock VERDICT command-exit 0.
- `dispatch-gates --commands --repo objectstack-ai/objectstack` derived
63 families. 61 exited 0 and 2 exited 3. `check-plugin-teardown-shape
--self-test` needed a shallow fixture; after `git fetch --depth=1` of
621a487 the rerun exited 0 with 48 cases. `check:dual-build-cjs-loads`
needs every package's dist, and CI runs it. `--ran` reconciliation: 63
derived, 61 run, 2 NOT-MEASURED, 0 UNRUN.
- `overlap-check --branch=HEAD --pr=35267`: clean. `check-nul-bytes`
exit 0.
</details>
## Acceptance notes
- The copy installs the collections the template carries, the same set
the iterate is scored on (`collections`). An iterate that adds an item
of a metadata type the template had none of is neither scored nor
copied. That gap already existed and is unchanged.
- Rows the agent inserted during the iterate turn, as opposed to
metadata, are not carried to a copy. The copy holds the card's seed
only, the same as the scratch and ask copies.
- Template-mode copies boot from the host project and install the
iterated app. A copy whose install is refused is NOT MEASURED, with the
door's answer.
- The dispatch named ADR-0148 D1/D2 as the scenario runner's shape. Read
at this head, ADR-0148 is the recycle-bin record, and its D1/D2
(snapshot store, restore under original ids) govern record restore in
the engine, not this runner. They do not bear on this change, so there
is no tension to resolve. The change stays inside the runner's Run half
and adds no mode, door or record field.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01Utp6CazXu8zyYD5PC6J2u7
<!-- signed: repo:objectstack#5 · os-bill ·
session_01Utp6CazXu8zyYD5PC6J2u7 -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(scenarios): template mode's iterate Run half runs an operation an earlier write would meet on a fresh copy of the iterated app, so a one-way state rule no longer leaves the operations after a transition unmeasured
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
Scratch and ask modes already ran such an operation on a fresh seeded copy of the app. Template mode still wrote the moved rows back through the app's own doors, because its app holds the agent's iterate, made live through those doors, which a host booted again from the project would not hold. On a card with a state machine the write-back met the app's rule: in `asset_lifecycle`, approving scrap request DR-0006 (`submitted` → `approved`) was followed by a write-back to `submitted`, refused with 400 `VALIDATION_FAILED`, and every later operation of the half read `restore: … not measured`.
11
+
12
+
Now template mode's copy is a blank host booted from the same project with the iterated app installed unmanaged, the same way the run's own install landed: the manifest that install sent, with each collection the app serves replaced by the items it serves after the iterate. Each served item comes off its read decorations first (`stripReadDecorations` from `@objectstack/spec/kernel`), because a served body is no valid input to its own schema until they are removed. The unmanaged install door refuses a served flow that still carries `_diagnostics` (422 `INVALID_METADATA`, measured on a blank 18.6.0 host). Measured on that host with the `travel_expense` verified build and an iterate made through `PUT /api/v1/meta/object/…` (one new object with a state-machine rule, one new lookup field): the copy serves the same objects, fields, validation rules and actions as the iterated host. The only difference is the new object's `_packageId` (`sys_metadata` on the host, the install's copy package on the copy). The card's seed loads alike there (757/757 rows, no refusal, every persona's permission set assigned).
13
+
14
+
The result carries `restored: { freshCopy }` as in the other modes. A copy whose install is refused, that does not boot, or whose seed does not load as the run's did makes the operation NOT MEASURED with that reason. Door mode still writes the rows back.
it('⛔ with no fresh copy (template mode), a restore that cannot be done makes the operation NOT MEASURED with the reason, not asked, never a pass or a fail',async()=>{
3601
+
it('⛔ with no fresh copy (a Run half given none), a restore that cannot be done makes the operation NOT MEASURED with the reason, not asked, never a pass or a fail',async()=>{
3602
3602
classNoDeleteAppextendsFakeApp{
3603
3603
overrideasyncdeleteRow(): Promise<HttpAnswer>{
3604
3604
return{ok: false,status: 403,body: {},code: 'PERMISSION_DENIED',message: 'refused by the double'};
3605
3605
}
3606
3606
}
3607
-
/** The Run half on the booted app alone, as template mode runs it: no fresh copy, so the rows are written back through its doors. */
3607
+
/** The Run half on the booted app alone, given no fresh copy, so the rows are written back through its doors. */
constREFUSAL='That status change is not allowed: a request is approved or rejected once, and only an approved one is disposed of.';
3655
3655
3656
-
/** The asset card's app as a well-built one is: a decided scrap request never goes back to submitted (400 VALIDATION_FAILED). Counts the writes its doors take. */
3656
+
/**
3657
+
* The asset card's app as a well-built one is: a decided scrap request never goes back to submitted (400 VALIDATION_FAILED).
3658
+
* Counts the writes its doors take. Its metadata reads carry the platform's read decoration (`_diagnostics`), and its
3659
+
* unmanaged install door refuses an item that still carries one, as a blank 18.6.0 host refuses a served flow.
it('template mode: the iterate Run half measures all six operations, each one an earlier write would meet on a copy installed with what the app serves after the iterate (#34497)',async()=>{
3727
+
const{ scenario, ops, driver, apps, life }=assetRun(()=>newOneWayApp());
it('⛔ a copy whose seed does not load as the run\'s did, or that does not boot, leaves the operation NOT MEASURED with the reason, never graded on other rows',async()=>{
0 commit comments