Skip to content

fix(verify): run a declared managed datasource on an ephemeral stand-in, never its real database - #35635

Merged
objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-35523-verify-managed-datasource-ephemeral
Nov 19, 2026
Merged

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/issue-35523-verify-managed-datasource-ephemeral

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #35523

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:应用作者在本地跑应用自检时,若某个对象绑在声明为"平台托管"的辅助数据源上,自检写的测试数据从此只落进自检自己的临时内存库,不再写进那个数据源指向的真实数据库;这些对象照样被检查。
  • 为什么做:自检要求"测试数据只写进临时库",上一轮只管住了外部数据源,托管数据源这一半还在往真实库里写。
  • 出错会怎样:最坏情况是某类托管库被误判,其对象在自检报告里显示为"未检查"而非被写入;这是一处纯自检工具改动,可直接撤回。
  • 要你做什么:无

What changes

os verify builds every declared datasource through its own driver factory (packages/verify/src/managed-datasource-stand-in.ts), which wraps the one objectstack dev uses (createDefaultDatasourceDriverFactory):

  • A declared datasource whose resolveDatasourceSchemaMode(spec) is managed (or that declares none) is built as a fresh in-memory store: a SQL engine (sqlite, sqlite-wasm, postgres, mysql, turso) gets the engine of verify's own default store (sqlite-wasm :memory:, or memory under databaseDriver: 'memory'), and a memory datasource gets a memory store with no persistence. The stand-in is built by the real factory from a spec of verify's own (name, engine, in-memory config), so nothing of the declared connection (url, credentials, pool, persistence) reaches it. This is the swap ruling A on verify: the in-process handle boots a leaner stack than serve and has no door for eight things an app's tests need (requires[] capabilities, system/predicate update, the form door, user-less triggers, …), measured by hotcrm#2013 #22301 already makes for default; the harness header now says it covers declared managed stores too.
  • An external datasource keeps its real driver: reads reach it, and deriveCrudCases keeps writes off it (unchanged from fix(verify): os verify writes nothing to an object on an external datasource, even one whose write gate is open #35509).
  • A managed datasource whose engine has no faithful stand-in (mongodb, or a driver id the platform ships no contract for, i.e. a plugin's, which the factory never builds anyway) keeps its real driver, and deriveCrudCases withholds its objects from every write family: managed datasource "NAME" (driver "DRIVER"): not exercised — verify has no ephemeral stand-in for this engine and never writes through to the real one. A datasource named default is exempt: verify's own store holds that name.
  • Cascade wording: a managed object that requires a withheld target (external, or the case above), directly or transitively, now reads required relational target "X" is withheld on purpose — REASON instead of is not synthesizable. A target blocked for a field shape keeps the generic sentence.
  • derive.ts comment fixed: only the schemaMode half is the engine's write gate; the object's external block is verify's own trigger.
  • Docs brought into line: packages/verify/README.md, the harness.ts header, and the os verify section of content/docs/deployment/cli.mdx.
  • Patch changeset for @objectstack/verify. No new flag, option or export (the module is not re-exported from index.ts).
  • One reader for managed (L1-a M1, head bb1259f): isManagedDatasource in managed-datasource-stand-in.ts (resolveDatasourceSchemaMode: spec.schemaMode, then external.schemaMode, then config.schemaMode; absent = managed) decides both the factory (stand-in or real driver) and deriveCrudCases (withhold as external or exercise). So a datasource spelling schemaMode only inside config or external gets its real driver for reads, and its objects are withheld from every write family as external datasource "NAME" (read-only): not exercised. The module header names this reader as the authority.

Tests

New packages/verify/src/verify.managed-datasource-stand-in.test.ts:

  • Boot pin: a managed secondary datasource on a real, file-backed sqlite-wasm database (the file is the recording driver). After CRUD, reference shapes, delete behaviours, unique scopes and a REST create, the real database file was never created ({ exists: false, rows: 0 }).
  • Coverage kept: the bound object's CRUD case is verified against the stand-in; the REST create answers 201 and reads back 200.
  • CONTROL: the factory objectstack dev uses (createDefaultDatasourceDriverFactory), given the same declaration, opens that file and writes a row into it.
  • Factory unit pins against a recording real factory: managed postgres and mode-less sqlite become sqlite-wasm :memory: (secret and host dropped); managed memory loses its persistence; external and managed mongodb pass through unchanged.

derive.test.ts: withheld-on-purpose cascade wording (direct and transitive), the generic sentence kept for a field-shape block, and managed postgres exercised vs mongodb / plugin driver withheld.

L1-a M1 pins (head bb1259f): derive.test.ts withholds the config.schemaMode and external.schemaMode spellings (it.each); the stand-in test passes a config.schemaMode: 'external' postgres declaration to the real factory unchanged and withholds its derive case. Red on 2de0d50 (derive.ts restored, tree only): 3 failed / 40 passed; green on bb1259f: 43 passed; ablation of the one-reader line (anchor if (obj.external || (ds && !isManagedDatasource(ds))) {, blob 17ddde7d → 261e62e9): the same 3 red, restored blob == HEAD. Full package on bb1259f: Test Files 55 passed, Tests 478 passed; typecheck exit 0.

Red on origin/main, green on head, one ablation
  • Red on origin/main (harness.ts + derive.ts restored from d2bc1ff, tree only; restored with git checkout HEAD --, git diff HEAD empty): × nothing reached the real database with + "exists": true, + "rows": 11; Tests 1 failed / 8 passed; lock VERDICT command-exit 1.
  • Green on head 2de0d50: vitest run src/verify.managed-datasource-stand-in.test.ts src/derive.test.ts → Test Files 2 passed, Tests 40 passed; VERDICT command-exit 0.
  • Ablation (scripts/ablation-replace.mjs, anchor driverFactory: createVerifyDatasourceDriverFactory({ x1 → x0, blob fd6fa6de → dfceaaa6): the same pin red with "rows": 11; restored blob == HEAD, git diff HEAD empty. No dist leg: the suite imports the harness from src/.
  • Full package: pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2 → Test Files 55 passed, Tests 475 passed (head 2de0d50). pnpm --filter @objectstack/verify typecheck exit 0.

Acceptance notes

  • A managed mongodb datasource (and a plugin-driver one) keeps its real driver, so the app's own seed and hooks still reach it during os verify, as for an external datasource; only verify's derived writes are withheld from it. Route A scopes the change to verify's own writes.
  • The control does not boot os dev; it builds the declared datasource through the same factory os dev composes and writes the real file, which is what proves the boot pin's silence is the stand-in.

Verification

Read first: packages/verify/src/managed-datasource-stand-in.ts (create: the managed / stand-in decision), packages/verify/src/derive.ts (the new withheld branch and the Pass 2 cascade), packages/verify/src/harness.ts (the factory wiring).

Two-minute check: pnpm --filter @objectstack/verify exec vitest run src/verify.managed-datasource-stand-in.test.ts shows 9 passed; on origin/main's harness.ts it shows the real database file with 11 rows.

Derived gates (dispatch-gates --commands at bb1259f, 104 families)

All 104 derived families ran locally at head 2de0d50 and again at bb1259f (same 104-family list), each exit 0 (exit codes captured before any pipe). dispatch-gates --ran: 104 derived famil(ies) accounted for, 104 run, 0 NOT-MEASURED (a derived zero: all 104 recorded an exit code). check:skill-examples and check:dual-build-cjs-loads first answered exit 3 (prerequisite: unbuilt dist) and were re-run after the workspace build check:type-check-debt performs: both exit 0. CI-only families (dogfood shards, Dogfood Verify CLI, Build Core, the type-check lanes) are left to CI.


Generated by Claude Code

@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

10 anchor(s) derived from 1 changed package(s); no hand-written page names any of them. ⚠️ 1 changed file(s) yielded no anchor (packages/verify/README.md), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/verify/README.md) — pages documenting those are invisible to this run
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 8 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 2495486fd542c9aa1d48bfda32fae3b3f6a48a61 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from e4bf4b76dd951b47e261f7d638cf4369cc8f5e51 — the merge of head 2b4a90265b1891e160ea175ac17ebdbd1f4ea829 into base 2495486fd542c9aa1d48bfda32fae3b3f6a48a61, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin e4bf4b76dd951b47e261f7d638cf4369cc8f5e51 && git checkout e4bf4b76dd951b47e261f7d638cf4369cc8f5e51
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 2495486fd542c9aa1d48bfda32fae3b3f6a48a61 2b4a90265b1891e160ea175ac17ebdbd1f4ea829 && git checkout -B drift-repro 2495486fd542c9aa1d48bfda32fae3b3f6a48a61 && git merge --no-ff 2b4a90265b1891e160ea175ac17ebdbd1f4ea829

node scripts/docs-audit/affected-docs.mjs --json 2495486fd542c9aa1d48bfda32fae3b3f6a48a61

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt

Final green head for L1: 2de0d505dc73fcbf8e4f16c19760590077ee8edd(2026-11-19T20:07Z)

  • CI on this head: 42 success, 17 skipped, 0 failed (59 check runs). Dogfood Verify CLI and the dogfood shards were skipped by the CI path filter, so the boot pin in verify.managed-datasource-stand-in.test.ts (Test Core) is the measurement for the harness change.
  • Size: +507/-23 over 8 files, most of it tests. check-governed-merges.mjs reports NOT governed, under the 3000-line threshold.
  • Dev report: os verify still writes test rows through a declared managed secondary datasource, which can point at a real database #35523 comment 7020247281. The boot pin is red on origin/main's harness.ts + derive.ts (the real file holds 11 rows) and green with the fix. The ablation of the factory wiring turns the same pin red; it was restored afterwards. A CONTROL shows that the factory os dev uses writes the file.
  • PR body: the seat restored the backticked gate names that the shell had removed from the "Derived gates" paragraph (issue_patch, read-back identical). No other change.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-sales · session_01L6bhgTcFanGhTvqS1V2Q4U

维护者速读

  • 用户能看到什么变化:os verify 运行时,应用声明的托管数据源改用临时的内存库,不再连到它指向的真实数据库。没有可信替身的引擎(如 mongodb),verify 不往里写,并在报告里写明原因。
  • 为什么还没收:有一种写法会让两处代码对「这个数据源是不是托管的」判断不一致。数据源把 schemaMode 写在 config 里时,verify 生成的测试数据仍会写进真实数据库。需要先改成同一个判断。
  • 要你做什么:不需要你做任何事,区域改完再审。

席位核对 — REWORK (L1-a) · repo:objectstack#1 · head 2de0d505dc73fcbf8e4f16c19760590077ee8edd · 2026-11-19T20:10Z

  • 形态 — draft, base main, 3 commits, 8 files, +507/−23. Merge-base d2bc1ffd. NOT governed. Clause-②: no, Metadata-protocol: none, @objectstack/verify patch. The file surface matches claim 7018248157.
  • What holds
    • Route A is as the seat ruled. createVerifyDatasourceDriverFactory hands the real factory a spec of verify's own: the name, the stand-in engine and :memory: or {}. Nothing of the declared url, credentials, pool or persistence reaches it.
    • default is reserved by the datasource service (datasource-admin-service.ts:1619), so derive's default exemption is sound.
    • The cascade wording item is done for both the direct and the transitive case. The derive.ts comment now credits only the schemaMode half to the engine gate.
    • The boot pin, its control (the os dev factory opens the same file and writes into it), the red-on-main run and the ablation are all real evidence (os-dev-report 7020247281).

Must-fix

  1. The factory and deriveCrudCases read "is this datasource managed" from different places, and the gap writes through to the real database.
    • The factory reads three sources. create() asks resolveDatasourceSchemaMode(spec), which is spec.schemaMode ?? spec.external?.schemaMode ?? spec.config?.schemaMode (datasource-schema-mode.ts:29). Anything other than managed gets opts.real.create(spec), the real connection.
    • Derive reads one. It treats the object as external only on typeof ds.schemaMode === 'string' && ds.schemaMode !== 'managed', the same declared key the engine's write gate reads (engine-registration.ts:742). Otherwise it treats the object as managed, and with hasManagedStandIn('postgres') true it does not withhold.
    • How the two meet. DatasourceSchema.config is an open record (z.record(z.string(), z.unknown())). So a datasource declared { driver: 'postgres', config: { host: …, schemaMode: 'external' } } is reachable:
      • The factory builds the real postgres connection.
      • Derive keeps its objects in every write family.
      • The engine gate sees no declared schemaMode, so it reads managed and admits the writes.
    • So verify's CRUD, reference, delete and unique-scope rows land in the real database. That is the card's exact Expected ("no write verify itself derives reaches a datasource the app declares") and the seat's route line ("never write through"). The same holds for external.schemaMode if that block carries one.
    • This is by reading and not measured. It was already the behaviour before this PR, but the PR now owns both readers and adds the factory's three-source read.
    • Fix. Make the two decisions one reading. Either:
      • derive uses the same resolution for its external test, so those objects are withheld as external and the real driver serves reads; or
      • the factory decides the stand-in on the key derive and the gate read.
        Pick one, and say in the docblock which reader is the one. Pin it with a config.schemaMode: 'external' + postgres declaration: zero derived writes reach a recording real factory or driver, and the matching derive case is withheld. Ablate that pin.

Not blocking, carried to the landing round

  • A card is owed, rather than "noted, not filed". For mongodb and plugin drivers, the real driver stays connected. The app's own seed (and any hook a verify write fires) then writes into that real database, and those rows survive the run. That is the condition triage 7011470565 named for raising this family to p1 ("rows survive verify"). It is outside this card's derived-write scope, so it is not part of this REWORK, but triage should grade it: file it area:build, citing this record and the Acceptance note.

  • The harness change has one measured path. Dogfood Verify CLI was path-skipped, so the boot pin in Test Core is the only measured harness path, besides the control and the ablation. That is enough for the factory wiring. No extra run is owed.

  • 门禁 — on this head: 42 success, 17 skipped, 0 failure. Mergeable clean.

  • 下一步 — fix item 1 with its pin and ablation, push, and ask for a delta L1. The rest of this record's readings carry.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt

Green head for delta L1: bb1259fb2688af11116383967cf6386c2140cea7(2026-11-19T20:50Z)· after L1-a REWORK 7020917973 on 2de0d505

  • Delta 2de0d505..bb1259fb: one commit, 5 files, +77/-25. A single reader, isManagedDatasource (resolveDatasourceSchemaMode), now decides both the factory and deriveCrudCases. The factory's resolveSchemaMode option is removed.
  • CI on this head: every pushed-head run is complete, 0 failed. The two body-edit re-runs (Check Changeset, PR-body guards) were started by the seat's body patch and are still running.
  • Dev report: os verify still writes test rows through a declared managed secondary datasource, which can point at a real database #35523 comment 7021803363. The three new pins (config.schemaMode and external.schemaMode spellings withheld; a config.schemaMode: 'external' postgres declaration passed to the real factory and withheld in derive) are red on 2de0d505 (3 failed / 40 passed) and green on head (43 passed). The ablation of the one-reader line turns the same 3 red, and the blob was restored afterwards. Full package 478/478; derived gates 104/104 exit 0.
  • PR body: the seat appended the M1 lines under What changes and Tests, and moved the gate paragraph's head to bb1259f (issue_patch, read-back identical).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-sales · session_01L6bhgTcFanGhTvqS1V2Q4U

维护者速读

  • 这一轮修好了上次指出的漏洞:判断「这个数据源是不是托管的」,两处代码现在用同一个读法。只在 config 或 external 里写了 schemaMode 的数据源,verify 只读不写。
  • 要你做什么:不需要你做任何事,区域自己落地。

席位核对 — ACCEPT (L1-a, delta) · repo:objectstack#1 · head bb1259fb2688af11116383967cf6386c2140cea7 · 2026-11-19T20:52Z

Delta read: 2de0d505..bb1259fb, 1 commit, 5 files, +77/−25, no main merge. REWORK 7020917973's other readings are carried.

  • M1 is closed. isManagedDatasource is now the one reader.
    • It is resolveDatasourceSchemaMode (spec.schemaMode, then external.schemaMode, then config.schemaMode), with no mode read as managed. A non-object config is folded to {}.
    • The factory's create() calls it, and the injected resolveSchemaMode option is gone, so the factory cannot be handed a second reader.
    • deriveCrudCases' external test is now obj.external || (ds && !isManagedDatasource(ds)). So whatever the factory keeps real, derive withholds as external, and reads still reach it.
    • The docblock names the one reader and says why: the engine's write gate reads only the declared key, which is exactly the drift that wrote through before.
  • Pins
    • derive.test.ts covers schemaMode only inside config, and only inside external. Both are withheld, with no body.
    • The factory test covers a config.schemaMode: 'external' + postgres declaration: the factory returns the declared spec to the real factory, and the same declaration's derive case is withheld.
    • All 3 are red on 2de0d505 and green here, and the ablation turns the same 3 red. The package passes 478/478 and gates pass 104/104 (os-dev-report 7021803363).
  • nit (accepted): managed-datasource-stand-in.ts now imports resolveDatasourceSchemaMode as a value. Since derive.ts imports that module, every verify run loads @objectstack/service-datasource's module graph, where the harness used to load it only for an app that declares datasources. The package is a declared dependency with sideEffects: false, and the plugin is still wired only on that condition, so only load cost moves.
  • nit (accepted): derive's no-stand-in withhold still requires typeof ds.driver === 'string'. The factory reads any driver through resolveDriverId. A schema-valid datasource always carries a string driver (DriverType), so the two cannot disagree on valid metadata.
  • The owed card for the app's own seed and hook writes is filed as os verify still lets the app's own seed and hooks write into a managed mongodb or plugin-driver datasource #35640, for triage.
  • 门禁 — on this head: 42 success, 17 skipped, 0 failure. Mergeable clean.
  • 落地条款 — not governed, no L2 face: b1-B lands this head. A new push needs a fresh L1 only if it changes more than a main merge.

Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt

Landing · 2026-11-19T21:15Z · area b1-B, after L1-a delta ACCEPT 7021917719 on bb1259fb (REWORK 7020917973 on 2de0d505, M1 closed). This PR has no L2 face.

  • Head 2b4a9026 is a clean merge of origin/main 2495486f into bb1259fb, with no other change. K was 15 first-parent commits since d2bc1ffd. diff <(git diff d2bc1ffd bb1259fb) <(git diff 2b4a9026^2 2b4a9026) is empty (checked by the seat as well as the dev), so the ACCEPT carries. K is now 1 since 2495486f. Verify package 478/478 and typecheck OK on the merge.
Probe Reading
check-governed-merges.mjs --pr 35635 NOT governed · 578 changed lines ≤ 3000
check-runs on 2b4a90265b1891e160ea175ac17ebdbd1f4ea829 55 completed: 40 success, 15 skipped, 0 failed

Follow-up: #35640 (p1, managed mongodb or plugin-driver datasources: the app's own seed and hook writes) is routed to b1-B after this lands.

State: ready + auto-merge now; #35523 closes on merge.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 19, 2026 21:15
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit 1104ee5 Nov 19, 2026
56 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35523-verify-managed-datasource-ephemeral branch November 19, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

os verify still writes test rows through a declared managed secondary datasource, which can point at a real database

2 participants