Skip to content

feat(cli): add meta schema command and retire ai-runtime publish - #639

Merged
dmealing merged 10 commits into
mainfrom
fm/mo-130-lane-ts-2-b4
Nov 22, 2026
Merged

dmealing merged 10 commits into
mainfrom
fm/mo-130-lane-ts-2-b4

Conversation

@dmealing

@dmealing dmealing commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Adds meta schema, a read-only command that prints the expected schema for a dialect (postgres, sqlite, d1) as CREATE DDL, views included, or as the neutral snapshot JSON (--as json, format 4) with --out <file> to write it. It builds the schema the same way meta migrate does and reads no database or snapshot. Adds a reference page for the snapshot format at docs/features/schema-snapshot-format.md.
  • trace-helper now writes the LLM call loop into the project as llm-call.ts beside the <Entity>.trace.ts modules, instead of importing @metaobjectsdev/ai-runtime. ai-runtime becomes private, leaves the publish set (now 13 packages) in scripts/publish-set.mjs, and release-verify.mjs reads its npm list from that set. docs/RELEASING.md and ADR-0024 are updated to match.
  • @metaobjectsdev/react: ImageUpload and cropToBlob move to the @metaobjectsdev/react/image-upload subpath, and react-easy-crop becomes an optional peer. The generated form imports from the subpath. The empty private forge package 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.md stays, as the SDK still ships that vocabulary), and the test round made meta schema --out into 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 schema tests run its DDL against a real SQLite database and check it with meta migrate --db. The llm-call.ts tests compile and execute the generated code. The round-1 fix removed the forge-provider section from extending-with-providers.md, and no other text in that doc names the forge provider. The ImageUpload move 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-toolchains passed 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 real meta CLI from source under bun: (1) meta schema DDL and --as json output, checked by an independent python sqlite oracle and JSON format-4 assertions: pass. (2) the round-2 --out fix: 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, --check OK: 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.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
meta schema prints the expected schema as sqlite DDL (tables, FK, projection view) and as format-4 JSON on a sample project; DDL executes on an empty SQLite DB and yields the expected objects ✅ pass live s1-schema-sqlite.sql, s1-schema.json; python3 -I oracle run during the test phase
meta schema --out into a missing parent directory fails cleanly: exit 1, message naming the path, no directory created, no stack trace; writable and directory-target --out also behave ✅ pass live s2-missing-stderr.txt, s2-schema-out-test.txt
publish set (T10b) is 13 lockstep packages with ai-runtime and forge absent, and the set invariants hold ✅ pass live s3-publish-set-check.txt
forge package removed and react-easy-crop is an optional peer of @metaobjects/react (T10a) ⏸️ untested no Manifest and packaging state only. Live proof needs packing @metaobjectsdev/react and installing it in a clean consumer without react-easy-crop, which was out of scope for the ten-minute budget. Not d…
Evidence: meta schema sqlite DDL output (scenario 1)
CREATE TABLE "authors" (
  "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  "name" VARCHAR(80) NOT NULL
);

CREATE TABLE "books" (
  "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
  "title" TEXT NOT NULL,
  "author_id" INTEGER NOT NULL,
  FOREIGN KEY ("author_id") REFERENCES "authors" ("id")
);

CREATE VIEW "v_books" AS
  SELECT
    b.id AS id,
    b.title AS title
  FROM books b;
Evidence: meta schema --as json output, format 4 (scenario 1)
{
  "formatVersion": 4,
  "snapshot": {
    "tables": [
      {
        "checks": [],
        "columns": [
          {
            "identity": "increment",
            "name": "id",
            "nullable": false,
            "sqlType": {
              "bits": 64,
              "kind": "integer"
            }
          },
          {
            "name": "name",
            "nullable": false,
            "sqlType": {
              "kind": "text",
              "maxLength": 80
            }
          }
        ],
        "foreignKeys": [],
        "indexes": [],
        "name": "authors",
        "primaryKey": [
          "id"
        ]
      },
      {
        "checks": [],
        "columns": [
          {
            "name": "author_id",
            "nullable": false,
            "sqlType": {
              "bits": 64,
              "kind": "integer"
            }
          },
          {
            "identity": "increment",
            "name": "id",
            "nullable": false,
            "sqlType": {
              "bits": 64,
              "kind": "integer"
            }
          },
          {
            "name": "title",
            "nullable": false,
            "sqlType": {
              "kind": "text"
            }
          }
        ],
        "foreignKeys": [
          {
            "columns": [
              "author_id"
            ],
            "name": "books_author_id_fk",
            "refColumns": [
              "id"
            ],
            "refTable": "authors"
          }
        ],
        "indexes": [],
        "name": "books",
        "primaryKey": [
          "id"
        ]
      }
    ],
    "views": [
      {
        "dependsOn": [
          "books"
        ],
        "fingerprint": "b85d6d735a4c96ad9dd80dc2c437d49a6a5022166cbca353a8a866cb82710f0b",
        "name": "v_books",
        "sql": "  SELECT\n    b.id AS id,\n    b.title AS title\n  FROM books b"
      }
    ]
  }
}
Evidence: --out missing-dir clean error stderr (scenario 2)
meta: schema: cannot write <scratch>/t3-fixture/missing/expected.sql — ENOENT: no such file or directory, open '<scratch>/t3-fixture/missing/expected.sql'
Evidence: schema-out focused test run (scenario 2)
bun test v1.3.14 (0d9b296a)

test/schema-out.test.ts:
meta: schema: cannot write <tmpdir>/missing/expected.sql — ENOENT: no such file or directory, open '<tmpdir>/missing/expected.sql'
meta schema — wrote <tmpdir>/expected.sql

 2 pass
 0 fail
 4 expect() calls
Ran 2 tests across 1 file. [202.00ms]
Evidence: publish-set --check output (scenario 3)
   1. @metaobjectsdev/metadata  (server/typescript/packages/metadata)
   2. @metaobjectsdev/render  (server/typescript/packages/render)
   3. @metaobjectsdev/docs-site  (server/typescript/packages/docs-site)
   4. @metaobjectsdev/migrate-ts  (server/typescript/packages/migrate-ts)
   5. @metaobjectsdev/codegen-ts  (server/typescript/packages/codegen-ts)
   6. @metaobjectsdev/runtime-ts  (server/typescript/packages/runtime-ts)
   7. @metaobjectsdev/sdk  (server/typescript/packages/sdk)
   8. @metaobjectsdev/runtime-web  (client/web/packages/runtime-web)
   9. @metaobjectsdev/codegen-ts-react  (server/typescript/packages/codegen-ts-react)
  10. @metaobjectsdev/codegen-ts-tanstack  (server/typescript/packages/codegen-ts-tanstack)
  11. @metaobjectsdev/react  (client/web/packages/react)
  12. @metaobjectsdev/tanstack  (client/web/packages/tanstack)
  13. @metaobjectsdev/cli  (server/typescript/packages/cli)
publish set: OK (lockstep 1.3.0; 13 packages, tier-ordered, closed over sibling deps)
  • Outcome: ⚠️ 1 info across 2 runs (15m55s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ server/typescript/packages/sdk/FORGE-METADATA.md:5 - T10a requires: "remove the forge package and the doc that names its provider." The package is removed, but no doc is removed. server/typescript/packages/sdk/FORGE-METADATA.md is kept and gets a new "Where this vocabulary lives" note that names forgeTypesProvider. The ### The TypeScript forge provider section of docs/features/extending-with-providers.md (around line 507) is untouched. FORGE-METADATA.md is still linked from metadata/METAMODEL.md and cli/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 - The description string changed from a literal em dash to the — escape. The change is a side effect of rewriting the file to drop the ai-runtime dependency. The parsed value is the same, so nothing breaks. It is unrelated churn in the diff, and the literal em dash can be restored.
⚠️ **Test** - 1 info
  • ⚠️ server/typescript/packages/cli/src/commands/schema.ts:157 - meta schema --out &lt;path&gt; 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 via log.error (exit 1), or create the parent directory.
  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
T3: meta schema prints sqlite DDL that builds exactly the expected schema (tables, FK, projection view) and migrate sees no drift ✅ pass live meta-schema-sqlite.sql and meta-schema-migrate-probe.txt; ran the real bin/meta.ts against a scratch project, executed the DDL in a real SQLite file, then ran migrate --from-db (changes [], no migrati…
T3: meta schema --as json emits the neutral snapshot, format 4, stable across runs; refuses missing or unknown dialect with exit 2; --out writes the same bytes as stdout ✅ pass live meta-schema-format4.json, meta-schema-no-dialect.txt, meta-schema-bad-dialect.txt; two JSON runs compared byte-identical; --out files compared with cmp
T10b: ai-runtime is out of the publish set; publish-set invariants hold on the 13-package lockstep ✅ pass live publish-set-check.txt; ran node scripts/publish-set.mjs and --check (exit 0, 13 packages, no @metaobjectsdev/ai-runtime)
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun server/typescript/packages/cli/bin/meta.ts schema --dialect sqlite &gt; schema.sql on 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:&lt;scratch&gt;/local.db --dialect sqlite --slug probe against that DB: changes [] , no migration files written
  • meta schema --dialect sqlite --as json run twice: formatVersion 4, snapshot tables [authors, books], views [v_books], byte-identical across runs
  • meta schema with no dialect -> exit 2 with actionable message; --dialect mysql -> exit 2 with unknown-dialect message
  • meta schema --dialect sqlite --out out/expected.sql and --as json --out out/snap.json write files byte-identical to stdout form (exit 0)
  • meta schema --dialect sqlite --out out/x.sql with missing parent dir out/: ENOENT stack trace, exit 1
  • node scripts/publish-set.mjs (13 dirs, no ai-runtime) and node scripts/publish-set.mjs --check (exit 0, 'publish set: OK')
  • bun test test/trace-helper-llm-call.test.ts in 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 commit
  • Scratch 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.ts
  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
meta schema prints the expected schema as sqlite DDL (tables, FK, projection view) and as format-4 JSON on a sample project; DDL executes on an empty SQLite DB and yields the expected objects ✅ pass live s1-schema-sqlite.sql, s1-schema.json; python3 -I oracle run during the test phase
meta schema --out into a missing parent directory fails cleanly: exit 1, message naming the path, no directory created, no stack trace; writable and directory-target --out also behave ✅ pass live s2-missing-stderr.txt, s2-schema-out-test.txt
publish set (T10b) is 13 lockstep packages with ai-runtime and forge absent, and the set invariants hold ✅ pass live s3-publish-set-check.txt
forge package removed and react-easy-crop is an optional peer of @metaobjects/react (T10a) ⏸️ untested no Manifest and packaging state only. Live proof needs packing @metaobjectsdev/react and installing it in a clean consumer without react-easy-crop, which was out of scope for the ten-minute budget. Not d…
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun 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 assertions
  • bun 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.

`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.
@dmealing
dmealing merged commit 044380f into main Nov 22, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-130-lane-ts-2-b4 branch November 22, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant