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 5756ae0
Browse filesBrowse the repository at this point in the historyBrowse files
feat(scenarios): the gallery export writes each app as a trial package (listing text, facet, sample data); the check refuses an app with no sample data (#35430)
Fixes#35132
Clause-②: yes
Metadata-protocol: none
## 维护者速读
-
改了什么:应用市场画廊导出的每个应用,现在都带上场景卡的中英文标题和简介、业务职能分类,以及卡上的种子数据(作为安装时的示例数据)。画廊检查会拒绝没有示例数据的应用。
- 为什么改:目标是「客户可以从应用市场中下载安装试用」。之前导出的应用装上后是空的,名字是 `Demoasset`,也没有分类。
- 风险与回滚:风险低。只改导出副本和检查,不碰运行时,不碰被评分的构建。回滚就是还原这个
PR。用旧版导出器写出的画廊目录,在下一次刷新重新导出之前,新检查会报 `app-sample-data`;检查只读不写,不会删除任何应用。
-
先看:`packages/qa/scenarios/src/export/trial-package.ts`(`withSampleData`
对 AI 写的配置做的 AST 拼接,以及四种拒绝情况)→ `src/export/check.ts`(`checkSampleData`)→
`src/export/exporter.ts`(`trialPackageSource` 的调用点)。
- 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run
--maxWorkers=2 test/export`,预期 4 个文件、132 个测试全部通过。
- 需要你做的:无,席位落地。
## What changes
The gallery exporter (`packages/qa/scenarios/src/export/`) now writes
each app's `source/` as a package a customer can install and try. It
does this after scoring, into the export copy only. The run's own
project is never written.
- `objectstack.manifest.json`: `displayName` and `description` are the
card's English title and `prompt.short`. The Chinese pair goes under
`translations.zh`. `businessFunctions` is the card's own list. The
build's other keys are kept.
- `src/sample-data.json`: the card's seed rows as stack `data:`
datasets. There is one dataset per object, named `demoCODE_object`, with
`externalId: 'id'` and rows as the card states them. A
`run.userHandleFields` field is left out, and the app README names it.
- `objectstack.config.ts`: gets one import line and `data:
gallerySampleData` as the first property of the default-exported
`defineStack({ … })` literal. The edit is a TypeScript AST splice, and
every other byte stays as the AI wrote it. Four cases are refused with a
located reason, never guessed: there is no such literal, the literal
already declares `data:` or spreads a value, a seeded object is missing
from the build, or the build already wrote the file.
- `export-gallery --check` has a new finding, `app-sample-data`. It
reports a missing `source/src/sample-data.json`, a file that is not a
non-empty list of `SeedSchema`-valid datasets each with a record, or a
config that does not import it.
- `typescript` moves from devDependencies to dependencies. It was
already in the install closure through `@objectstack/lint`. The exporter
loads it with a dynamic `import()`, so `export-gallery --check`
(`dist/export-check.js`) never loads it.
- Not written, per the seat's re-split on the card: `installModes`,
`solutionType: 'template'`, and the check's installModes refusal. These
moved to #35266, which is blocked by #35157. With `installModes:
['unmanaged']`, `defineStack` refuses an app carrying `plugins` or
`capability` items (`packages/spec/src/stack.zod.ts:2843`).
## Tests
All at head `30a918ccf0`.
- `test/export/exporter.test.ts` has a new top-level describe, "the
trial package". It pins the manifest's four keys with the build's keys
kept. It pins the sample data: namespaced, keyed on `id`, crm's
`account.owner` left out. It pins the config edit: one import, `data`
first, and the rest byte-identical to the authored file. It checks that
the run's project is untouched and that the README line is present. It
also covers a scaffold-shaped config, a config with no import line, six
refused config shapes, three refused sources, one refusal through
`exportGallery` (no app directory written), and `sampleDataOf` over
every card in the library.
- `test/export/check.test.ts`: the exporter's own output is still clean.
There are four `app-sample-data` cases, and the code roster is updated.
<details><summary>Readings: package suite, typecheck,
ablations</summary>
- `os-verify-lock … vitest run --maxWorkers=2` (whole
`@objectstack/scenarios` suite): `Test Files 40 passed (40)`, `Tests
1199 passed (1199)`, `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/scenarios typecheck`: exit 0.
- Ablation 1: `ablation-replace.mjs` deleted the `checkSampleData(dir,
app, add);` call (anchor 1 → 0, blob 0d9fd6d → 0c9d9b17). Result:
`Tests 4 failed | 37 passed (41)`, which is exactly the four sample-data
cases. Restored blob 0d9fd6d equals the HEAD blob, and `git diff HEAD`
is empty.
- Ablation 2: the `trialPackageSource` call was replaced with the
authored files as they are (blob 7b14425 → 16986a84). Result: `Tests 32
failed | 67 passed (99)` across exporter and check suites. Among them
are the layout test, the trial-package export test and the `data:`
refusal export test; the check's clean tree goes red, as do the other
cases that copy it. Restored blob 7b14425 equals HEAD.
</details>
## Acceptance notes
- Measured, as the seat asked: the exported source still passes
`objectstack validate` with the new keys, on a managed stack. A probe
project used the blank scaffold's `objectstack.config.ts` verbatim
(connector plugins included), the recorded `travel_expense` build's 7
objects, and `trialPackageSource` output with 757 rows. `os validate`
printed `✓ Validation passed`, exit 0. The control project without the
trial edits also exited 0. A negative leg, with one dataset renamed to
`demotravel_nope`, exited 1 with `Seed data references object
'demotravel_nope' which is not defined in objects.`, so the validator
reads the imported JSON. The probe dropped the three `state_machine`
validations from the probe objects in both projects. Without that, both
projects failed identically on `state-machine-no-initial-states`, an
author-time rule unrelated to `data:`. The probe projects were deleted.
- Measured, as the seat asked: no app the exporter emits on refresh is
refused or deleted by the new refusals. The check pin "the exporter's
own output … has no finding" runs the new check over this exporter's
output. The exporter's new refusals cannot fire on the gallery's apps as
far as in-repo evidence reaches. Every one of the 9 cards seeds only
objects in its `expect.objects`, and the recorded `travel_expense` build
declares all 7 seeded objects. That build artifact carries no `data`,
and the probe's scaffold config shape takes the edit. For
`asset_lifecycle`, 6973237961 added `data:` to the gallery source by
hand, and 559 rows (the card's full count) inserted with 0 errors, so
the source had no `data:` of its own. The gallery repository itself is
not readable from this session, so its other listed apps were not
checked directly. A tree written by the earlier exporter has no
sample-data file, so the check reports each of its apps until the next
refresh re-exports it. The check writes nothing.
- `order_to_cash`'s English title is 131 characters.
`PackageSchema.displayName` allows at most 128, and its
`objectstack.manifest.json` fails `TemplateManifestSchema` (measured).
The exporter writes it anyway rather than refuse the app (a refusal
would delete a listed app). This is reported to the seat as a decision;
see the report.
- The scaffold's `objectstack.manifest.json` keeps `readmePath:
'README.md'`, but the exporter never copies the scaffold README into
`source/`. `os package publish` reads `readmePath` and exits 1 when the
file is missing (`publish.ts:883`, read, not run). carrier: #35134.
- `manifest.name` in the config (the in-app package name, e.g.
`Demoasset`) is unchanged: the listing name is
`objectstack.manifest.json` `displayName`. carrier: #35134.
- Sample rows carry the card's own dates (its `asOf`), not the run
date's rebase.
- Public surface of `@objectstack/scenarios/export`: new exports
`sampleDataOf`, `listingManifest`, `withSampleData`,
`trialPackageSource`, `TrialPackageRefusal`, `SAMPLE_DATA_FILE`,
`SAMPLE_DATA_SPECIFIER`, `SAMPLE_DATA_BINDING` and the type
`SampleDataset`. `FINDING_CODES` gains `app-sample-data`, so the check
accepts less. There is one new runtime dependency, `typescript`.
## Verification
<details><summary>Gates (local subset, head 30a918c)</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 75 families. All 75 ran: `✓
dispatch-gates --ran: 75 derived famil(ies) accounted for — 75 run, 0
NOT-MEASURED (a DERIVED zero …)`.
- `pnpm check:cross-package-test-inputs` was red on a first draft, which
read the blank scaffold config from `create-objectstack`. The pin now
uses an inline scaffold-shaped fixture, and the gate exits 0 (`OK: 32
package(s) read outside themselves, all declared …`).
- `pnpm check:dts-closure` and `pnpm check:dual-build-cjs-loads` both
exited 1 once in the sweep, naming only `@objectstack/organizations`'s
`dist/index.d.ts` (a package this diff does not touch) while its `dist/`
was being rewritten. On re-run both exited 0: `260/260 declared
declaration file(s) present`, and `124 published require entry point(s)
… load`.
- `node scripts/check-platform-checklist.mjs --changed-from
origin/main`: exit 0, 0 anchored files.
- `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0`
(origin/main, #35129 and #34223 merge cleanly).
- The repo-wide lint and the full CI battery are left to CI.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01Q4EjjNq58cmHeqckjZkTFE)_
<!-- signed: repo:objectstack#6 · hotlong ·
session_01Q4EjjNq58cmHeqckjZkTFE -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
feat(scenarios): the gallery export writes each app as a package a customer can install and try (listing text, business-function facet, sample data), and the gallery check refuses an app with no sample data
6
+
7
+
Clause-②: yes
8
+
Metadata-protocol: none
9
+
10
+
The exporter now adds three things to each app's `source/`. It adds them after the run is scored, so the AI's build is never graded on them, and it never writes them into the run's own project.
11
+
12
+
-`objectstack.manifest.json` gets the card's listing text and facet. `displayName` and `description` are the card's English title and one-sentence requirement. The Chinese pair goes under `translations.zh`. `businessFunctions` is the card's own list, primary first. The build's other keys are kept.
13
+
-`src/sample-data.json` holds the card's seed rows as stack `data:` datasets: one per object, named with the app's namespace, keyed on the card's row id (`externalId: 'id'`). Lookup values name row ids of the same load. A user-handle field (`run.userHandleFields`) is left out of every row, because its value names a user of the run's own environment, and the app README says which field was left out.
14
+
-`objectstack.config.ts` gets one import line and `data: gallerySampleData` as the first property of its default-exported `defineStack({ … })` literal. Every other byte stays as the AI wrote it. The export is refused, with the reason, in four cases: the default export is not such a literal, the literal already declares `data:` or spreads a value, a seeded object is missing from the build, or the build already wrote `src/sample-data.json`.
15
+
16
+
Measured on `travel_expense`: the blank scaffold's `objectstack.config.ts`, with the recorded build's objects and the 757 seed rows added this way, passes `objectstack validate`. A dataset naming an object the build lacks is refused there ("Seed data references object … which is not defined in objects"), which shows the validator reads the imported file.
17
+
18
+
`export-gallery --check` has a new finding, `app-sample-data`. It reports an app whose `source/` has no `src/sample-data.json`, a file that is not a non-empty list of datasets the spec's `SeedSchema` accepts (each with at least one record), or a `source/objectstack.config.ts` that does not import it. A gallery tree written by an earlier exporter has no sample-data file, so the check reports each of its apps until the next refresh exports them again. The check writes nothing and deletes no app.
19
+
20
+
`installModes` and `solutionType` are not written yet: `installModes: ['unmanaged']` makes `defineStack` refuse an app that carries code `plugins` or `capability` items, which an app on the standard scaffold does. `typescript` moves from a dev dependency to a dependency. The exporter loads it, with a dynamic import, only when it edits a config.
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`);
if(!isFile(config))return;// an incomplete source is `app-incomplete` already
199
+
constrel=`${source}/${SAMPLE_DATA_FILE}`;
200
+
constfile=join(dir,rel);
201
+
if(!isFile(file)){
202
+
add('app-sample-data',rel,`a gallery app is a package a customer installs to try, and it arrives with the card's seed rows as its sample data in ${APP_LAYOUT.source}/${SAMPLE_DATA_FILE}; this one has none`);
add('app-sample-data',`${source}/${SOURCE_REQUIRED}`,`does not import '${SAMPLE_DATA_SPECIFIER}' into its \`data:\`, so the package installs without its sample data`);
`- Sample data: the card's ${Object.values(c.run.seed).reduce((n,rows)=>n+rows.length,0)} seed rows in ${Object.keys(c.run.seed).length} objects${omitted.length ? `, without ${omitted.map((f)=>`\`${f}\``).join(', ')} (a user handle of the run's own environment, left unset)` : ''}`,
147
154
'',
148
155
'## The requirement',
149
156
'',
@@ -158,7 +165,7 @@ function appReadme(scenario: LoadedScenario, record: ScenarioRunRecord, entry: G
158
165
'',
159
166
'## Files',
160
167
'',
161
-
`- [\`${APP_LAYOUT.source}/\`](./${APP_LAYOUT.source}/) — the app's metadata source, as the AI wrote it (after the change request)`,
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`,
162
169
`- [\`${APP_LAYOUT.transcriptMd}\`](./${APP_LAYOUT.transcriptMd}) — every data question, each persona's answer and its grade ([JSON](./${APP_LAYOUT.transcriptJson}))`,
163
170
`- [\`${APP_LAYOUT.scorecardMd}\`](./${APP_LAYOUT.scorecardMd}) — the scorecard ([JSON](./${APP_LAYOUT.scorecardJson}))`,
164
171
`- [\`${APP_LAYOUT.runRecord}\`](./${APP_LAYOUT.runRecord}) — the full run record`,
@@ -294,7 +301,10 @@ async function exportOne(
294
301
if(!existsSync(projectDir))thrownewRefused([`the run's scratch project is gone: ${projectDir}`]);
295
302
constartifact=readArtifact(projectDir);
296
303
if(artifact===undefined)thrownewRefused([`${projectDir} holds no dist/objectstack.json`]);
297
-
constsource=readAuthoredSource(projectDir);
304
+
constauthored=readAuthoredSource(projectDir);
305
+
// The trial package's listing text, facet and sample data: added to the exported copy only, after scoring.
306
+
constbuiltObjects=newSet(((artifactas{objects?: Array<{name?: unknown}>}).objects??[]).map((o)=>o?.name).filter((n): n is string=>typeofn==='string'));
0 commit comments