Skip to content

fix(metadata): home sys_metadata storage objects in metadata-core; register from ObjectQL#1545

Merged
xuyushun441-sys merged 4 commits into
mainfrom
fix/sys-metadata-storage-objects-home
Jun 2, 2026
Merged

fix(metadata): home sys_metadata storage objects in metadata-core; register from ObjectQL#1545
xuyushun441-sys merged 4 commits into
mainfrom
fix/sys-metadata-storage-objects-home

Conversation

@xuyushun441-sys
Copy link
Copy Markdown
Contributor

Problem

Standalone host-config apps (e.g. examples/app-showcase) boot via the isHostConfig path and never load @objectstack/metadata's MetadataPlugin. So nobody registered the metadata-storage objects (sys_metadata, _history, _audit, sys_view_definition) into ObjectQL → syncRegisteredSchemas never created their tables → ObjectQL's own protocol (loadMetaFromDb at boot, getMetaItems on REST /meta requests) failed with no such table: sys_metadata on every read (swallowed but log-spamming; metadata persistence effectively broken).

Diagnosed by temporarily capturing the synchronous caller stack in engine.find — the readers were ObjectQL's protocol, not the metadata DatabaseLoader as initially assumed.

Fix — "put the table in the package that uses it"

  • Move the 4 storage-object definitions from @objectstack/platform-objects/metadata@objectstack/metadata-core (src/objects/), the lowest package shared by their real consumers (the ObjectQL protocol + the metadata DatabaseLoader). platform-objects/metadata keeps a thin re-export shim for back-compat.
  • ObjectQLPlugin.init() registers these objects itself so their tables are always schema-synced — gated on environmentId === undefined (the same condition as restoreMetadataFromDb): standalone/platform kernels own their local sys_metadata; per-project cloud kernels skip and source metadata from the control plane.
  • Update @objectstack/metadata imports to metadata-core; add @objectstack/spec dep to metadata-core and @objectstack/metadata-core dep to platform-objects.

Verification

Showcase dev server: no such table: sys_metadata0, all /api/v1/meta/* + data reads 200, full boot log ERROR=0.

Tests green: metadata-core 80 · platform-objects 52 · objectql 486 · metadata 246 · runtime 334 · rest 78 · example-showcase 20 · example-crm 29.

🤖 Generated with Claude Code

…gister from ObjectQL

Standalone "host config" apps (e.g. the showcase) boot via the isHostConfig
path and never load @objectstack/metadata's MetadataPlugin, so nobody
registered the metadata-storage objects (sys_metadata, _history, _audit,
sys_view_definition) into ObjectQL. syncRegisteredSchemas therefore never
created their tables, and ObjectQL's OWN protocol (loadMetaFromDb at boot,
getMetaItems on REST /meta requests) failed with "no such table: sys_metadata"
on every read (swallowed but log-spamming; metadata persistence broken).

Fix, following "put the table in the package that uses it":
- Move the 4 storage-object definitions from @objectstack/platform-objects/metadata
  to @objectstack/metadata-core (src/objects/) — the lowest package shared by
  their real consumers (the ObjectQL protocol and the metadata DatabaseLoader).
  platform-objects/metadata now re-exports from metadata-core for back-compat.
- ObjectQLPlugin.init() registers these objects itself so their tables are
  always schema-synced, gated on `environmentId === undefined` (same condition
  as restoreMetadataFromDb): standalone/platform kernels own local sys_metadata;
  per-project cloud kernels skip and source metadata from the control plane.
- Update @objectstack/metadata imports to metadata-core; add @objectstack/spec
  dep to metadata-core and @objectstack/metadata-core dep to platform-objects.

Verified on the showcase dev server: "no such table: sys_metadata" errors drop
to 0 and all /api/v1/meta + data reads return 200. Tests green across
metadata-core (80), platform-objects (52), objectql (486), metadata (246),
runtime (334), rest (78), example-showcase (20), example-crm (29).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 2, 2026 1:42pm

Request Review

@github-actions github-actions Bot added dependencies Pull requests that update a dependency file tests size/m labels Jun 2, 2026
os-zhuang and others added 2 commits June 2, 2026 21:26
Since `organization_id` is now provisioned on every table regardless of the
tenant flag, the SQL driver's "has organization_id column" heuristic mis-flagged
EVERY table as tenant-scoped. On single-tenant boots this spammed
"[tenant-audit] updateMany on tenant-scoped object … without options.tenantId"
for benign infrastructure writes (the notification / http-delivery outbox
dispatchers' claim/reap updates) — there is no tenant isolation to miss.

Gate `auditMissingTenant` on the actual multi-tenant mode (OS_MULTI_ORG_ENABLED /
deprecated OS_MULTI_TENANT, matching the SchemaRegistry / SecurityPlugin). The
warning still fires where it's meaningful (org-scoping installed); single-tenant
stacks stay quiet.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation tooling labels Jun 2, 2026
… test

Mirror the driver-sql fix: the inherited tenant-audit warning now only fires in
multi-tenant mode, so the 'logs once per object:op' test must opt in.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xuyushun441-sys xuyushun441-sys merged commit 764c747 into main Jun 2, 2026
13 checks passed
@xuyushun441-sys xuyushun441-sys deleted the fix/sys-metadata-storage-objects-home branch June 2, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants