Skip to content

fix(runtime): surface code-defined datasources on the host-config boot path (ADR-0015 §18) - #2157

Merged
xuyushun441-sys merged 1 commit into
mainfrom
fix/dev-datasource-visibility
Jun 22, 2026
Merged

fix(runtime): surface code-defined datasources on the host-config boot path (ADR-0015 §18)#2157
xuyushun441-sys merged 1 commit into
mainfrom
fix/dev-datasource-visibility

Conversation

@xuyushun441-sys

Copy link
Copy Markdown
Contributor

Problem

A datasource declared in defineStack({ datasources: [...] }) (e.g. examples/app-showcase's showcase_external) was absent from GET /api/v1/datasources and GET /api/v1/meta/datasource under os dev/serve — even though the boot banner counted it ("1 Datasources") and its federated objects were queryable. Affects any code-defined datasource (app-crm too). Follow-up to #2111 / ADR-0015 §18.

Root cause (write-side, not read-side)

The read paths were already correct: protocol.getMetaItems({type:'datasource'}) merges metadataService.list(type), and datasource-admin's listDatasourceRecords reads metadata.list('datasource').

The showcase config has instantiated plugins, so isHostConfig is true → shouldBootWithLibrary is false → it boots via the lightweight assembler, notcreateStandaloneStack/MetadataPlugin. On that host-config path the metadata service is the kernel's in-memory fallback (createMemoryMetadata), which implemented register/list/get but not registerInMemory. AppPlugin gates code-defined-datasource (and stack-RBAC) registration on typeof metadata.registerInMemory === 'function', so the registration was silently skipped and both REST surfaces read empty. The standalone path (NodeMetadataManager, which has registerInMemory) was unaffected.

Fix

Add registerInMemory (synchronous, no persistence — identical to register for an in-memory store, matching MetadataManager's signature) to both in-memory metadata fallbacks:

  • packages/core/src/fallbacks/memory-metadata.ts
  • packages/plugins/plugin-dev/src/dev-plugin.ts (same latent gap)

This also restores stack-declared RBAC (roles/permissions/sharingRules/policies) listing on this path, since AppPlugin registers those through the same guard.

Test / verification

  • New regression test packages/runtime/src/datasource-visibility.test.ts boots the host-config shape (no MetadataPlugin → kernel injects the fallback) and asserts metadata.list, datasource-admin.listDatasources() (backs /api/v1/datasources), and protocol.getMetaItems (backs /api/v1/meta/datasource) all include the code datasource with origin:'code'. Verified RED before → GREEN after.
  • Live HTTP (real Hono server + REST + admin routes) returns both endpoints 200 with showcase_external (origin:"code").
  • No regressions: core 284, runtime 404, plugin-dev 7 tests pass; eslint + builds clean.

Changeset: @objectstack/core: patch (fixed group).

🤖 Generated with Claude Code

…t path (ADR-0015 §18)
A datasource declared in `defineStack({ datasources: [...] })` was absent from
`GET /api/v1/datasources` and `GET /api/v1/meta/datasource` under `os dev`/`serve`
for any config whose `plugins` are already instantiated (`isHostConfig` true), even
though the boot banner counted it and its federated objects were queryable.
Root cause is write-side, not read-side: on the host-config path no MetadataPlugin
loads, so the `metadata` service is the kernel's in-memory fallback, which
implemented register/list/get but not `registerInMemory`. AppPlugin gates
code-defined-datasource (and stack-RBAC) registration on
`typeof metadata.registerInMemory === 'function'`, so the registration was silently
skipped and both REST surfaces read empty. The read paths (metadata.list,
datasource-admin listDatasources, protocol.getMetaItems which merges metadata.list)
were already correct.
Add `registerInMemory` (synchronous, no persistence — identical to register for an
in-memory store) to both in-memory metadata fallbacks: @objectstack/core's
createMemoryMetadata and @objectstack/plugin-dev's dev stub. Also restores
stack-declared RBAC listing on this path. Adds a runtime regression test that boots
the host-config shape and asserts all three backing surfaces include the code
datasource.
Follow-up to #2111.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercelBot commented Jun 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
specReadyReadyPreview, CommentJun 22, 2026 2:26am

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation dependencies Pull requests that update a dependency file tests tooling labels Jun 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/core, @objectstack/plugin-dev, @objectstack/runtime.

30 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/cloud-artifact-api.mdx(via packages/runtime)
  • content/docs/concepts/core/index.mdx(via @objectstack/core)
  • content/docs/concepts/core/plugins.mdx(via @objectstack/core)
  • content/docs/concepts/core/services.mdx(via @objectstack/core)
  • content/docs/concepts/implementation-status.mdx(via @objectstack/core, @objectstack/runtime)
  • content/docs/concepts/north-star.mdx(via packages/core, packages/runtime)
  • content/docs/concepts/packages.mdx(via @objectstack/core, @objectstack/plugin-dev, @objectstack/runtime)
  • content/docs/concepts/webhook-delivery.mdx(via @objectstack/core)
  • content/docs/guides/ai-capabilities.mdx(via @objectstack/core)
  • content/docs/guides/api-reference.mdx(via @objectstack/runtime)
  • content/docs/guides/authentication.mdx(via @objectstack/core, @objectstack/runtime)
  • content/docs/guides/cloud-deployment.mdx(via @objectstack/runtime)
  • content/docs/guides/contracts/index.mdx(via @objectstack/core)
  • content/docs/guides/deployment-vercel.mdx(via @objectstack/runtime)
  • content/docs/guides/driver-configuration.mdx(via @objectstack/runtime)
  • content/docs/guides/hook-bodies.mdx(via @objectstack/runtime)
  • content/docs/guides/kernel-services.mdx(via @objectstack/core)
  • content/docs/guides/objectql-migration.mdx(via @objectstack/core)
  • content/docs/guides/packages.mdx(via @objectstack/core, @objectstack/plugin-dev, @objectstack/runtime)
  • content/docs/guides/plugin-chatbot-integration.mdx(via @objectstack/runtime)
  • content/docs/guides/plugin-development.mdx(via @objectstack/core)
  • content/docs/guides/plugins.mdx(via @objectstack/core)
  • content/docs/guides/production-readiness.mdx(via @objectstack/runtime)
  • content/docs/guides/runtime-services/examples.mdx(via @objectstack/core)
  • content/docs/guides/single-project-mode.mdx(via @objectstack/runtime)
  • content/docs/protocol/objectos/config-resolution.mdx(via @objectstack/core)
  • content/docs/protocol/objectos/http-protocol.mdx(via @objectstack/runtime)
  • content/docs/protocol/objectos/index.mdx(via @objectstack/core, @objectstack/runtime)
  • content/docs/protocol/objectos/lifecycle.mdx(via @objectstack/core, @objectstack/runtime)
  • content/docs/protocol/objectos/plugin-spec.mdx(via @objectstack/core)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@xuyushun441-sys
xuyushun441-sys merged commit d5f6d29 into mainJun 22, 2026
17 checks passed
@xuyushun441-sys
xuyushun441-sys deleted the fix/dev-datasource-visibility branch June 22, 2026 02:31
xuyushun441-sys added a commit that referenced this pull request Jun 22, 2026
…le, credentials, visibility, query completeness) (#2162)
Consolidates the runtime gaps surfaced while implementing ADR-0015 federation
(#2138 read path, #2149 columnMap, #2139 example+verify, #2157 visibility) into a
single forward decision: one DatasourceConnectionService that auto-connects
declared datasources as queryable engine drivers (no onEnable bridge), backward-
compatible opt-in gating (existing managed apps unchanged), credential resolution
at connect, native-analytics remote-table awareness, and columnMap/field.columnName
reconciliation. Status: Proposed; decisions D1-D8 with a phased rollout.
Co-authored-by: Jack Zhuang <277994282+os-zhuang@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependenciesPull requests that update a dependency filedocumentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@xuyushun441-sys@os-zhuang