Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/34294-scenario-restore-seeded-rows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/scenarios': patch
---

feat(scenarios): every operation starts from the seeded rows: the runner undoes an earlier turn's write before the next operation runs

Clause-②: yes (widening) — new exports `restoreObjects`, `seededRows`, `restoreSeededRows` and types `SeededRows` / `RowRestore` (`orchestrate.ts`); `derivedFields`, `rowDrift`, `driftText`, `RESTORE_UNCOMPARED`, `RESTORE_UNWRITTEN` and types `HeldRow` / `RowDrift` (`seed.ts`); new optional member `AppHarness.deleteRow` and method `HttpApp.deleteRow` (`app.ts`); new optional fields `OperationResult.restored` (`orchestrate.ts`) and `HalfScores.operations.restored` (`scorecard.ts`); all of these reached through `./runner`. Operation grades after an earlier turn's write move: an operation that used to read the rows the turn before it left now reads the seeded rows.
Metadata-protocol: none

Until now a Run half ran every operation in card order on one seeded app, so a turn that wrote the wrong row, deleted one, or a probe the app wrongly stored, left the next operation starting from rows the card never declared. One bad write could fail two or three operations, and the operations score measured the cascade as much as each turn.

Now the runner reads the rows of every seeded object, and of every object an operation writes or its outcome reads, right after the seed loads. Before each operation it reads them again, and when an earlier turn moved them it puts them back as the admin: a row a turn added is deleted, a seeded row a turn removed is inserted again with the body the seed sent, and a changed column is set back to the value the seed left, in up to three rounds so a cascade settles. The clock, the last writer and the fields the build computes (formula, summary, autonumber) are neither compared nor written. The operation's result carries `restored` (`deleted`, `reinserted`, `setBack`), and the `Run-operations` cell adds `N started from restored rows`. Rows that still differ after the rounds make the operation NOT MEASURED with the reason (`restore: …`), never a pass or a fail.

The restore runs before an operation's first turn, never between a `pending_confirmation` operation's ask and its confirmation. Questions are untouched: they all run before any operation, at every `--ask-repeats` ask. A run where no earlier turn moved a row writes nothing and records and scores exactly as before. A replayed recording re-sends each operation's writes against the restored rows; where a later operation leaned on an earlier one's write, it reads NOT MEASURED (the replay is not faithful), never a fail.
16 changes: 16 additions & 0 deletions packages/qa/scenarios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,22 @@ npx @objectstack/scenarios help # the comma
reads the second NOT MEASURED, never a fail. The `Run-operations` cell adds `confirmed write k/N` beside the
`asked first` count, and the card states the sum on its own line. A card with no `pending_confirmation` operation
runs, records and scores exactly as before.
- **Each operation starts from the seeded rows** (`orchestrate.ts`, `seed.ts`, `app.ts`, `scorecard.ts`): right after
the seed loads, the runner reads the rows of every seeded object, and of every object an operation writes or its
outcome reads (`restoreObjects`), as the admin. Before each operation it reads them again and compares
(`rowDrift`: every column but `created_at`, `updated_at`, `updated_by` and the fields the build computes — formula,
summary, autonumber). When an earlier turn moved them (the agent's write, a probe's, a confirmed one, or a question
turn that wrote), it puts them back (`restoreSeededRows`): a row a turn added is deleted, a seeded row a turn removed
is inserted again with the body the seed sent, and a changed column is set back to the value the seed left, in up to
three rounds so a cascade settles. The operation's result then carries `restored` (`deleted`, `reinserted`,
`setBack`, each `object/id`), and the `Run-operations` cell adds `N started from restored rows`. Rows that still
differ after the rounds make the operation NOT MEASURED (`restore: the rows could not be restored …`, naming what
differs and the first refusals), never a pass or a fail on rows the card did not declare. The restore runs before an
operation's first turn, never between its ask and its confirmation; questions are untouched (they all run before any
operation). A run where no earlier turn moved a row writes nothing and records and scores exactly as before. A
replay re-sends each operation's recorded writes against the restored rows, so a recording made before restores
whose later operation leaned on an earlier one's write reads NOT MEASURED there (the replay is not faithful), never a
fail.
- **Language and build prompt** (`prompts.ts`, `orchestrate.ts`, `scorecard.ts`, `driver.ts`): `--lang zh|en` renders
every card-authored text a prompt carries in that language and no other — the build prompt (`prompt.short` or
`prompt.detailed`), the iterate change (`iterate.change`), and each question's and each operation's `ask` — in every
Expand Down
15 changes: 15 additions & 0 deletions packages/qa/scenarios/src/runner/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
* seed's second pass, `seedApp` in `orchestrate.ts`; read from the
* route's source, `packages/rest/src/crud-routes.ts`, not yet
* measured live)
* a restored row DELETE /api/v1/data/:object/:id (a row an earlier operation added,
* deleted before the next one runs, `restoreSeededRows` in
* `orchestrate.ts`; read from the same route source, not yet
* measured live)
* rows GET /api/v1/data/:object?limit=…
* the audit actor GET /api/v1/data/sys_audit_log?record_id=… (`user_id`)
* unmanaged install POST /api/v1/marketplace/install-local { packageId, manifest,
Expand Down Expand Up @@ -125,6 +129,13 @@ export interface AppHarness {
insertRow(object: string, row: Record<string, unknown>): Promise<HttpAnswer>;
/** Set fields on a row already in (the seed's second pass: the lookups that close a reference cycle). */
updateRow(object: string, id: string, patch: Record<string, unknown>): Promise<HttpAnswer>;
/**
* Delete a row, as the admin (a restore: a row an earlier operation added).
* Optional, so a harness written before restores keeps compiling; without it
* a restore that needs a delete cannot be done, and the operation is not
* measured.
*/
deleteRow?(object: string, id: string): Promise<HttpAnswer>;
listRows(object: string): Promise<HttpAnswer & { rows: Array<Record<string, unknown>> }>;
/** The `user_id` the newest audit row for this record names; `null` when none names one. */
auditActorUserId(object: string, recordId: string): Promise<string | null>;
Expand Down Expand Up @@ -272,6 +283,10 @@ export class HttpApp implements AppHarness {
return this.call('PATCH', `/api/v1/data/${encodeURIComponent(object)}/${encodeURIComponent(id)}`, patch, { session: this.admin });
}

deleteRow(object: string, id: string): Promise<HttpAnswer> {
return this.call('DELETE', `/api/v1/data/${encodeURIComponent(object)}/${encodeURIComponent(id)}`, undefined, { session: this.admin });
}

async listRows(object: string): Promise<HttpAnswer & { rows: Array<Record<string, unknown>> }> {
const r = await this.call('GET', `/api/v1/data/${encodeURIComponent(object)}?limit=1000`, undefined, { session: this.admin });
const records = (r.body as { records?: unknown } | null)?.records;
Expand Down
Loading
Loading