Repository navigation
Commit 6910797
build(scenarios): a minimal unpublished build, and a narrow ./score entry that reads no objectql or plugin-sharing (#30938)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D6fapbH2zHLk3JPBFybbtnd)_
domain:devx#1 · os-elon-musk · session_016WV4cwgUKpQgCE3UWsA74d
Fixes #30915
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:私有包 `@objectstack/scenarios` 加了一个不发布的最小 tsup 构建(`dist/` 下 ESM
+ CJS + `.d.ts`),四个导出子路径全部指向构建产物;`./score` 改为窄入口,只含图形打分与答题/写操作评分,不再牵出
`objectql` 和 `plugin-sharing`;原先的完整入口改名为 `./score/full`。
- **为什么改**:按裁决 D 打分器搬进了这个包,但包里只有 `.ts` 源码,cloud 打包后用纯 Node 加载会报
ERR_MODULE_NOT_FOUND;内联打包又等于把源码复制进 cloud(2.87 MB → 3.95 MB),违反裁决。
- **风险与回滚**:包仍是 private、不发布;仓内的测试和 `run-scenarios` 仍直接读
`src/`,行为零改动。唯一外部消费者是 cloud#3604(尚未落地)。回滚即 revert。
- **先看**:① `packages/qa/scenarios/package.json` 的 `exports`(`./score` 与
`./score/full` 的分工);② `src/score/narrow.ts`(只做 re-export,没有搬文件);③
`turbo.json` 一行:本包 `test` 改为先跑本包 `build`。
- **两分钟验证**:`pnpm --filter @objectstack/scenarios build && pnpm --filter
@objectstack/scenarios exec vitest run test/build`,预期 5 个测试全绿。
- **需要你做的**:无,席位落地。
## What changes
`@objectstack/scenarios` (`packages/qa/scenarios`) exported `.ts`
sources only. A consumer that links the framework tree and bundles its
own entry with tsup leaves the dependency external, so plain Node then
loads `src/score/index.ts`, whose `.js` specifiers only a TypeScript
resolver follows: `ERR_MODULE_NOT_FOUND`, ESM and CJS alike (measured by
the cloud#3604 dev; reproduced here, see the ablation below).
1. **A minimal build, still private and unpublished.** `tsup.config.ts`
builds one entry per export subpath to `dist/` (ESM `.js`, CJS `.cjs`,
`.d.ts` / `.d.cts`, `splitting: false`, dependencies external), using
`tsconfig.build.json` (`rootDir: src`). `build` ends with
`check-dts-emitted.mjs` (8/8 declarations present). Every `exports`
subpath (`.`, `./score`, `./score/full`, `./runner`) now has `import` /
`require` conditions on the built files, wired the way `packages/lint`
is (a `type: module` multi-entry tsup package; no private package under
`packages/` had a tsup build to copy). The suites and `run-scenarios`
(`tsx src/runner/cli.ts`) import `src/` relatively and are untouched; no
in-repo package imports `@objectstack/scenarios` by specifier.
2. **A narrow `./score` entry.** `src/score/narrow.ts` re-exports
`scenario-graph`, `scenario-naming`, `scenario-operation-grade`,
`scenario-run-grade` and `scenario-score` (so `scoreGraphShape`,
`artifactToEvalGraph`, `gradeRun`, `gradePersonaRun`, `gradeOperation`,
…). Its import graph reads `@objectstack/core` and `@objectstack/spec`
only. The previous whole entry, `src/score/index.ts`, is unchanged code
and is now `./score/full`: it adds the capability-tag checks
(`scenario-tags.ts`, which read `@objectstack/objectql` and
`@objectstack/plugin-sharing`) and the card-level `scoreCardArtifact` /
`gradeCardOperation` / `gradeCardAnswer`. No score module moved, so
#30883 (editing score behaviour in `src/score/**`) does not collide.
3. **Wiring.** `turbo.json`: `@objectstack/scenarios#test` depends on
`build` (was `^build`), so the package's own `dist/` exists before its
suite runs; `turbo run test --filter=@objectstack/scenarios --dry=json`
lists `@objectstack/scenarios#build` as the test's dependency. Any
`turbo run build` / `pnpm build` (the root script) now builds the
package, which is how a pinned framework tree is built.
`docker/Dockerfile` in this repo installs published packages and builds
no workspace package, so it needs nothing.
READMEs (`packages/qa/scenarios/README.md`,
`docs/qa/scenarios/README.md`) and the `index.ts` header name the two
entries.
## Tests
- `test/build/built-consumer.test.ts`: a throwaway package that depends
on `@objectstack/scenarios`, imports `scoreGraphShape` statically and
`import()`s `@objectstack/scenarios/score`, is built with the repo's
tsup (`--format esm,cjs`). The test asserts the bundle keeps the
specifier external and does not carry the scorer, then loads
`dist/index.js` and `dist/index.cjs` with plain `node`. A preloaded
`module.registerHooks` resolve recorder lists every URL the child
resolves: the scorer loads from `packages/qa/scenarios/dist/`, nothing
from `src/`, nothing matching `objectql` or `plugin-sharing`, and
(control) `@objectstack/core` is seen.
- `test/build/narrow-score-graph.test.ts`: walks the source import graph
from `src/score/narrow.ts` (type-only imports included) and asserts no
`@objectstack/objectql` / `@objectstack/plugin-sharing` specifier, and
the exact `@objectstack/*` set it reads. Control: the same walker from
`src/score/index.ts` finds both.
## Acceptance notes
- **Surface move inside a private package.** `./score` no longer exports
`scoreCardArtifact`, the `scenario-tags` exports, `gradeCardOperation`
or `gradeCardAnswer`; they are under `./score/full`. The card's
acceptance requires `./score`'s graph to exclude objectql and
plugin-sharing, and the two card-level graders live in `index.ts` beside
`scoreCardArtifact`, so keeping them in `./score` would have meant
moving code out of `index.ts`, which the claim's serial constraint with
#30883 rules out. Its only out-of-repo consumer, cloud#3604, reads
`scoreGraphShape` and the run grader, both in `./score`.
- **Changeset.** `skip-changeset`: the package is private (the dispatch
order's fast lane). Measured: the Check Changeset job
(`.github/workflows/pr-automation.yml`) exempts on the label alone and
has no private-package branch, so nothing there asks a private package
with a build for a changeset. Earlier PRs on this package did carry
`'@objectstack/scenarios': patch` changesets (`.changeset/30289-…`,
`30291-…`, `30292-…`); `.changeset/config.json` has `privatePackages: {
version: true, tag: false }`, so a changeset would only bump the private
version.
- **Twin declarations.** tsup emits a `.d.ts` and a `.d.cts` per entry,
the simple `packages/lint` pattern, not `packages/core`'s
single-declaration pass. The runner exports classes, but no consumer
reaches this package through both resolution modes today.
## Verification
All at `e748dfb0a0`, the final head (`origin/main` `26c965cb8f` merged,
which brought #30846's loader change).
- `pnpm --filter @objectstack/scenarios build`: exit 0,
`check-dts-emitted: @objectstack/scenarios - 8/8 declared declaration
file(s) present.`
- `pnpm --filter @objectstack/scenarios test`: `Test Files 20 passed
(20)`, `Tests 256 passed (256)`. `typecheck`: exit 0.
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` (exit 0) derived 65 commands; all 65 ran,
every one exit 0. `pnpm check:dual-build-cjs-loads` first exited 3
(PREREQUISITE NOT MET, no dist for 61 packages) and exited 0 after a
whole-tree `turbo run build` (119/119 tasks). `dispatch-gates.mjs
--ran`: exit 0, "65 derived famil(ies) accounted for — 65 run, 0
NOT-MEASURED".
<details><summary>Ablation 1: the pre-fix export (`./score` import
condition back on src/score/index.ts)</summary>
`node scripts/ablation-replace.mjs --file
packages/qa/scenarios/package.json --anchor '"default":
"./dist/score.js"' --replacement '"default": "./src/score/index.ts"' --
… vitest run test/build/built-consumer.test.ts`: mutation landed (anchor
1 → 0, blob 144f294 → 0d0da83a). Both plain-Node legs red with the
card's error, `Error [ERR_MODULE_NOT_FOUND]: Cannot find module
'…/packages/qa/scenarios/src/schema.js' imported from
…/src/score/index.ts`. Restored: blob == HEAD, `git diff HEAD` empty.
</details>
<details><summary>Ablation 2: the narrow entry re-exports
scenario-tags</summary>
`ablation-replace.mjs --file packages/qa/scenarios/src/score/narrow.ts
--anchor "export * from './scenario-graph.js';" --replacement "export {
artifactToEvalGraph } from './scenario-graph.js';\nexport * from
'./scenario-tags.js';"` then `pnpm build`: `ablation-dist-preflight.mjs
@objectstack/scenarios "@objectstack/plugin-sharing"` → marker live in
dist. `vitest run test/build`: 3 failed | 2 passed (the source-graph leg
and both plain-Node legs red; the full-entry control and the
external-bundle check stay green). Restored: blob == HEAD, `git diff
HEAD` empty; rebuilt, `grep -c 'plugin-sharing\|objectql'` on
`dist/score.js`, `dist/score.cjs`, `dist/score.d.ts` = 0 each, and
`test/build` 5/5 green.
</details>
<details><summary>65 gates, exit codes at e748dfb</summary>
```text
node scripts/check-adr-links.mjs :: exit 0
node scripts/check-adr-links.mjs --self-test :: 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-console-intercept-disarm.mjs :: exit 0
node scripts/check-console-intercept-disarm.mjs --self-test :: exit 0
node scripts/check-dts-emitted.mjs --self-test :: exit 0
node scripts/check-issue-citations.mjs :: exit 0
node scripts/check-osv-exemptions.mjs :: exit 0
node scripts/check-osv-exemptions.mjs --self-test :: exit 0
node scripts/check-plugin-teardown-shape.mjs :: exit 0
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/docs-audit/check-affected-docs.mjs :: exit 0
node scripts/docs-audit/check-drift-comment.mjs :: exit 0
node scripts/osv-base-relative.mjs --self-test :: exit 0
pnpm --filter @objectstack/lint run check:doc-formula-expressions :: exit 0
pnpm --filter @objectstack/spec run check:duration-unit-keys :: exit 0
pnpm --filter @objectstack/spec run check:llms-txt :: exit 0
pnpm check:changeset-fixed :: exit 0
pnpm check:ci-filter-parity :: exit 0
pnpm check:closed-ceremony-text :: exit 0
pnpm check:cross-package-test-inputs :: exit 0
pnpm check:doc-authoring :: exit 0
pnpm check:driver-memory-census :: exit 0
pnpm check:dts-closure :: exit 0
pnpm check:dual-build-cjs-loads :: exit 0
pnpm check:engine-double-contract :: 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:manifest-repository-directory :: exit 0
pnpm check:merge-driver :: exit 0
pnpm check:nul-bytes :: exit 0
pnpm check:objectql-double-limit :: exit 0
pnpm check:org-identifier :: exit 0
pnpm check:override-consistency :: exit 0
pnpm check:page-declaration-shape :: exit 0
pnpm check:platform-object-tenancy-census :: exit 0
pnpm check:pnpm-flag-spellings :: 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: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:turbo-task-graph :: 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:vendor-export-contract-resolve :: exit 0
pnpm check:watch-hint-literal :: exit 0
pnpm check:where-matcher :: exit 0
pnpm check:workspace-manifest-cycles :: exit 0
```
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_016WV4cwgUKpQgCE3UWsA74d
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwgUKpQgCE3UWsA74d)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent af1d59b commit 6910797
10 files changed
Lines changed: 358 additions & 16 deletions
File tree
- docs/qa/scenarios
- packages/qa/scenarios
- src/score
- test/build
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
168 | | - | |
| 168 | + | |
169 | 169 | | |
170 | 170 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
27 | | - | |
28 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
29 | 40 | | |
30 | 41 | | |
31 | | - | |
| 42 | + | |
32 | 43 | | |
33 | 44 | | |
34 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
13 | 61 | | |
14 | 62 | | |
| 63 | + | |
15 | 64 | | |
16 | 65 | | |
17 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments