fix(metadata): home sys_metadata storage objects in metadata-core; register from ObjectQL#1545
Merged
Merged
Conversation
…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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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>
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Standalone host-config apps (e.g.
examples/app-showcase) boot via theisHostConfigpath and never load@objectstack/metadata'sMetadataPlugin. So nobody registered the metadata-storage objects (sys_metadata,_history,_audit,sys_view_definition) into ObjectQL →syncRegisteredSchemasnever created their tables → ObjectQL's own protocol (loadMetaFromDbat boot,getMetaItemson REST/metarequests) failed withno such table: sys_metadataon 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 metadataDatabaseLoaderas initially assumed.Fix — "put the table in the package that uses it"
@objectstack/platform-objects/metadata→@objectstack/metadata-core(src/objects/), the lowest package shared by their real consumers (the ObjectQL protocol + the metadataDatabaseLoader).platform-objects/metadatakeeps a thin re-export shim for back-compat.ObjectQLPlugin.init()registers these objects itself so their tables are always schema-synced — gated onenvironmentId === undefined(the same condition asrestoreMetadataFromDb): standalone/platform kernels own their localsys_metadata; per-project cloud kernels skip and source metadata from the control plane.@objectstack/metadataimports tometadata-core; add@objectstack/specdep tometadata-coreand@objectstack/metadata-coredep toplatform-objects.Verification
Showcase dev server:
no such table: sys_metadata→ 0, 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