Repository navigation
feat(cli): add meta schema command and retire ai-runtime publish - #639
Merged
Merged
Conversation
`meta schema --dialect postgres|sqlite|d1` prints the CREATE statements `meta migrate` would write for an empty database, views included; `--as json` prints the neutral document instead, the snapshot format `meta migrate` commits (formatVersion 4). The schema is built the way `meta migrate` builds it: the project's conventions, migrate.scope and the dependency exclusion, and the views projections and reports lower to. A scope that matches nothing is refused as migrate refuses it. It reads no database and no snapshot and writes nothing without --out, so a native migration tool can start from it. The dialect defaults to migrate.dialect, then to the dialect in metaobjects.config.ts. MySQL is refused, since MetaObjects owns no MySQL schema. `--as`, not `--json`: the global parser takes `--json` as a misspelling of `--format json`. The format now has a reference page, docs/features/schema-snapshot-format.md, written from the descriptor types and checked against a real document's keys. The integration test uses the migration engine as its oracle. It loads the printed SQLite DDL into an empty real database, then `meta migrate --from-db` must find nothing to change. Deleting a column from the DDL makes migrate write a migration, and the test fails.
… an optional peer; remove forge (T10a) `ImageUpload` and `cropToBlob` leave the root of `@metaobjectsdev/react` for `@metaobjectsdev/react/image-upload`, and `react-easy-crop` moves from dependencies to an optional peer (>=6.2.3 <7.0.0). The generated form imports `ImageUpload` from the subpath, only when the entity has a view.image field, so a project without one no longer installs the crop library. The adapter provider stays on the root: it imports nothing optional. This is the shape image-upload.md named as the long-term fix for #287. The optional-peer form failed through 0.21.4 only because the component sat on the root, and a bundler resolves the whole graph before it tree-shakes. test/browser-bundleable.test.ts already holds every optional peer unreachable from the root. Putting ImageUpload back on the root turns it red, naming react-easy-crop. The empty, private `@metaobjectsdev/forge` package is removed: it exported nothing and had no importer. The forge vocabulary stays in `@metaobjectsdev/sdk` (forgeTypesProvider), and FORGE-METADATA.md now says that is where it lives, with its METAMODEL.md and cli README links kept. Upgrade: docs/features/migrations/react-image-upload-subpath.md.
The subpath name must mirror the layout under src/, because tsconfig.scripts.json maps @metaobjectsdev/react/* to src/*. A separate src/image.ts entry made tsc read image-upload.tsx while bun read image.ts, which the subpath-resolves gate refuses. The component module now carries the cropToBlob re-export and the optional-peer note.
Each test runs meta gen and meta verify several times over a real tree. On an idle machine that is well under a second; under heavy load it overran Bun's 5 s default and failed a different test each run (load average about 95 when seen). The budget covers the whole sequence, as the other multi-run CLI integration tests already do.
…; ai-runtime leaves the publish set (T10b) The generated call<Entity> imported runLlmCall and the LlmClient seam from @metaobjectsdev/ai-runtime, so stopping that package's publication would have broken generated code. trace-helper now writes llm-call.ts beside the <Entity>.trace.ts modules, whenever a helper has a call<Entity>: the LlmClient seam, the injectable Clock, IdGen and CostFn, and runLlmCall, with the behaviour the package had. Generated trace code imports only runtime-ts, render and metadata. Each renderable helper emits the same bytes at the same path, and the runner keeps one copy. The owned reference copy (meta eject trace-helper) does the same. ai-runtime is private and leaves the publish set, which is now 13 packages (1.2.3 stays on npm). It stays in the repo as reference source for callLlm and the Composite, Langfuse and OTel recorders. ADR-0024 Amendment 2 records the change, and docs/features/migrations/ai-runtime-unpublished.md is the upgrade path. publish-set.mjs, RELEASING.md, the releasing skill, AGENTS.md, MAINTAINERS.md and the prompts skill reference (and its agent-context golden) follow. release-verify.mjs now reads the npm set from publish-set.mjs instead of a third hardcoded list, which this change would otherwise have had to edit by hand. Also fixes a defect the new compile test found. A trace helper whose response value object has a required field did not compile under strict TypeScript: it cast the extracted record straight to the interface. It now casts through unknown, after the helper has checked that no required field was lost or malformed. test/trace-helper-llm-call.test.ts covers three things: - it compiles the generated tree with the real compiler, and asserts the program never reaches ai-runtime's files; - it runs the generated runLlmCall against the expectations ai-runtime's call-loop tests held; - it runs callApiCall end to end (render, call, extract, persist one typed row). Pointing the import back at ai-runtime fails it.
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.
What Changed
meta schema, a read-only command that prints the expected schema for a dialect (postgres,sqlite,d1) asCREATEDDL, views included, or as the neutral snapshot JSON (--as json, format 4) with--out <file>to write it. It builds the schema the same waymeta migratedoes and reads no database or snapshot. Adds a reference page for the snapshot format atdocs/features/schema-snapshot-format.md.trace-helpernow writes the LLM call loop into the project asllm-call.tsbeside the<Entity>.trace.tsmodules, instead of importing@metaobjectsdev/ai-runtime.ai-runtimebecomesprivate, leaves the publish set (now 13 packages) inscripts/publish-set.mjs, andrelease-verify.mjsreads its npm list from that set.docs/RELEASING.mdand ADR-0024 are updated to match.@metaobjectsdev/react:ImageUploadandcropToBlobmove to the@metaobjectsdev/react/image-uploadsubpath, andreact-easy-cropbecomes an optional peer. The generated form imports from the subpath. The empty privateforgepackage is removed; the forge vocabulary stays in@metaobjectsdev/sdk.Gate runs: 1. Fixed in the run: the review round removed the forge-provider section of
docs/features/extending-with-providers.md(T10a;FORGE-METADATA.mdstays, as the SDK still ships that vocabulary), and the test round mademeta schema --outinto a missing directory a clean CLI error instead of a raw stack trace.Validation
Risk Assessment
✅ Low: All three plan rows (T3, T10a, T10b) are implemented. I traced each and found no wrong-result path. The
meta schematests run its DDL against a real SQLite database and check it withmeta migrate --db. Thellm-call.tstests compile and execute the generated code. The round-1 fix removed the forge-provider section fromextending-with-providers.md, and no other text in that doc names the forge provider. TheImageUploadmove to a subpath is a breaking change, but it has a migration page and the bundleability gate covers it. I only skimmed some of the doc and generated-fixture files, so the reviewed list below does not include them.Testing
Baseline
scripts/ci-local.sh --affected --strict-toolchainspassed at the target commit; no source changed in this turn, so it was not re-run. Three scenarios driven live against a scratch fixture (an entity pair with FK and a projection view) via the realmetaCLI from source under bun: (1)meta schemaDDL and--as jsonoutput, checked by an independent python sqlite oracle and JSON format-4 assertions: pass. (2) the round-2--outfix: missing parent dir gives a clean exit-1 error naming the path, creates nothing, and writable and directory-target cases behave; the focused schema-out test passes: pass. (3) T10b publish set, offline: 13-package lockstep set, ai-runtime and forge absent,--checkOK: pass. T10a (forge removal and react-easy-crop optional peer) is manifest/packaging state with no runtime path here, so it is untested rather than guessed. Overall: all driven scenarios pass; no findings. Scratch fixture removed; worktree clean; no background processes started.Evidence: meta schema sqlite DDL output (scenario 1)
Evidence: meta schema --as json output, format 4 (scenario 1)
Evidence: --out missing-dir clean error stderr (scenario 2)
Evidence: schema-out focused test run (scenario 2)
Evidence: publish-set --check output (scenario 3)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/typescript/packages/sdk/FORGE-METADATA.md:5- T10a requires: "remove theforgepackage and the doc that names its provider." The package is removed, but no doc is removed.server/typescript/packages/sdk/FORGE-METADATA.mdis kept and gets a new "Where this vocabulary lives" note that namesforgeTypesProvider. The### The TypeScript forge providersection ofdocs/features/extending-with-providers.md(around line 507) is untouched.FORGE-METADATA.mdis still linked frommetadata/METAMODEL.mdandcli/README.md. The CHANGELOG says the doc "now says so", so the author chose to keep it. The criterion says to remove it. It is not clear which doc the criterion means. The author needs to confirm which doc was meant and whether keeping and amending it satisfies the criterion. Removing it would also mean dropping the two inbound links.🔧 Fix applied.
1 info still open:
server/typescript/packages/integration-tests/package.json:5- Thedescriptionstring changed from a literal em dash to the—escape. The change is a side effect of rewriting the file to drop theai-runtimedependency. The parsed value is the same, so nothing breaks. It is unrelated churn in the diff, and the literal em dash can be restored.server/typescript/packages/cli/src/commands/schema.ts:157-meta schema --out <path>with a missing parent directory throws an unhandled ENOENT from writeFile: a raw Bun stack trace, exit 1. No partial write, but the error is not reported as a clean CLI error. Wrap the write in try/catch and log vialog.error(exit 1), or create the parent directory.scripts/ci-local.sh --affected --strict-toolchainsbun server/typescript/packages/cli/bin/meta.ts schema --dialect sqlite > schema.sqlon a scratch two-entity-plus-view project under (exit 0)Executed schema.sql into a real SQLite file via bun:sqlite; sqlite_master lists authors, books (tables), v_books (view); PRAGMA foreign_key_list(books) = [authors, author_id, id]bun .../bin/meta.ts migrate --from-db --db file:<scratch>/local.db --dialect sqlite --slug probeagainst that DB: changes [] , no migration files writtenmeta schema --dialect sqlite --as jsonrun twice: formatVersion 4, snapshot tables [authors, books], views [v_books], byte-identical across runsmeta schemawith no dialect -> exit 2 with actionable message;--dialect mysql-> exit 2 with unknown-dialect messagemeta schema --dialect sqlite --out out/expected.sqland--as json --out out/snap.jsonwrite files byte-identical to stdout form (exit 0)meta schema --dialect sqlite --out out/x.sqlwith missing parent dirout/: ENOENT stack trace, exit 1node scripts/publish-set.mjs(13 dirs, no ai-runtime) andnode scripts/publish-set.mjs --check(exit 0, 'publish set: OK')bun test test/trace-helper-llm-call.test.tsin server/typescript/packages/codegen-ts: 3 pass (existing test; compiles generated trace tree, not a live product run)Verified server/typescript/packages/forge directory absent at target commitScratch project removed; worktree git status clean after run🔧 Fix applied.
1 info still open:
server/typescript/packages/cli/test/schema-out.test.ts- new test file written by agent: server/typescript/packages/cli/test/schema-out.test.tsscripts/ci-local.sh --affected --strict-toolchainsbun server/typescript/packages/cli/bin/meta.ts schema --cwd <fixture> --dialect sqlite (DDL and --as json, scenario 1)python3 -I sqlite oracle over the printed DDL and JSON format-4 assertionsbun server/typescript/packages/cli/bin/meta.ts schema --out missing/expected.sql, --as json --out nope/x.json, --out expected.sql, --out <directory> (scenario 2)bun test test/schema-out.test.ts in server/typescript/packages/cli (2 pass)node scripts/publish-set.mjs and node scripts/publish-set.mjs --check (scenario 3)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.