Skip to content

Commit 9a3a500

Browse files
fix(verify)!: run a managed mongodb datasource on verify's in-memory stand-in, refuse a managed plugin-driver datasource (#36171)
<!-- claude-projects-attribution: {"github_login":"os-project-manager"} --> _Requested by **Leehom** · [project thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1X1qGnTYLQs3EtmtCmjrcfCe)_ Fixes #35640 Ruling-ref: 7065449898 Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no published skill teaches which datasources `os verify` stands in or refuses; the rule ships in the `@objectstack/verify` README (updated here), which `skills/objectstack-project` already points readers to ## 维护者速读 - 开发者或 AI 跑应用自检时:文档型数据库的数据源以前会连真实库,现在换成内存库照常验证;插件驱动的托管数据源以前会改写真实库,现在自检直接拒绝启动并点名该数据源;插件用同名注册自己的驱动顶替托管数据源时,自检同样拒绝启动。 - 属于"应用自检只碰自己建的库"这条规则的收尾,替声明了文档型数据库或插件驱动数据源的应用作者解决自检改写真实库、事后无法恢复的问题。 - 只有声明了插件驱动托管数据源的应用会碰到:自检从能跑变为拒绝启动;目前仓库内与姊妹仓都没有这样的应用;本改动可以直接撤回。 - 要你做什么:这次改动让一类原来能跑的自检改为拒绝启动(收紧),按规则需要你本人批准后才能合并。 ## What changes Ruled on the card (maintainer, 「C+A 能换内存库就换,否则拒绝」, decision record 7065449898): verify writes only to stores it creates, for every engine the platform ships; a managed datasource on a plugin's driver id refuses the boot; no switch. - `packages/verify/src/managed-datasource-stand-in.ts`: `managedStandInEngine` now answers for every driver id the platform ships (`resolveDriverId` from `@objectstack/spec`, the same table the default driver factory's `supports()` reads): `memory` gets a fresh memory store, every other shipped engine, `mongodb` included, gets the default store's engine. The "shipped engine with no faithful stand-in keeps its real driver" branch is gone, and so is `hasManagedStandIn`. New `unstandableManagedDatasources(config)` lists every declared managed datasource (not `default`) on a driver id the platform does not ship, judged on the same `isManagedDatasource` reader the factory and derive use; `unstandableManagedDatasourceRefusal` is the sentence. The factory itself refuses such a spec instead of handing it to the real factory (unreachable from the connection service, whose `supports()` gate already turns it away; defence for direct callers). - `packages/verify/src/harness.ts`: `bootStack` refuses before it composes anything (first statement of the boot, before any env change or kernel) while such a datasource is declared, naming each datasource and driver id and why. `os verify` already prints a boot error and exits 1 (`packages/cli/src/commands/verify.ts` run-level catch), so no CLI change. - `packages/verify/src/derive.ts`: the "managed, no stand-in, withheld" branch and its report sentence are removed; objects on a managed `mongodb` datasource enter every derived family. - `packages/verify/src/managed-datasource-stand-in.ts` + `harness.ts` (rework round 1, contract review 7067086844 S1): the connection service keeps any driver already registered under a datasource's NAME, whatever driver id it declares, so a plugin registering `driver.NAME` under a managed datasource that declares a shipped id (`mongodb`, `postgres`, …) bypassed both the stand-in and the refusal. New `createManagedDatasourceDriverGuard(config)`: `bootClaimed` mounts it as the FIRST plugin whenever a managed datasource other than `default` is declared; its `start()` runs after every plugin's `init` (where plugin drivers register) and before any plugin's `start` (where ObjectQL adopts `driver.*`, syncs schemas, and the app connects and seeds), and refuses the boot when a `driver.NAME` service or an engine driver is held under a managed datasource's name, naming the datasource and its declared driver id. Rework round 2 (contract review 7068014028, S2 + N4): the guard now also matches each `driver.*` service by the driver instance's own `name` (the key the engine registers it under), and after its start-time check it wraps `registerDriver` on the engine instance, the engine's only way to put a driver under a name, so a driver registered later (ObjectQL's `driver.*` adoption, an `objectql:drivers-ready` handler, a later plugin) under a managed datasource's name that verify's factory did not build for it is refused before the engine holds it; the identity check reads a per-name ledger the verify factory fills with the exact instance it returns. `bootStack` rethrows the guard's own sentence with the kernel error as cause (N4). Rework round 3 (contract review 7069009856, S3 + N6–N8): the wrap forwards to the engine's own `registerDriver` when the engine already holds verify's stand-in under that name (the engine keeps the stand-in and discards the newcomer without calling it), so a late registration from an app plugin's `start()` or the `runtime.onEnable` bridge boots on the stand-in instead of being refused; a refusal a plugin catches still refuses the boot after `bootstrap()` returns, and a boot that failed for another reason keeps the kernel's own error (the guard's sentence only when the guard's own refusal is in the cause chain). Not covered, stated in the jsdoc: a plugin that replaces the `objectql` service, takes the guard's plugin name, calls the prototype's `registerDriver`, deletes or overwrites the own property, or a driver whose `name` answers differently on each read. No key, flag, boot option or package export added. The driver-id refusal now says the datasource names no driver id the platform ships ("a plugin's driver, or a misspelling") and prints a missing driver as `(no driver declared)` (N1). - Text: the `harness.ts` and stand-in headers, `packages/verify/README.md` (Posture), the `os verify` section of `content/docs/deployment/cli.mdx`, and one changeset `.changeset/35640-verify-memory-stand-in.md` (patch, `!`, BREAKING section with FROM/TO/fix for both refusals, ADR-0087 disposition `not-required (no-migration-prescription)`). Read first (by risk): 1. `packages/verify/src/managed-datasource-stand-in.ts` — the `managedStandInEngine` body and `unstandableManagedDatasources`: the "shipped" set and the managed reader both refusal and factory decide on. 2. `packages/verify/src/harness.ts` — the two lines at the top of `bootClaimed`: the refusal must precede every side effect; and the guard mounted before `ObjectQLPlugin`. `createManagedDatasourceDriverGuard` in the stand-in file: its `start()` check sees every `init`-time registration, and its `registerDriver` wrap with the factory ledger must catch every later one before the first write (ObjectQL `start()`: adoption, `ql.init()`, `drivers-ready`, then the first schema sync). 3. `packages/verify/src/verify.managed-datasource-stand-in.test.ts` — the mongodb recording medium (a TCP listener counting connections) and the refusal pin with its control. Two-minute check: `pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2 src/verify.managed-datasource-stand-in.test.ts` → `Tests 32 passed (32)`, including `nothing reached the real mongodb address: no connection was ever made to it` and `the boot is refused, naming the datasource and the driver id, and the recording driver is never called`. ## Tests The card's Done-when, pinned in `verify.managed-datasource-stand-in.test.ts` (the component's shared harness file, extended rather than a new file, one boot): - Boot pin, `mongodb`: the fixture declares a managed secondary `mongodb` datasource pointed at a local TCP listener that counts connections (the recording medium), seeds two rows on its object, and has an async `afterInsert` hook on another object writing into it. After CRUD, reference shapes, delete behaviours, unique scopes and a REST create: 0 connections to the listener; the object's CRUD case `verified`; both seed rows and the hook rows present in the stand-in (read back through REST); no hook error. CONTROL: the factory `os dev` uses (`createDefaultDatasourceDriverFactory`) connects to that listener for the same declaration. - Refusal pin, plugin driver id: a fixture declaring a managed datasource on a plugin's driver id, with a recording driver plugin and a seed: `bootStack` rejects with a sentence naming `datasource "vms_plug_ds" (driver "vms_plug_driver")`, and the recording driver's plugin never initialised, so no call reached it. CONTROL: in the boot above, the same recording plugin behind an EXTERNAL datasource (not refused) initialises and takes the REST create. - Refusal pin, name-keyed (round 1): a recording driver plugin registers `driver.vmd_docs_ds` under a managed datasource declaring `mongodb`, with a seed on its object: `bootStack` rejects naming `datasource "vmd_docs_ds" (driver "mongodb")` and "registered a driver of its own"; the driver's recorded calls are exactly `[plugin.init]` (no connect, no schema sync, no seed write). Unit pin: a missing driver reads `datasource "a" (no driver declared)`. - Refusal pins, round 2: a driver registered as `driver.vmk_elsewhere` whose instance is named after the managed datasource, and a driver registered on the engine from an `objectql:drivers-ready` handler for an object-bound managed datasource. Both booted on a81e777 (recorded calls ran through connect/syncSchema/seed `bulkCreate`/`updateMany`); at 26abb3e both are refused with the bare `verify: refusing to boot:` sentence and the driver's calls are `[plugin.init]` / `[plugin.init, drivers-ready]`. Ledger unit pin; the mongodb/SQL main boot is the no-false-refusal control. - Pins, round 3 (red on 26abb3e: `4 failed | 28 passed (32)`): a late registration from an app plugin's `start()` and from the `runtime.onEnable` bridge now BOOT on the stand-in (GET returns the seed, a REST POST answers 201 and lands in the stand-in; the foreign driver's calls are `[plugin.init, plugin.start]` / `[onEnable]`, no connect, sync or write); a `drivers-ready` handler that catches the refusal is still refused with the bare sentence; a caught refusal followed by the plugin's own start failure reports that failure, not the guard's sentence. - Unit pins: the factory builds `mongodb`, `turso` and `pg` as the default store's engine with nothing of the declared config, `mongodb` on a `memory` default store as a fresh memory store, and refuses a plugin driver id without asking the real factory; the refusal reader names managed plugin-driver datasources with or without a declared `schemaMode`, reads a name-keyed map, and (control) refuses no shipped engine, no external or validate-only plugin datasource and not `default`; `derive.test.ts` now pins that objects on managed `postgres`, `mongodb` and plugin-driver datasources (and a required reference to the mongodb one) are derived, not blocked. Reverse verification (each mutation landed and restored by `scripts/ablation-replace.mjs` or `git restore --source`, blob == HEAD and `git diff HEAD` empty after each; the tests import the changed files from `src/`, no `dist/` in the path): <details><summary>Readings</summary> - Base implementation (`3543b51d` versions of the three source files, new tests): the boot reaches the real mongodb address and fails fast (`datasource 'vms_docs_ds': connect failed — connection monitor to 127.0.0.1:32885 closed`); `Tests 8 failed | 7 passed | 8 skipped (23)`. The decision thread's probe re-run on base `3543b51d`: `connectionsToRealMongoAddress: 10`. - `mongodb` mapped to no stand-in again: the refusal (same reader) refuses the mongodb fixture; `Tests 3 failed | 12 passed | 8 skipped (23)`, VERDICT command-exit 1. - Refusal line deleted from `bootClaimed`: `× the boot is refused, naming the datasource and the driver id, and the recording driver is never called` — `expected undefined to be an instance of Error` (the boot succeeded on the plugin's driver); `Tests 1 failed | 22 passed (23)`. - Name-keyed guard's throw deleted (round 1, head a81e777): `× the boot is refused, naming the datasource and its declared driver id, and the plugin driver receives no call` — `expected undefined to be an instance of Error` (the boot ran on the plugin's driver); `Tests 1 failed | 24 passed (25)`; restored blob == HEAD. - Round 2 (head 26abb3e): own-name leg dropped ⇒ `1 failed | 27 passed` (the other-key pin is still refused, by the wrap, but not by the guard's start); `registerDriver` wrap removed ⇒ the drivers-ready pin boots, `1 failed | 27 passed`; N4 rethrow deleted ⇒ `3 failed | 25 passed`. Each restored to the HEAD blob. - Round 3 (head 205d953): S3 forward condition forced off ⇒ the two late-registration pins red, `2 failed | 30 passed`; post-return refusal disabled ⇒ the caught-refusal pin boots, `1 failed | 31 passed`; identity check replaced by reading `refusal` alone ⇒ the own-failure pin red, `1 failed | 31 passed`. Each restored to the HEAD blob. - derive withholding mongodb objects again: `× exercises objects on managed datasources of every shipped engine, mongodb included` — `doc_task: expected 'withheld' to be falsy`; `Tests 1 failed | 32 passed (33)`. </details> <details><summary>Package runs</summary> - `pnpm --filter @objectstack/verify test`: `Test Files 55 passed (55)`, `Tests 500 passed (500)` (head 205d953). - `pnpm --filter @objectstack/verify typecheck`: `tsc --noEmit` clean; `check:test-typecheck: OK — 0 file(s) / 0 error(s)`. </details> ## Acceptance notes - Premise P2 of the ruling, checked on `origin/main` 3543b51 before any code: a plugin driver is constructed by its plugin and registered as a `driver.NAME` service in the plugin's `init` (`packages/drivers/driver-odata/src/plugin.ts:201`); `ObjectQLPlugin` adopts every `driver.*` service (`packages/objectql/src/plugin.ts:1524`); the connection service then answers `already-registered` and never reaches the factory (`packages/services/service-datasource/src/datasource-connection-service.ts:607-613`), and for an unregistered plugin id its `factory.supports()` gate answers `skipped-unsupported` (`:693`); `supports()` is `resolveDriverId(id) !== undefined` (`default-datasource-driver-factory.ts:1131`). No single swap point exists: the instance is the plugin's (the connection service deliberately never evicts it). - "Shipped" = `resolveDriverId` / `BUILTIN_DRIVER_IDS` in `@objectstack/spec` (`packages/spec/src/data/driver/config-registry.zod.ts`), which that file states is exactly what the default factory builds. It includes the federation-only `oracle` and `mssql`, which a managed datasource cannot name at authoring; were one to reach verify anyway it would be stood in, never connected. - Two unreleased changesets on `main` (`.changeset/verify-managed-datasource-stand-in.md`, `.changeset/35640-verify-real-store-wording.md`) still describe `mongodb` and plugin drivers keeping their real driver. They are outside this claim's file surface, so they are not edited; the new changeset says it supersedes them for this release. - Not changed, as ruled: external datasources, a report line saying an object ran on a stand-in, and the mongodb driver's own disagreements with the stand-in. ## Verification Local gates, the derived set (`dispatch-gates.mjs --commands`), run one by one with each exit captured before any pipe; the readings are in the reports on the card (round 3: #35640 comment 7069764734, 105 derived, 102 exit 0, 3 prerequisite-not-met left to CI). Full dogfood battery on 205d953: `Tests 4101 passed | 68 skipped (4169)`, no failures. CI owns the full farm. Session: session_01FEkQ5kt9AD1TPLy7Y9oa9D 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#4 · os-project-manager · session_01FEkQ5krBqrrgxCYgjXmfbv --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6c7c6db commit 9a3a500

