Skip to content

fix(metadata): provision sys_metadata_commit for env kernels (ADR-0067)#2331

Merged
os-zhuang merged 1 commit into
mainfrom
fix/provision-sys-metadata-commit
Jun 25, 2026
Merged

fix(metadata): provision sys_metadata_commit for env kernels (ADR-0067)#2331
os-zhuang merged 1 commit into
mainfrom
fix/provision-sys-metadata-commit

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Problem

An AI build into a tenant env logs a hard SqliteError: no such table: sys_metadata_commit. The build still lands (objects/views/dashboard register), but the ADR-0067 commit-history write fails, so every AI build/edit spams the error and the commit timeline silently records nothing.

Root cause

The metadata-storage objects are registered through two parallel paths that must stay in sync:

  1. ObjectQLPlugin registers the full set [sys_metadata, history, commit, audit, view_definition] — but only when environmentId === undefined (platform / standalone kernels).
  2. MetadataPlugin.queryableMetadataObjects is what per-project cloud env kernels actually provision (artifact-kernel-factory boots it with registerSystemObjects:true + ObjectQL skipSchemaSync:false → boot-sync DDLs every registered object).

ADR-0067 added SysMetadataCommitObject to list (1) but not (2), so env DBs never got the sys_metadata_commit table. Every build's publishPackageDrafts writes a commit row (op='apply') → no such table. Same class as the already-merged audit/messaging lazy-table provisioning fix.

Fix

Add SysMetadataCommitObject to queryableMetadataObjects, next to its sys_metadata_history sibling (+ import + unit test). One object, +70 lines.

Verification

  • Unit test (plugin.test.ts): a new test asserts init() registers sys_metadata_commitfails without the fix (expected [4 elements] to include 'sys_metadata_commit'), passes with it. Full metadata suite: 254 passed.
  • Real-engine before/after: a kernel booted with the exact env-kernel triple (DriverPlugin('cloud') + ObjectQLPlugin(skipSchemaSync:false) + MetadataPlugin(registerSystemObjects:true)) over real better-sqlite3 — boot-sync goes synced:4 → 5, and the writer's insert('sys_metadata_commit', …) reproduces the exact reported error unfixed / succeeds fixed.

Deploy

After merge, bump cloud .framework-sha to pull this into staging/prod (same flow as the audit/messaging fix).

🤖 Generated with Claude Code

Per-project (cloud) env kernels boot MetadataPlugin with
registerSystemObjects:true, registering `queryableMetadataObjects` so
ObjectQL boot-sync provisions their physical tables. The ADR-0067 commit
log `sys_metadata_commit` was missing from that list — it lived only in
ObjectQLPlugin's standalone `environmentId === undefined` path — so env
DBs never got the table. Every AI build/apply calls publishPackageDrafts,
which writes a commit row (op='apply'), hitting a hard
`SqliteError: no such table: sys_metadata_commit` on the first build. The
write is best-effort so the build still landed, but the error spammed
logs and the commit timeline silently recorded nothing.

Add SysMetadataCommitObject next to its sys_metadata_history sibling in
queryableMetadataObjects so env kernels provision it at boot. Same class
as the audit/messaging lazy-table provisioning fix.

Verified before/after on a kernel booted with the env-kernel plugin
triple (DriverPlugin('cloud') + ObjectQLPlugin(skipSchemaSync:false) +
MetadataPlugin(registerSystemObjects:true)) over real SQLite: boot-sync
goes 4 -> 5 objects and the writer's insert succeeds; without the change
the exact reported error reproduces. Unit test in plugin.test.ts fails
without the fix, passes with it.

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

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 25, 2026 4:43pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/metadata.

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

  • content/docs/concepts/cluster-semantics.mdx (via packages/metadata)
  • content/docs/concepts/metadata-lifecycle.mdx (via @objectstack/metadata)
  • content/docs/concepts/packages.mdx (via @objectstack/metadata)
  • content/docs/guides/packages.mdx (via @objectstack/metadata)
  • content/docs/protocol/objectos/metadata-service.mdx (via @objectstack/metadata)

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.

@os-zhuang
os-zhuang merged commit 88d1c39 into main Jun 25, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the fix/provision-sys-metadata-commit branch June 25, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant