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 ac0f928
Browse filesBrowse the repository at this point in the historyBrowse files
fix(verify): a bootStack artifact boot registers its metadata door ahead of the app, as os dev does (#38638)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9St4eUWHFcCKuRUrCZPperJ)_Fixes#36274
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 用户能看到什么变化:用户无感;变化在测试工具里,开发者用它启动编译产物时,演示数据的读法现在和本地开发启动一致。
- 为什么做:替应用作者和车队解决“测试工具里演示数据关联都对、本地开发启动却存错”的假绿,上一张修复的种子关联缺陷在测试工具里测不出来。
- 出错会怎样:只影响用这个测试工具启动编译产物的测试;万一有问题,表现为这类测试里元数据读到的对象和以前不同,撤回本次改动即恢复原样。
- 要你做什么:无
## What changes
**Cause (measured).** Both boots seed through the same
`SeedLoaderService`; what differs is what `metadata.getObject` holds
when the inline seed runs in `AppPlugin.start()`.
- `os dev` over a compiled artifact (`createStandaloneStack`, and the
CLI's dev artifact door) registers a `MetadataPlugin` with
`artifactSource` AHEAD of the app. Its `start()` loads each object as
its own package wrote it, so by seed time the metadata service's copy of
the extended object lacks the field another package adds through
`objectExtensions`.
- `bootStack` never got there. With `BootOptions.artifact` it composed
only the artifact-less lazy `MetadataPlugin`. With a caller's
`MetadataPlugin({ artifactSource })` in `extraPlugins`, that plugin was
registered in the `extraPlugins` slot, AFTER `AppPlugin`, so its
artifact load ran after the seed. Either way the seed read the copy
ObjectQL's one-shot bridge had put into the empty metadata service (the
harness's `ObjectQLPlugin` has no `environmentId`): the registry's
folded object, extension included. So the pre-#36272 resolver (metadata
copy first) resolved the natural key under verify and stored it raw
under `os dev`.
- Not the cause: the registrar option and `unwrapEnvelope`.
`loadCompiledArtifact` already reads with `unwrapEnvelope: true`. The
registrar decides who registers the four security collections; it does
not touch the object copy a seed reads.
**Fix (`packages/verify/src/harness.ts`): the `metadata` slot boots like
`os dev`.**
- `bootStack(config, { artifact })` composes `MetadataPlugin({ watch:
false, artifactWatch: false, artifactSource: { mode: 'local-file', path
}, rootDir: hostRoot })` over the same file the app is mounted from. It
is registered in the metadata slot, ahead of `AppPlugin`, and the app
gets `securityMetadataRegistrar: 'artifact-door'`, exactly as
`createStandaloneStack` declares both. One value
(`composesArtifactDoor`) decides both.
- A `MetadataPlugin` in `extraPlugins` is registered in the metadata
slot, ahead of the app, and skipped in the `extraPlugins` loop. The
harness still composes none of its own beside it.
- A source boot (no `artifact`, no caller `MetadataPlugin`) is
unchanged, and so is an app that declares a `MetadataPlugin` in its own
`plugins`.
- `loadCompiledArtifact` now also returns the `location` it resolved.
The docblocks of `bootStack`, `BootOptions.artifact` and
`BootOptions.extraPlugins` say where the door sits and why.
`packages/verify/README.md` names the door and its slot.
- `.changeset/36274-verify-artifact-metadata-door.md`:
`@objectstack/verify` patch.
## Tests
New pin: `packages/verify/src/harness.seed-extension-lookup.test.ts`. It
boots a two-package artifact of the #35254 shape: module
`com.example.sxl.mod` adds `quote_ref` (lookup to `sxl_quote`) to the
app's `sxl_order` through `objectExtensions`, and seeds `O-1` with
`quote_ref: 'Acme Quote'`. There are two legs, `bootStack(config, {
artifact })` and `bootStack(artifact, { extraPlugins: [MetadataPlugin({
artifactSource })] })`. Each leg asserts:
- precondition: the metadata service's copy of `sxl_order` has no
`quote_ref`, which is the copy `os dev` holds;
- `quote_ref` stores the quote's id;
- CONTROL: `account_ref`, the owner's own lookup, stores the account's
id.
<details>
<summary>Measurement: what getObject held at seed time, per boot
(pre-#36272 resolver)</summary>
The resolver body of `8925d5bc^` was put back in the worktree, never
committed (blob 2713d6f4cb, the same blob #36272's ablation used).
`@objectstack/metadata-protocol` was rebuilt, and
`ablation-dist-preflight.mjs @objectstack/metadata-protocol
'fromMetadata?.fields'` read the marker present in `dist/`. A scratch
probe (not committed) wrapped
`SeedLoaderService.prototype.resolveObjectDefinition` and recorded, for
the extended object, whether the metadata copy and the engine schema
carried the extension field.
| boot | harness | metadata copy at seed time | engine schema | stored
`quote_ref` |
|:--|:--|:--|:--|:--|
| `bootStack(config)` (source) | origin/main | has the field | has it |
quote id |
| `bootStack(config, { artifact })` | origin/main | has the field | has
it | quote id |
| `bootStack(artifact, { extraPlugins: [MetadataPlugin(artifactSource)]
})` | origin/main | has the field (after boot: absent) | has it | quote
id |
| `createStandaloneStack({ artifactPath })` kernel (the `os dev`
composition) | n/a | **absent** | has it | not read (see below) |
| `bootStack(config, { artifact })` | this branch | **absent** | has it
| **`"Acme Quote"`** |
| `bootStack(artifact, { extraPlugins: [MetadataPlugin(artifactSource)]
})` | this branch | **absent** | has it | **`"Acme Quote"`** |
The standalone-stack leg composes only the stack's own plugins (no
`AuthPlugin`), so its rows were refused for a missing organization. Its
seed-time reading is the measurement there. That `os dev` stores the raw
key on this resolver was measured on #36272 (`os dev --fresh`, PR body
table).
</details>
<details>
<summary>Ablation of the pin (rebuild + on-disk mutation
proof)</summary>
The fix was committed first (d11ad49). The red leg used the same
put-back resolver as above, with the dist marker present (preflight exit
0):
- `vitest run src/harness.seed-extension-lookup.test.ts`: 2 failed, 4
passed. Both seed pins were red: `expected 'Acme Quote' to be
'Jxi4WdPdRfw5yZh3'` (artifact leg) and `expected 'Acme Quote' to be
'uI0EwppDilcGU-qA'` (caller-door leg). The two preconditions and the two
CONTROLs stayed green.
- Restore: `git checkout HEAD --
packages/metadata-protocol/src/seed-loader.ts`. The blob reads
fdbca4a, the HEAD blob, and `git status --porcelain` showed only the
untracked scratch probe, since deleted. After the rebuild, `--absent`
read the marker absent from all 24 built files.
- Green: 6 of 6 pin tests pass.
</details>
<details>
<summary>Suite and gate readings</summary>
- `pnpm --filter @objectstack/verify typecheck`: exit 0
(`check:test-typecheck: OK`).
- `pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2`
(whole package): `Test Files 56 passed (56)`, `Tests 515 passed (515)`.
- Flip sweep: every dogfood file that hands `bootStack` a
`MetadataPlugin` or an `artifact` (16 files), run against the rebuilt
`@objectstack/verify` dist: `Test Files 16 passed (16)`, `Tests 206
passed (206)`. No existing test flipped.
- `dispatch-gates.mjs --commands` at ce65d57 derived 75 families, and
every one ran locally, each exit captured before any pipe. 74 exited 0.
`node scripts/check-plugin-teardown-shape.mjs --self-test` exited 3
(PREREQUISITE NOT MET: its fixture commit is out of this shallow clone's
reach), so it is NOT MEASURED locally and CI runs it. `--ran`
reconciliation: "75 derived, 74 run, 1 NOT-MEASURED, 0 UNRUN", exit 0.
- The first pass at da23bd2 caught `check:test-source-alias` exiting 1
on the new pin, which loaded `@objectstack/service-automation` inside a
case's clock. ce65d57 adds the module-top side-effect imports, and the
gate exits 0. The whole list was re-run on that head (the reading
above). The pin re-ran there too: `Tests 6 passed (6)`. `typecheck` exit
0.
</details>
## Acceptance notes
- **The dogfood-guidance sentence is not owed.** The Done-when offers it
only for a harness that seeds through another path on purpose. The
measurement shows the divergence was an accident of slot order, now
fixed, so `.claude/skills/dogfood-verification/SKILL.md` is untouched.
- **Not changed, same shape:** a `MetadataPlugin` declared in the app's
own `plugins` is still registered in the app-plugins slot after
`AppPlugin`, while `serve` registers it ahead of the wrap. No producer
was measured; noted, not filed.
- **Not changed:** a caller's `MetadataPlugin` with an `artifactSource`
leaves the app's registrar at `'app-plugin'`. The harness cannot know
that the caller's door reads the same file the app is mounted from, so
both still register the four security collections, as before this
change.
- **Not changed:** the harness's `ObjectQLPlugin` still has no
`environmentId`, so its one-shot bridge still copies registry objects
the artifact does not carry into the metadata service. The door's load
supersedes the bridge for every object the artifact carries.
## Verification
Files to read first, by risk:
1. `packages/verify/src/harness.ts`, the metadata-slot hunk
(`callerMetadataPlugins` / `composesArtifactDoor`) and the
`extraPlugins` loop's skip.
2. `packages/verify/src/harness.seed-extension-lookup.test.ts`.
3. `.changeset/36274-verify-artifact-metadata-door.md`.
Two-minute check: `pnpm --filter @objectstack/verify exec vitest run
--maxWorkers=2 src/harness.seed-extension-lookup.test.ts` should print
`Tests 6 passed (6)`.
🤖 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>
fix(verify): a `bootStack` boot of a compiled artifact fills its `metadata` slot the way `os dev` does, so it seeds the way `os dev` seeds
6
+
7
+
Clause-②: no
8
+
Metadata-protocol: none
9
+
10
+
`bootStack` could pass a seed that `os dev` stored wrongly. The case measured: a module package adds a lookup to the app package's object through `objectExtensions`, and seeds it by the target's natural key. On `os dev` the metadata service holds each object as its own package wrote it, because the `MetadataPlugin` that loads the artifact starts before the app seeds. Under `bootStack` that plugin started after the app's seed, or was not composed at all, so the seed read the registry's copy with the extension folded in. With the seed loader as it was before it learned to read the engine's schema first, `os dev` stored the raw key and `bootStack` stored the target's id, so a `bootStack` test could not catch the defect.
11
+
12
+
Now:
13
+
14
+
-`bootStack(config, { artifact })` composes a `MetadataPlugin` that loads the same artifact, ahead of the app, and the app leaves the four security collections (`positions`, `permissions`, `capabilities`, `sharingRules`) to it, as `os dev` declares it.
15
+
- A `MetadataPlugin` passed in `extraPlugins` is registered in the `metadata` slot, ahead of the app, instead of after it. The harness composes no `MetadataPlugin` of its own beside it, as before.
16
+
17
+
A source boot (no `artifact`, no `MetadataPlugin` in `extraPlugins`) is unchanged.
0 commit comments