8 files changed

Lines changed: 1088 additions & 117 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/verify': patch
3+
---
4+
5+
fix(verify)!: a managed `mongodb` datasource runs on verify's in-memory stand-in, and a managed datasource on a plugin's driver id refuses the boot
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or export is added, removed, renamed or re-shaped, and no stored row changes. What moves is what `os verify` (and `bootStack`) does with a datasource an app already declares: a managed `mongodb` one is built in memory instead of on its real connection, and a managed one on a driver id the platform does not ship refuses the boot. There is nothing for a migration to rewrite and no tombstone. -->
11+
12+
Verify writes only to stores it creates. Until now that held for a managed datasource on a SQL engine or `memory`, but not for one on `mongodb` or on a driver id a plugin supplies: those kept their real driver, verify withheld only its own writes from their objects, and the app's seed, hooks and flows still wrote to the real database during the run, where verify could neither identify nor undo the rows it changed.
13+
14+
- **`mongodb`, and every other engine the platform ships.** A declared managed datasource (`schemaMode: 'managed'`, or none declared) on any driver id the platform ships, `mongodb` included, now runs on verify's ephemeral in-memory stand-in, the same store verify builds for the SQL engines: nothing of its declared connection is used, every write to its objects (verify's and the app's seed, hooks and flows) stays in memory, and its objects are exercised by every derived family. The CRUD report no longer lists them as `managed datasource "NAME" (driver "mongodb"): not exercised`.
15+
- **BREAKING: a managed datasource on a plugin's driver id refuses the boot.** Such a datasource cannot be stood in: the plugin builds and registers its own driver, and the boot would write through it. `os verify` now refuses to boot while one is declared (any name other than `default`), before anything is composed. The refusal names each such datasource and its driver id, says why, and `os verify` exits 1 with it.
16+
- FROM: `os verify` booted the app, left the datasource's objects out of its own write families, and let the app's seed, hooks and flows write to the real database behind the plugin's driver.
17+
- TO: `os verify` refuses to boot, naming the datasource and the driver id. There is no flag, boot option or metadata key around the refusal.
18+
- The fix for an app author: correct the driver id if it is a misspelling, or verify a configuration that does not declare that datasource.
19+
- **BREAKING: a plugin driver registered under a managed datasource's name refuses the boot.** The datasource connection service keeps a driver already registered under a datasource's name, whatever driver id the datasource declares, so a plugin that registers a driver under a managed datasource's name on a shipped id (`mongodb`, `postgres`, …) would have run it on the plugin's driver. `os verify` now refuses that boot, naming the datasource and its declared driver id, when the driver is registered before verify's stand-in holds the name: as a `driver.*` service (matched by its key and by the driver's own name, before any plugin starts), or into the engine from an `objectql:drivers-ready` handler or anywhere else (refused at the engine's `registerDriver`, before the engine holds it). Either way no connect, schema sync or write reaches the plugin's driver. A driver registered under the name once the stand-in holds it (an app plugin's `start()`, a `runtime.onEnable` bridge) is discarded by the engine, as before, and that boot runs on the stand-in.
20+
- FROM: when the plugin's driver took the datasource's name before verify's stand-in did, `os verify` booted on it, and the app's seed, hooks and flows (and, for a SQL id, verify's own writes) reached the store behind it.
21+
- TO: `os verify` refuses that boot, even when the plugin catches the refusal and carries on. No flag, boot option or metadata key around it.
22+
- The fix for an app author: verify a configuration whose plugins do not register a driver under a managed datasource's name. An external datasource (`schemaMode: 'external'` or `'validate-only'`) on a plugin's driver is not affected: verify keeps its real driver and withholds its own writes from its objects, as before.
23+
24+
This supersedes what two earlier notes in this release say about a managed datasource "with no faithful stand-in": neither `mongodb` nor a plugin's driver keeps its real driver under `os verify` any more.

‎content/docs/deployment/cli.mdx‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,13 +3067,16 @@ os verify --flow notify_on_new_case --flow-record '{"subject":"Printer jam"}'
30673067
on purpose. A write the app itself makes there, its seed or a hook or flow
30683068
that a stage's write fires, goes where the app sends it, as under `os dev`.
30693069
A declared managed datasource (`schemaMode: 'managed'`, or none declared) is
3070-
not connected to the database it names: verify runs it on a fresh in-memory
3071-
store, as it runs its own default one, so every write to its objects stays
3072-
in memory and they are still exercised. One whose engine has no in-memory
3073-
stand-in (`mongodb`, or a driver a plugin supplies) keeps its real driver,
3074-
and its objects are `skipped` as `managed datasource "NAME" (driver
3075-
"DRIVER"): not exercised`. Only verify's own writes are withheld: the app's
3076-
seed, hooks and flows still write to that real database. With `--rls`, a second fresh boot proves the
3070+
not connected to the database it names, on any engine the platform ships
3071+
(`mongodb` included): verify runs it on a fresh in-memory store, as it runs
3072+
its own default one, so every write to its objects, the app's seed, hooks
3073+
and flows included, stays in memory and they are exercised by every stage.
3074+
A managed datasource on a driver id the platform does not ship (a
3075+
plugin's, or a misspelling) cannot be stood in, so `os verify` refuses to
3076+
boot while one is declared: it names the datasource and the driver id and
3077+
exits 1. It refuses the same way when a plugin registers a driver of its
3078+
own under a managed datasource's name, whatever driver id the datasource
3079+
declares. There is no flag around either refusal. With `--rls`, a second fresh boot proves the
30773080
cross-owner invariant — a member must not write what it cannot read — for a
30783081
probe persona and for one persona per declared position, and a hole fails
30793082
the run. With `--reference-shapes`, another fresh boot proves that every

‎packages/verify/README.md‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,24 @@ don't exercise, silently breaks at runtime." Point this at *your* app.
8080
> itself makes to an external object (its seed, or a hook or flow that one of
8181
> verify's writes fires) goes where the app sends it, as under
8282
> `objectstack dev`. A declared MANAGED datasource (or one that declares no
83-
> `schemaMode`) is never connected to the database it names: verify builds it
84-
> as a fresh in-memory store of the same kind as its own default store, so its
85-
> objects are still exercised and every write to them, the app's included,
86-
> stays in memory. A managed datasource whose engine has no faithful in-memory
87-
> stand-in (`mongodb`, or a driver a plugin supplies) keeps its real driver,
88-
> and every derived write family leaves its objects out as `managed datasource
89-
> "<name>" (driver "<driver>"): not exercised`; the app's own seed, hooks and
90-
> flows still write to that real database during the run. Only the `--flow` run refuses
91-
> every write routed away from the in-memory default database.
83+
> `schemaMode`) is never connected to the database it names, on any engine
84+
> the platform ships (`mongodb` included): verify builds it as a fresh
85+
> in-memory store of the same kind as its own default store (a `memory`
86+
> datasource gets a fresh memory store), so its objects are exercised by every
87+
> derived family and every write to them, the app's seed, hooks and flows
88+
> included, stays in memory. A managed datasource on a driver id the platform
89+
> does not ship (a plugin's, or a misspelling) cannot be stood in: `objectstack
90+
> verify` refuses to boot while one is declared, naming the datasource and the
91+
> driver id, and exits non-zero. It refuses the same way when a plugin
92+
> registers a driver of its own under a managed datasource's name before the
93+
> stand-in holds it, whatever driver id the datasource declares, because the
94+
> boot would keep that driver instead of the stand-in: the driver is refused
95+
> before the engine holds it, so no connect, schema sync or write reaches it.
96+
> A driver registered under the name once the stand-in holds it is discarded
97+
> by the engine, and that boot runs on the stand-in. There is no switch around
98+
> either refusal. Only
99+
> the `--flow` run refuses every write routed away from the in-memory default
100+
> database.
92101
93102
## CLI (zero-config)
94103

‎packages/verify/src/derive.test.ts‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ describe('deriveCrudCases — objects on an external datasource are not exercise
117117
expect(cases.find((x) => x.object === 'side_task')?.blocked).toBeFalsy();
118118
});
119119

120-
// A managed SQL or memory datasource runs on verify's stand-in, so its
121-
// objects are exercised (`verify.managed-datasource-stand-in.test.ts`). One
122-
// whose engine has no stand-in keeps its real driver, so verify withholds
123-
// its own writes from its objects; the app's seed, hooks and flows still
124-
// reach that real store, and the reason says so.
125-
it('exercises an object on a managed SQL datasource, and withholds one on an engine with no stand-in', () => {
120+
// Every managed datasource on an engine the platform ships runs on verify's
121+
// stand-in, `mongodb` included, so its objects are exercised
122+
// (`verify.managed-datasource-stand-in.test.ts`), and so is an object that
123+
// requires one. A managed datasource on a plugin's driver id never reaches
124+
// derive in a run: `bootStack` refuses that boot before it composes, so
125+
// derive carries no second gate for it.
126+
it('exercises objects on managed datasources of every shipped engine, mongodb included', () => {
126127
const config = {
127128
datasources: [
128129
{ name: 'pg', driver: 'postgres', schemaMode: 'managed' },
@@ -137,17 +138,14 @@ describe('deriveCrudCases — objects on an external datasource are not exercise
137138
],
138139
};
139140
const cases = deriveCrudCases(config);
140-
expect(cases.find((x) => x.object === 'pg_task')?.blocked).toBeFalsy();
141-
expect(cases.find((x) => x.object === 'doc_task')?.blocked).toBe(
142-
'managed datasource "docs" (driver "mongodb"): not exercised — verify has no ephemeral stand-in for ' +
143-
"this engine, so it withholds its own writes; the app's seed, hooks and flows still write to the " +
144-
'real database',
145-
);
146-
expect(cases.find((x) => x.object === 'plug_task')?.blocked).toContain(
147-
'managed datasource "plug" (driver "acme-plugin-driver"): not exercised',
148-
);
149-
expect(cases.find((x) => x.object === 'doc_note')?.blocked).toContain(
150-
'required relational target "doc_task" is withheld on purpose — managed datasource "docs"',
141+
for (const object of ['pg_task', 'doc_task', 'plug_task', 'doc_note']) {
142+
const c = cases.find((x) => x.object === object);
143+
expect(c?.blocked, object).toBeFalsy();
144+
}
145+
expect(cases.find((x) => x.object === 'doc_task')?.body).toHaveProperty('title');
146+
// The required target is created first and its id threaded in.
147+
expect(cases.findIndex((x) => x.object === 'doc_task')).toBeLessThan(
148+
cases.findIndex((x) => x.object === 'doc_note'),
151149
);
152150
});
153151
});

‎packages/verify/src/derive.ts‎

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import { isMultiValueField, referenceCarrierOf } from '@objectstack/spec/data';
2323
import { declaredCollection } from './artifact-collections.js';
24-
import { hasManagedStandIn, isManagedDatasource } from './managed-datasource-stand-in.js';
24+
import { isManagedDatasource } from './managed-datasource-stand-in.js';
2525

2626
const COMPUTED = new Set(['formula', 'summary', 'autonumber', 'rollup', 'vector']);
2727
const RELATIONAL = new Set(['lookup', 'master_detail', 'master-detail', 'masterdetail', 'tree']);
@@ -210,9 +210,6 @@ interface Draft {
210210
* in. Only genuinely unsatisfiable shapes are `blocked`:
211211
* - an object on an external datasource (never written: verify writes only to
212212
* its ephemeral store), or
213-
* - an object on a declared managed datasource whose engine verify has no
214-
* ephemeral stand-in for (verify's own writes withheld; the app's seed,
215-
* hooks and flows still reach the real store), or
216213
* - a required relation whose target is missing from the app config (external), or
217214
* - a required-reference cycle (incl. a required self-reference), or
218215
* - a required relation whose target is itself blocked (cascade), or
@@ -272,20 +269,11 @@ export function deriveCrudCases(config: any): CrudCase[] {
272269
}
273270

274271
// An object on a declared MANAGED datasource runs on the ephemeral store
275-
// verify builds in that datasource's place (`./managed-datasource-stand-in.ts`),
276-
// unless its engine has no faithful stand-in: then the boot keeps the real
277-
// driver, and verify withholds its own derived writes from the object. The
278-
// app's seed, hooks and flows still write to that real store.
279-
// `default` is verify's own store whatever the app declares under that name.
280-
if (ds && obj.datasource !== 'default' && typeof ds.driver === 'string' && !hasManagedStandIn(ds.driver)) {
281-
d.blocked =
282-
`managed datasource "${obj.datasource}" (driver "${ds.driver}"): not exercised — verify has no ` +
283-
"ephemeral stand-in for this engine, so it withholds its own writes; the app's seed, hooks and " +
284-
'flows still write to the real database';
285-
d.withheld = true;
286-
drafts.set(obj.name, d);
287-
continue;
288-
}
272+
// verify builds in that datasource's place (`./managed-datasource-stand-in.ts`)
273+
// and is exercised like any other: every engine the platform ships has a
274+
// stand-in, and a boot declaring a managed datasource on a plugin's driver
275+
// id is refused before it composes. `default` is verify's own store
276+
// whatever the app declares under that name.
289277

290278
for (const [name, f] of Object.entries(fields)) {
291279
const type = String((f as any)?.type ?? '').toLowerCase();

0 commit comments

Comments
 (0)