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 0ba5e06
Browse filesBrowse the repository at this point in the historyBrowse files
feat(scenarios): gallery export owes the template mode — unmanaged install with the sample data copied (#38646)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_Fixes#35266
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:应用市场图库里的每个应用,上架前都要先像试用客户那样以"可编辑副本"方式装一遍,带着示例数据回答问数问题;导出的应用包本身也声明成可编辑副本安装的模板。
- 为什么做:属于"客户可以从应用市场中下载安装试用"这条路,替图库发布(下一步上架到应用市场)先证明试用装得上、装上就能用。
- 出错会怎样:试用安装被拒或副本上答错的应用不会进图库,原因写在图库 PR 的"Refused"一节;这是内部图库流水线,改动可整体回退。
- 要你做什么:无。
## What changes
- **Runner, `--template-sample-data`** (`src/runner/orchestrate.ts`,
`cli.ts`, `app.ts`, `scorecard.ts`): template mode installs the passing
scratch build unmanaged with the card's seed rows as the package's
`data[]` (the same `sampleDataOf` rows the export writes) and the
install door's seed copy on (`seedSampleData: true`). The fresh copies a
Run half moves to install the same way. The Run half then seeds nothing
(`seedFromCopy`). It reads the card's rows back from the copy, and a row
the copy does not hold is refused by name, so `seedDependence` leaves
every turn that reads it not measured. It binds the copied rows to the
persona users it creates after the copy: `owner_id`, a persona record's
`user` field and a user-handle field, one data-API update per row, only
where they differ. Then it asks over those rows. The record keeps the
door's report (`seed.copied`), the bound fields (`seed.bound`) and
`template.seedSampleData`. The scorecard's Seed cell reads `N/M copied
by the install`. Without the flag nothing changes, and the flag is
refused when `--modes` leaves template out.
- **Refresh** (`src/export/refresh.ts`): `runnerArgv` asks for `--modes
scratch,template --template-sample-data`, and the PR body's Run line
says so.
- **Pass rule** (`src/export/pass.ts`): the record owes the template
mode run that way. Each of these keeps the card out with a reason of its
own, which `refreshPrBody` lists under `Refused`: no template mode; a
template mode without the copy; a skipped template mode; an unmanaged
install the door refused (its status, code and message); a template half
that did not pass.
- **Trial package** (`src/export/trial-package.ts`, new
`src/export/stack-config.ts`): the config's `manifest` literal gains
`installModes: ['unmanaged']` through an AST splice, every other byte
kept, and `objectstack.manifest.json` gains `solutionType: 'template'`.
The export is refused, each case with its reason, when the manifest
cannot be read as written, when it declares install modes without
`unmanaged`, or when the build carries code `plugins` (`defineStack`
refuses that install mode beside code). Install modes already declared
with `unmanaged` are kept.
- **Check** (`src/export/check.ts`): new finding `app-install-modes`. It
fires when the `manifest:` literal of `source/objectstack.config.ts`,
read as written, has no `installModes` containing `'unmanaged'`. The
TypeScript API loads only when a config is judged, so an empty gallery
still loads none.
- README (modes table, refresh steps, check list) and one `patch`
changeset.
## Tests
The card's four pins, each ablated once and restored. Every mutation
landed through `scripts/ablation-replace.mjs`, and each restore was
proved by blob equal to HEAD and an empty `git diff HEAD`:
1. **A template-half refusal keeps a card out** (`exporter.test.ts`,
`[#35266] the gallery owes the template half…`). A 422
`UNMANAGED_INSTALL_UNCOPYABLE` install answer gives the door's words as
the first reason, followed by the three template halves `not-run`.
Nothing is exported, and the refresh PR body lists the card under `##
Refused (1)`. A failed template half, a record with no template mode,
and a template mode without the copy are each refused too. Ablation:
`pass.ts` install-refusal branch replaced with `else if (false)`, so 1
of 1 failed; restored.
2. **The sample-data questions run over the copied rows**
(`orchestrate.test.ts`, `runCard — --template-sample-data…`). Every
template-mode app holds exactly `sampleDataOf(card).datasets` and made 0
runner seed loads. `seed.copied` is `{ mode: 'inline', inserted: 8,
errors: 0 }`, and Sam's accounts are bound to the sdr's user. When the
copy does not hold a row, the template half's contact questions are not
measured while the scratch half, which uses the runner's own seed,
measures them. A copy that did not load refuses all 8 rows with the
door's reason. Without the flag the half seeds as before. Ablation:
`seedCopy ? seedFromCopy(` replaced with `false ? …`, so 4 of 5 failed;
restored.
3. **The exporter writes both manifest keys** (`exporter.test.ts`, the
trial-package describes). Ablation (a) dropped `withInstallModes` from
the config write: 2 failed. Ablation (b) deleted `solutionType`: 3
failed. Both restored.
4. **`--check` refuses a manifest without `unmanaged`**
(`check.test.ts`, `checkGallery — install modes…`). The finding fires
for no `installModes`, for `['managed']`, for a non-literal list and for
a non-literal manifest. `['managed', 'unmanaged']` passes clean, and so
does the exporter's own output. Ablation: the `checkInstallModes` call
deleted, so 3 failed; restored. Also smoke-run on the **built** bin:
`node bin/objectstack-scenarios.js export-gallery --check` on the
exporter's clean tree printed `gallery check: clean`, exit 0. The same
tree with the spliced line removed printed one `app-install-modes`
finding, exit 1.
<details><summary>Package suite and typecheck at 6e32cf7</summary>
- `pnpm --filter @objectstack/scenarios build && pnpm --filter
@objectstack/scenarios test` under the verify lock: `Test Files 45
passed (45)`, `Tests 1424 passed (1424)`, `VERDICT command-exit 0`.
- `tsc --noEmit -p packages/qa/scenarios/tsconfig.json`: exit 0.
</details>
## Acceptance notes
- **The persona binding after the copy is the runner's.** The copied
rows are the trial package's rows, owned by the installer, with
user-handle fields left unset. The persona users do not exist until the
half creates them, so the runner sets only the owner, the persona
record's `user` field and the handle fields, the same values its own
seed writes, before asking. Without that step every persona-scoped
question would read rows nobody owns. No row content comes from the
runner.
- **What the template half installs is the scratch FIRST build**, as
template mode always has (`runCard`'s `verified`). The iterate change is
then applied to the copy. The exported `source/` is the scratch project
after its own iterate, so the unmanaged install of that exact iterated
tree is not itself installed by the run. The new `plugins` refusal and
the check cover the two keys that decide `defineStack`'s verdict.
- **NOT MEASURED live**: the seed copy's answer shape (`data.seeded`
counts with no per-row list), the copy keeping the card's row ids, and
the admin's data-API update of `owner_id`. These were read from the
install door's source (`marketplace-install-local-plugin.ts`,
`loadUnmanagedCopySeeds`) and its dogfood
(`install-local-unmanaged-seed-copy`). The card's own verification
comment measured the ids kept on a real install. No live AI driver run
was made, per the dispatch. The proof is the package's doubles.
- In copy mode the sample rows already exist while the agent authors the
iterate change, as they would for a trial user. In runner-seeded mode
they arrive after it.
- The scorecard already drew one column per mode. A record now holds the
template mode, so `scorecard.md` shows it, and its Seed cell says the
rows were copied.
- The gallery's existing export (`asset_lifecycle`) carries an
`app-install-modes` finding under the next published check until the
next refresh rewrites it. The changeset says so.
- Outside this card, reported to the seat: the blank scaffold on `main`
now declares `data: [articles]`
(`packages/create-objectstack/src/templates/blank/objectstack.config.ts`).
The exporter's existing `withSampleData` refuses such a config with
"already declares `data:`" (probe on this tree: `REFUSED`). So once that
scaffold reaches a stable release, every card built on it would stay out
of the gallery. Not fixed here.
## Verification
Read first, by risk: `src/runner/orchestrate.ts` (`seedFromCopy` and the
`withInstalledBuild` hunk that adds `data` after the collections and the
baseline are read), `src/export/pass.ts` (`judgeRecord`'s template
reasons), `src/export/stack-config.ts`.
Two minutes: `pnpm --filter @objectstack/scenarios exec vitest run
test/runner/orchestrate.test.ts -t template-sample-data`. Expect 5
passed, with no `--` before the filter.
<details><summary>Gates (local subset, at 6e32cf7)</summary>
- Derived with `node scripts/pm/dispatch-gates.mjs --commands` at
`6e32cf71e`: 70 families. All 70 were run, and 69 exited 0.
- `node scripts/check-plugin-teardown-shape.mjs --self-test` first
exited 3 because this shallow clone could not reach its pinned fixture
commit. I fetched that one commit (`--depth=1`) and reran it: exit 0,
`48 cases pass`.
- `pnpm check:dual-build-cjs-loads`: exit 3, **NOT MEASURED**, reason
`PREREQUISITE NOT MET`: 63 packages have no `dist/`, and a full-repo
build is CI's job. Its `--self-test` passed (94 cases). As a narrower
local probe, every built CJS entry of `@objectstack/scenarios` loads
with `require` (`bin`, `cli`, `export-check`, `export`, `index`,
`runner`, `score-full`, `score`). The CI check-run is the verdict.
- `dispatch-gates --ran` with each exit code recorded: `70 derived
famil(ies) accounted for — 69 run, 1 NOT-MEASURED (1 DERIVED from a
recorded exit 3)`.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01ADHkmRar3Kkg6SpwVgaaVE
<!-- signed: repo:objectstack#3 · os-steve ·
session_01ADHkmRar3Kkg6SpwVgaaVE -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(scenarios): a gallery app exports only when it also installs as a trial copy, with its sample data, and answers there
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
`gallery-refresh` now runs `run-scenarios --modes scratch,template --template-sample-data`. The new `--template-sample-data` flag makes template mode install the passing scratch build unmanaged with the card's seed rows as the package's sample data (the same rows the export writes into `source/src/sample-data.json`) and the install door's seed copy on (`seedSampleData: true`). Its Run half then seeds nothing itself: it reads the card's rows back from the copy, binds the copied rows to the persona users it creates afterwards (`owner_id`, a persona record's `user` field, a user-handle field), and asks every question and operation over those rows. A card row the copy does not hold is refused by name, so every turn that reads it is not measured. The record keeps the door's report (`seed.copied`) and the bound fields (`seed.bound`), `template.seedSampleData` says the install asked for the copy, and the scorecard's Seed cell reads `N/M copied by the install`. Without the flag, template mode seeds as before. The flag is refused when `--modes` leaves template out.
11
+
12
+
The exporter's pass rule now owes the template mode run that way, beside scratch mode's six halves. A record without it, a template mode run without the sample data copied, a refused unmanaged install (the door's status, code and message are the reason) or a failed template half keeps the card out of the gallery. The reason shows in the refresh PR body under `Refused`.
13
+
14
+
The exported `source/` now installs as the customer's own editable copy. `objectstack.config.ts`'s `manifest` gains `installModes: ['unmanaged']` and `objectstack.manifest.json` gains `solutionType: 'template'`. A build that carries code `plugins` is refused, because `defineStack` refuses that install mode beside code. Install modes the build already declares with `'unmanaged'` are kept as they are.
15
+
16
+
`export-gallery --check` gains the `app-install-modes` finding: an app whose `source/objectstack.config.ts``manifest:` literal, read as written, declares no `installModes` containing `'unmanaged'`. A gallery tree exported before this release carries that finding until the next refresh rewrites it.
Copy file name to clipboardExpand all lines: packages/qa/scenarios/README.md
+14-7Lines changed: 14 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -471,7 +471,7 @@ npx @objectstack/scenarios help # the comma
471
471
| Mode | Steps |
472
472
|:---|:---|
473
473
|`scratch`|`create-objectstack` → the agent builds from the card prompt and the runner's data contract (`prompts.ts`) → `objectstack validate` / `build` / `verify` (proofs chosen from the tags) → score → `objectstack dev --fresh` → seed, one user + permission-set grant + API key per persona → every question as every persona it names and every operation as its persona, over the app's MCP → the iterate change → rebuild, re-score, re-run |
474
-
|`template`| a blank host project (`host<code>`) → boot → install the card's verified build **unmanaged** (`/api/v1/marketplace/install-local`, `installMode: 'unmanaged'`) → the agent applies the iterate change to the installed copy → score → seed → Run. A refused install is a finding in the record |
474
+
|`template`| a blank host project (`host<code>`) → boot → install the card's verified build **unmanaged** (`/api/v1/marketplace/install-local`, `installMode: 'unmanaged'`) → the agent applies the iterate change to the installed copy → score → seed → Run. A refused install is a finding in the record. With `--template-sample-data` (the gallery's run) the install carries the card's seed rows as the package's sample data, exactly as the gallery exports them, with the door's seed copy on (`seedSampleData: true`, `template.seedSampleData` in the record), and the Run half seeds nothing: it reads the card's rows back from the copy (one not there is refused by name, so what reads it is not measured), binds the copied rows to the persona users it creates after the copy (`owner_id`, a persona record's `user` field, a user-handle field, one update each; `seed.bound`), and asks over them. The scorecard's Seed cell reads `N/M copied by the install`|
475
475
|`ask`| the same install of the same verified build as `template`, into a blank host of its own → seed → Run, and nothing else: no authoring turn, no score, no iterate. Ask mode edits nothing, so a build the unmanaged door refuses `UNMANAGED_INSTALL_UNCOPYABLE` (it carries an item no environment row can hold, such as a `capability`) is installed unchanged through the same door with `installMode: 'managed'`; the record's `template.installMode` says which mode the run used, and `template.unmanagedRefusal` keeps the refusal it fell back from. No other refusal falls back, and template mode never does. Off by default (`--modes ask`, or `--modes scratch,ask`) |
476
476
477
477
-**Ask mode** (`orchestrate.ts`, `scorecard.ts`): `--modes ask` runs only the Run half — every question (with
@@ -798,16 +798,21 @@ that version, it prints one `skip: …` line and exits 0, having run nothing. It
798
798
`export/<version>` branch exists: that refresh was pushed and awaits review. Otherwise it:
799
799
800
800
1. runs every card the gallery may show (origin `generic`, tier `starter` or `delivery`; `--debut`: the first of them
801
-
by id) with `run-scenarios --modes scratch --packages published --create-version <version>`, so the apps are built
802
-
on exactly that release, the turns recorded;
803
-
2. exports with screenshots into the checkout (`export-gallery`'s rules: only a run that passed every half). Each
801
+
by id) with `run-scenarios --modes scratch,template --template-sample-data --packages published --create-version
802
+
<version>`, so the apps are built on exactly that release, the turns recorded, and each passing scratch build is
803
+
installed as a trial user installs it: unmanaged, the card's seed rows copied by the install, the iterate change
804
+
applied to the copy and the questions asked over the copied rows;
805
+
2. exports with screenshots into the checkout (`export-gallery`'s rules: only a run that passed every half, scratch
806
+
mode's and template mode's; a record without the template mode run so, a refused install or a failed template half
807
+
keeps the card out, its reason in the PR body under `Refused`; the scorecard shows both columns). Each
804
808
app's `source/` is written as a package a customer installs to try, after scoring so the build is never graded on
805
809
it (`src/export/trial-package.ts`): `objectstack.manifest.json` carries the card's English title and one-sentence
806
810
requirement as `displayName` and `description`, the Chinese pair under `translations.zh`, and the card's
807
811
`businessFunctions`; `src/sample-data.json` carries the card's seed rows as stack `data:` datasets (namespaced
808
812
objects, `externalId: 'id'`, a user-handle field left out), which `objectstack.config.ts` imports into its `data:`.
809
-
`installModes` and `solutionType` are not written: `installModes: ['unmanaged']` makes `defineStack` refuse an app
810
-
that carries code `plugins` or `capability` items, which an app on the standard scaffold does;
813
+
The config's `manifest` gains `installModes: ['unmanaged']` and the listing `solutionType: 'template'`, so the
814
+
package installs as the customer's own editable copy; a build that carries code `plugins` is refused, since
815
+
`defineStack` refuses that install mode beside code;
811
816
3. creates the branch `export/<version>`, commits `apps/` and `index.json` under the checkout's own git identity, and
812
817
prints the branch, the commit and a ready PR body.
813
818
@@ -875,7 +880,9 @@ tree: `index.json` that does not validate (absent is an empty gallery); an entry
875
880
(README, run record, scorecard and transcript in JSON and Markdown, `source/objectstack.config.ts`, at least one
876
881
screenshot, every listed screenshot on disk and none unlisted); an app whose package arrives with no sample data (no
877
882
`source/src/sample-data.json`, one that is not a non-empty list of stack `data:` datasets the spec's `SeedSchema`
878
-
accepts, each with a record, or a `source/objectstack.config.ts` that does not import it); a directory under `apps/` no entry lists; a
883
+
accepts, each with a record, or a `source/objectstack.config.ts` that does not import it); an app whose package does
884
+
not install as an editable copy (`app-install-modes`: the `manifest:` literal of `source/objectstack.config.ts`, read as
885
+
written, declares no `installModes` containing `'unmanaged'`); a directory under `apps/` no entry lists; a
879
886
`framework.version` that is not a stable release published for `@objectstack/cli` (read with `npm view … versions`,
880
887
only when the index lists an app); and anywhere in the tree a `.env*` name, a `node_modules` directory, a symbolic link
add('app-incomplete',`${rel}/${APP_LAYOUT.source}`,`a complete app directory holds its metadata source, ${APP_LAYOUT.source}/${SOURCE_REQUIRED} at least, and this one does not`);
add('app-install-modes',rel,`${trial}, and ${read.declared ? `this one declares [${read.modes.map((m)=>`'${m}'`).join(', ')}]` : 'this one declares none, which installs managed only'}`);
Copy file name to clipboardExpand all lines: packages/qa/scenarios/src/export/exporter.ts
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,16 @@
11
11
* 1. the card is loaded, marked generic and of a gallery tier ({@link GalleryGuard});
12
12
* 2. ⛔ the run was on published packages ({@link unpublishedRunRefusal}): a
13
13
* `--packages workspace` run is never exported or shown;
14
-
* 3. the record passed every half ({@link judgeRecord});
14
+
* 3. the record passed every half ({@link judgeRecord}): scratch mode's, and
15
+
* template mode's, run as a trial user installs the app (unmanaged, the
16
+
* card's sample data copied by the install), so a refused install or a
17
+
* failed template half keeps the card out;
15
18
* 4. the run's scratch project is still on disk, with its build, and its
16
19
* source can be made the trial package ({@link trialPackageSource}): its
17
20
* config default-exports a `defineStack({ … })` literal that declares no
18
-
* `data:` of its own, and the build declares every object the card seeds;
21
+
* `data:` of its own and a `manifest:` literal the unmanaged install mode
22
+
* can be written into, the build carries no code `plugins`, and it
23
+
* declares every object the card seeds;
19
24
* 5. its transcript joins with the recording ({@link buildTranscript});
20
25
* 6. its screenshots were taken, unless the caller turned them off.
21
26
*
@@ -26,7 +31,8 @@
26
31
* apps/<id>/README.md what the app is, the driver that ran it ({@link driverText}), what its authoring cost
27
32
* ({@link authorCostText}: stated only when every authoring turn reported a cost), its scorecard, the files
28
33
* apps/<id>/source/… the authored metadata source (`source.ts`), as a trial package: the
29
-
* card's listing text, facet and sample data added after scoring
34
+
* card's listing text, facet and sample data, the unmanaged install
35
+
* mode and the `template` solution type added after scoring
30
36
* (`trial-package.ts`)
31
37
* apps/<id>/run-record.json the run record, the work directories redacted (`workDirsOf`)
32
38
* apps/<id>/scorecard.json|.md the per-half scorecard
@@ -165,7 +171,7 @@ function appReadme(scenario: LoadedScenario, record: ScenarioRunRecord, entry: G
165
171
'',
166
172
'## Files',
167
173
'',
168
-
`- [\`${APP_LAYOUT.source}/\`](./${APP_LAYOUT.source}/) — the app's metadata source, as the AI wrote it (after the change request), with the package's listing text in \`objectstack.manifest.json\`and the card's seed rows as its sample data (\`${SAMPLE_DATA_FILE}\`, read into \`data:\`), both added after scoring`,
174
+
`- [\`${APP_LAYOUT.source}/\`](./${APP_LAYOUT.source}/) — the app's metadata source, as the AI wrote it (after the change request), with the package's listing text and solution type in \`objectstack.manifest.json\`, the unmanaged install mode in \`objectstack.config.ts\`, and the card's seed rows as its sample data (\`${SAMPLE_DATA_FILE}\`, read into \`data:\`), all added after scoring`,
169
175
`- [\`${APP_LAYOUT.transcriptMd}\`](./${APP_LAYOUT.transcriptMd}) — every data question, each persona's answer and its grade ([JSON](./${APP_LAYOUT.transcriptJson}))`,
170
176
`- [\`${APP_LAYOUT.scorecardMd}\`](./${APP_LAYOUT.scorecardMd}) — the scorecard ([JSON](./${APP_LAYOUT.scorecardJson}))`,
171
177
`- [\`${APP_LAYOUT.runRecord}\`](./${APP_LAYOUT.runRecord}) — the full run record`,
@@ -304,7 +310,8 @@ async function exportOne(
304
310
constauthored=readAuthoredSource(projectDir);
305
311
// The trial package's listing text, facet and sample data: added to the exported copy only, after scoring.
306
312
constbuiltObjects=newSet(((artifactas{objects?: Array<{name?: unknown}>}).objects??[]).map((o)=>o?.name).filter((n): n is string=>typeofn==='string'));
0 commit comments