From 1f3cf9014674f9eb29e75af32b75c94b1bdff8f7 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Thu, 26 Nov 2026 17:35:48 -0500 Subject: [PATCH 1/6] fix(prerelease): explain every rc.1 estate diff in the 1.3.0 upgrade list A downstream estate's run against 1.3.0-rc.1 found diffs the "Upgrading from 1.2.0" list did not explain. This adds them and hardens the two owned-generator breaks. - CHANGELOG upgrade list: the removed codegen-spring string helpers (SpringRecordBuilder.members, SpringTypeMapper.enumDeclaration) and their writer replacements; valueObjectModuleSpecifier's node-first signature, each with a before/after snippet; the Kotlin Exposed enum column with no length moving from VARCHAR(64) to TEXT (intended: it is what meta migrate creates and what the Drizzle and EF Core bindings declare); the partial-index predicate in Exposed; literal @default as Kotlin constructor defaults; the unreadable-body 400's issues list in the generated MetaDecimalWire. - valueObjectModuleSpecifier refuses a first argument that is not a node with a CodegenError naming the 1.3 signature, instead of "node.resolutionKey is not a function". - meta gen prints the cause of a generator or template throw and the frame it was thrown at; the new --verbose prints its stack. - estate-run.sh: the java install default is `mvn -B -q -U test-compile`, which builds a multi-module reactor whose modules depend on each other; estate-run.md documents lifecycle-bound generation (--gen-cmd/--verify-cmd) and snapshot diffs for gitignored output. --- CHANGELOG.md | 84 ++++++++++++- .../packages/cli/src/commands/gen.ts | 3 +- server/typescript/packages/cli/src/index.ts | 3 + .../typescript/packages/cli/src/lib/args.ts | 7 ++ .../packages/cli/src/lib/error-text.ts | 39 ++++++ .../test/gen-generator-throw-cause.test.ts | 117 ++++++++++++++++++ .../packages/cli/test/unit/args-gen.test.ts | 5 + .../cli/test/unit/config-resolver.test.ts | 4 +- .../packages/codegen-ts/src/import-path.ts | 27 ++++ .../codegen-ts/test/import-path.test.ts | 20 +++ tools/prerelease/estate-run.md | 26 +++- tools/prerelease/estate-run.sh | 13 +- tools/prerelease/test-estate-run.sh | 9 ++ 13 files changed, 349 insertions(+), 8 deletions(-) create mode 100644 server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index adbb601d82..1f1a4d12ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -138,6 +138,52 @@ Each item below is described in full under Security, Added, Changed or Fixed; th `asOneline`, `Import.fromMaybeString`, `saveFiles`, `conditionalOutput` or its `toString` import options no longer loads.** The printer is now vendored without them; `code`, `imp`, `joinCode`, `Import` and the `Code` type still resolve from a bare `ts-poet` import. +- **TypeScript: `valueObjectModuleSpecifier` takes the value object's node first.** An owned + template copied from 1.2 calls `valueObjectModuleSpecifier(name, ctx.packageOf, fromPkg, + ctx.outputLayout, ctx.extStyle)`; the 1.3 signature is `valueObjectModuleSpecifier(vo, voName, + fromPkg, layout, extStyle)`, keyed by the node so two same-named value objects in two packages + are two modules. Both take five arguments, so nothing refuses the old call before it runs; it now + fails with a `CodegenError` that names the new signature (it used to be a bare + `node.resolutionKey is not a function`). Pass the node the field references first and the name + second, or re-eject the generator (`meta eject `) and re-apply your changes: + + ```ts + // 1.2 + valueObjectModuleSpecifier(name, ctx.packageOf, entityPkg, ctx.outputLayout, ctx.extStyle) + // 1.3 + valueObjectModuleSpecifier(ctx.resolveValueObject(field), name, entityPkg, ctx.outputLayout, ctx.extStyle) + ``` + + When a generator or template throws, `meta gen` now prints the error it threw (`caused by:`) and + the frame it was thrown at, where it printed only the wrapped message; `meta gen --verbose` + prints that error's whole stack. +- **Java and Kotlin: two string-returning `codegen-spring` helpers are removed, so an owned JVM + generator that calls them no longer compiles.** `SpringRecordBuilder.members(String recordName, + List components)` is `writeMembers(CodeWriter w, String recordName, List + components)` (it returns whether it wrote anything; `applies(recordName, components)` asks + first), and `SpringTypeMapper.enumDeclaration(String typeName, List values, + Map intValueMap)` is `writeEnumDeclaration(CodeWriter w, String typeName, + List values, Map intValueMap, Map stringValueMap)`, + which also writes a `@stringValueMap` enum's stored strings. Both write into a + `com.metaobjects.generator.writer.JavaWriter` (a `CodeWriter`) at its current indent. A generator + that still assembles its file as a string can write into a fresh writer and take its text: + + ```java + // 1.2 + String builder = SpringRecordBuilder.members(recordName, components); + String decl = SpringTypeMapper.enumDeclaration(typeName, values, SpringTypeMapper.intValueMap(ef)); + // 1.3 + JavaWriter bw = new JavaWriter(); + SpringRecordBuilder.writeMembers(bw, recordName, components); + String builder = bw.toString(); + JavaWriter ew = new JavaWriter(); + SpringTypeMapper.writeEnumDeclaration(ew, typeName, values, + SpringTypeMapper.intValueMap(ef), SpringTypeMapper.stringValueMap(ef)); + String decl = ew.toString(); + ``` + + A fresh writer starts at column 0, where `members` indented its lines by four spaces; to keep the + old layout, write into the writer the class body is written with, inside the body's block. - **`docsSiteFile()` builds the model explorer by default.** The site under `site/` changes, with object pages under `model/`. Pass `docsSiteFile({ site: "classic" })` to keep the earlier site. - **C#: an int-backed enum throws on write for a value its `@intValueMap` does not describe**, as @@ -217,6 +263,41 @@ Each item below is described in full under Security, Added, Changed or Fixed; th `Names.Field` / `Column` (C#), `fields.` (TypeScript) or a `ColumnsByField` entry for such a field stops compiling; use `nameof(...)` or the metamodel name as a literal. A projection's derived field and a write-through entity's keep their entry. +- **Kotlin: a string-stored enum with no length is a `TEXT` column in the Exposed table.** An enum + field with no `@maxLength` (and no `"enums": { "maxLength": n }` in `.metaobjects/config.json`) + was `enumerationByName(NAME, 64, X::class)`, a `VARCHAR(64)`; it is now + `customEnumeration(NAME, "TEXT", { v -> X.valueOf(v as String) }, { e -> e.name })`, the + unbounded text column `meta migrate` has always created for it on Postgres and SQLite, and what + the Drizzle and EF Core bindings declare there. Reading and writing an existing `VARCHAR(64)` + column is unchanged: Exposed uses the declared type only for the DDL it writes, so only a project whose Exposed `SchemaUtils` creates + or alters its tables sees `TEXT` there. To keep a sized column, declare `@maxLength` on the field + or `enums.maxLength` for the project; the Exposed column is then `enumerationByName(NAME, n, X::class)` + and `meta migrate` proposes `VARCHAR(n)`. +- **Kotlin: a partial index carries its predicate.** An index with `@where` was emitted without + it (a unique one as `uniqueIndex(NAME, cols)`, a lookup as `index(NAME, false, cols)`), so a + database Exposed created had a full index, and a full unique index refuses rows the partial one + allows. A unique one is now `index(NAME, true, cols, filterCondition = { ... })` and a lookup + `index(NAME, false, cols, filterCondition = { ... })`, the predicate as `meta migrate` creates + it; a non-default `@using` is emitted as `indexType` the same way. Nothing changes in a database + `meta migrate` or another tool manages; a project whose Exposed `SchemaUtils` builds the schema gets the partial + index. +- **Kotlin: a literal `@default` is a constructor default on the generated data classes.** An + entity's or projection's field with a literal `@default` (enum member, Boolean, String, Int, Long, + Double), its own or inherited through `extends`, gets it as the parameter default + (`success: Boolean = true`), where the parameter had none (under Fixed, "An enum's `@default` is + what an untouched record stores"). A create body that omits a required defaulted field is now bound with the default + instead of answering 400, and an omitted nullable one starts at the default instead of NULL. + Every call that passed the argument compiles and behaves as before; a call that leaves it out + now compiles and gets the default. +- **Kotlin: a request body that cannot be read answers with an `issues` list.** The generated + `MetaDecimalWire.kt` (one per generated package) maps the failure into the + validation envelope every other 400 uses: `{"error": "validation", "issues": [{"code", "path", + "message"}], "field"}`, where it answered `{"error": "validation", "field"}`. `code` is + `invalid_type`, `invalid_format` (a malformed date, time, uuid or uri), `invalid_value` (an + unknown enum member) or `too_big` (a decimal past its precision); `path` lists every property + Jackson was binding, empty when the body as a whole is unreadable. `error` and `field` are + unchanged, so a client that reads them keeps working; check any client that treats the body as + exactly those two keys, and read `issues` to show the specific failure. - **C#: a "-sis" entity name pluralizes to "-ses".** `Diagnosis` gives `Diagnoses` and `FindDiagnosesByPatient`, not `Diagnosises`; code naming the old form stops compiling. Use the new name, or set `"@collectionName": "Diagnosises"` on the entity to keep the old one. The REST segment is @@ -1412,7 +1493,8 @@ four `rules.*` and `verify.lifecycle.unreachable` settings, held to `fixtures/ru - **A string-stored enum's column length: `@maxLength` on `field.enum`, and `enums.maxLength`.** `@maxLength` on a `field.enum` makes its column `VARCHAR(n)`, and `"enums": { "maxLength": n }` in `.metaobjects/config.json` gives every enum without one a default; with neither, the column - stays unbounded text, as before. The ports that size a column resolve the length through one + stays unbounded text, as before (except in Kotlin, whose Exposed table declared `VARCHAR(64)` + and now declares `TEXT`: see "Upgrading from 1.2.0"). The ports that size a column resolve the length through one core function (`resolveEnumMaxLength` in TypeScript, `EnumLength.ResolveMaxLength` in C#, `EnumLength.resolveMaxLength` on the JVM), and `meta migrate`, the Drizzle, Prisma, EF Core and Exposed bindings use it. Python emits no column types, so it accepts the `enums` block and diff --git a/server/typescript/packages/cli/src/commands/gen.ts b/server/typescript/packages/cli/src/commands/gen.ts index ae36f03ea6..34959c1ccc 100644 --- a/server/typescript/packages/cli/src/commands/gen.ts +++ b/server/typescript/packages/cli/src/commands/gen.ts @@ -35,7 +35,7 @@ import { } from "../lib/catalog-listing.js"; import { emitStructured, narrate } from "../lib/format.js"; import { composeCatalog } from "../lib/catalog.js"; -import { describeError } from "../lib/error-text.js"; +import { describeError, describeErrorCause } from "../lib/error-text.js"; import { findRuntimeBoundaryCrossings, runtimeBoundaryWarnings } from "../lib/runtime-boundary-advisory.js"; import { hasLegacyDocsBlock, legacyDocsConfigMessage, NO_CONFIG_MESSAGE } from "../lib/docs-removed.js"; import { buildAgentSchemaInput } from "../lib/agent-schema.js"; @@ -363,6 +363,7 @@ export async function genCommand(args: string[], cwd: string, fmt: OutputFormat }); } catch (err) { log.error(`gen failed: ${describeError(err)}`); + for (const line of describeErrorCause(err, flags.verbose)) log.error(line); return 1; } diff --git a/server/typescript/packages/cli/src/index.ts b/server/typescript/packages/cli/src/index.ts index 49620fedfd..e57c892ff1 100644 --- a/server/typescript/packages/cli/src/index.ts +++ b/server/typescript/packages/cli/src/index.ts @@ -234,6 +234,9 @@ FLAGS: the last successful run's, and whose generated files all still match what that run left, renders nothing and writes nothing (ADR-0064; the metadata is still loaded, since the key is made of it). + --verbose When a generator or template throws, print the full stack of the + error it threw. Without it gen prints the message, a "caused by:" + line and the frame it was thrown at. --format Output format (global flag; default toon off-TTY) [] Positional filter on entity names --help, -h Print this help diff --git a/server/typescript/packages/cli/src/lib/args.ts b/server/typescript/packages/cli/src/lib/args.ts index b619cc6a39..99bbaa1bce 100644 --- a/server/typescript/packages/cli/src/lib/args.ts +++ b/server/typescript/packages/cli/src/lib/args.ts @@ -153,6 +153,11 @@ export interface GenFlags { * only warns. */ strict: boolean; + /** + * `--verbose`: when a generator or template throws, print the stack of the error it threw + * (and of each error on its `cause` chain), not only the `caused by:` line and the frame. + */ + verbose: boolean; } /** The flag table `parseGenArgs` parses. Exported so the help text can be gated against it. */ @@ -166,6 +171,7 @@ export const GEN_OPTIONS = { "generators": { type: "string" }, "strict": { type: "boolean", default: false }, "force": { type: "boolean", default: false }, + "verbose": { type: "boolean", default: false }, } as const; export function parseGenArgs(argv: string[]): GenFlags { @@ -195,6 +201,7 @@ export function parseGenArgs(argv: string[]): GenFlags { noAntipatterns: !!values["no-antipatterns"], strict: !!values.strict, force: !!values.force, + verbose: !!values.verbose, // Throws on a bad value; the command layer reports it and exits 2, exactly as // it does for --baseline above. limit: parseAdvisoryLimit(values.limit as string | undefined), diff --git a/server/typescript/packages/cli/src/lib/error-text.ts b/server/typescript/packages/cli/src/lib/error-text.ts index 5b815edab9..7d0a80c5b1 100644 --- a/server/typescript/packages/cli/src/lib/error-text.ts +++ b/server/typescript/packages/cli/src/lib/error-text.ts @@ -11,3 +11,42 @@ export function describeError(err: unknown): string { const code = (err as { code?: unknown }).code; return typeof code === "string" && code ? code : err.name; } + +/** + * The lines that say where a caught error came from: one `caused by:` line per error on its + * `cause` chain, each with the frame it was thrown at, and with `verbose` that error's whole + * stack. A generator throw reaches `meta gen` wrapped as `[] `, so the + * wrapper's own message and stack name the runner, not the template line that threw; an owned + * template broken by an engine API change was reported as a bare "x is not a function" with + * nothing to say which file to fix. An error with no cause gets its own stack under `verbose`, + * and nothing otherwise. + */ +export function describeErrorCause(err: unknown, verbose: boolean): string[] { + const lines: string[] = []; + const seen = new Set([err]); + let cur: unknown = err instanceof Error ? err.cause : undefined; + while (cur !== undefined && cur !== null && !seen.has(cur)) { + seen.add(cur); + if (!(cur instanceof Error)) { + lines.push(`caused by: ${String(cur)}`); + break; + } + const frames = stackFrames(cur); + const at = !verbose && frames.length > 0 ? ` (${frames[0]})` : ""; + lines.push(`caused by: ${cur.name}: ${describeError(cur)}${at}`); + if (verbose) lines.push(...frames.map((f) => ` ${f}`)); + cur = cur.cause; + } + if (lines.length === 0) { + if (verbose && err instanceof Error) lines.push(...stackFrames(err).map((f) => ` ${f}`)); + return lines; + } + if (!verbose) lines.push("run again with --verbose for the full stack"); + return lines; +} + +/** The `at ...` frames of an error's stack, without the leading `Name: message` line(s). */ +function stackFrames(err: Error): string[] { + if (typeof err.stack !== "string") return []; + return err.stack.split("\n").map((l) => l.trim()).filter((l) => l.startsWith("at ")); +} diff --git a/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts b/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts new file mode 100644 index 0000000000..993de33035 --- /dev/null +++ b/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts @@ -0,0 +1,117 @@ +// A generator or owned template that throws reaches `meta gen` wrapped by the runner as +// `[] `, with the original throw as `cause`. `meta gen` used to print only the +// wrapper's message, so an owned template broken by an engine API change (1.3.0's +// `valueObjectModuleSpecifier`, found by a downstream pre-release check) read as a bare +// "node.resolutionKey is not a function" with nothing naming the file that threw. It now prints +// the cause and the frame it was thrown at, and the whole stack under --verbose. +import { describe, test, expect, beforeEach, afterEach } from "bun:test"; +import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; +import { join, resolve } from "node:path"; +import { run } from "../src/index.js"; +import { describeErrorCause } from "../src/lib/error-text.js"; + +const WORKSPACE_TMP = resolve(import.meta.dirname, "fixtures", "__tmp__"); + +function setupRepo(): string { + mkdirSync(WORKSPACE_TMP, { recursive: true }); + const root = mkdtempSync(join(WORKSPACE_TMP, "gen-throw-cause-")); + mkdirSync(join(root, "metaobjects"), { recursive: true }); + writeFileSync(join(root, "metaobjects", "meta.app.json"), JSON.stringify({ + "metadata.root": { package: "app", children: [ + { "object.entity": { name: "Note", children: [ + { "source.rdb": { "@table": "notes" } }, { "field.long": { name: "id" } }, + { "identity.primary": { "@fields": "id" } } ] } }, + ] }, + }), "utf8"); + mkdirSync(join(root, ".metaobjects"), { recursive: true }); + writeFileSync(join(root, ".metaobjects", "config.json"), JSON.stringify({ schema_version: 1, sources: [] }), "utf8"); + // An owned template in its own file, so the frame `meta gen` prints names it. + mkdirSync(join(root, "codegen"), { recursive: true }); + writeFileSync(join(root, "codegen", "broken-template.ts"), ` +export function renderBroken(): string { + const node = {} as { resolutionKey: () => string }; + return node.resolutionKey(); +} +`); + writeFileSync(join(root, "metaobjects.config.ts"), ` +import { defineConfig } from "@metaobjectsdev/codegen-ts"; +import { renderBroken } from "./codegen/broken-template"; +export default defineConfig({ + outDir: ${JSON.stringify(join(root, "generated"))}, + dialect: "postgres", + extStyle: "none", + generators: [{ name: "owned-broken", generate: () => [{ path: "x.ts", content: renderBroken() }] }], +}); +`); + return root; +} + +let out: string[]; +let err: string[]; +let origLog: typeof console.log; +let origErr: typeof console.error; +beforeEach(() => { + out = []; + err = []; + origLog = console.log; + origErr = console.error; + console.log = (...a: unknown[]) => { out.push(a.map(String).join(" ")); }; + console.error = (...a: unknown[]) => { err.push(a.map(String).join(" ")); }; +}); +afterEach(() => { + console.log = origLog; + console.error = origErr; +}); + +describe("meta gen — a generator throw names its cause", () => { + test("prints the cause, the frame it was thrown at and the --verbose hint", async () => { + const root = setupRepo(); + try { + expect(await run(["gen", "--cwd", root, "--format", "text"])).toBe(1); + const text = err.join("\n"); + expect(text).toMatch(/gen failed: \[owned-broken\] .*resolutionKey is not a function/); + // The runtime's own wording follows the message; the frame closes the line. + expect(text).toMatch(/caused by: TypeError: .*resolutionKey is not a function.* \(at .*broken-template\.ts:\d+:\d+\)\)?$/m); + expect(text).toContain("run again with --verbose for the full stack"); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); + + test("--verbose prints the stack of the error the template threw", async () => { + const root = setupRepo(); + try { + expect(await run(["gen", "--cwd", root, "--format", "text", "--verbose"])).toBe(1); + const text = err.join("\n"); + expect(text).toMatch(/caused by: TypeError: .*resolutionKey is not a function/); + expect(text).toMatch(/^(meta: )? {4}at .*broken-template\.ts/m); + expect(text).not.toContain("run again with --verbose"); + } finally { + rmSync(root, { recursive: true, force: true }); + } + }); +}); + +describe("describeErrorCause", () => { + test("an error with no cause adds nothing, and only its stack under verbose", () => { + const e = new Error("plain"); + expect(describeErrorCause(e, false)).toEqual([]); + expect(describeErrorCause(e, true).every((l) => l.startsWith(" at "))).toBe(true); + }); + + test("walks the whole cause chain and stops on a cycle", () => { + const inner = new RangeError("inner"); + const mid = new Error("mid", { cause: inner }); + const outer = new Error("outer", { cause: mid }); + (inner as { cause?: unknown }).cause = outer; + const lines = describeErrorCause(outer, false); + expect(lines.filter((l) => l.startsWith("caused by:")).map((l) => l.replace(/ \(at .*\)$/, ""))).toEqual([ + "caused by: Error: mid", + "caused by: RangeError: inner", + ]); + }); + + test("a non-Error cause is printed as text", () => { + expect(describeErrorCause(new Error("x", { cause: "socket closed" }), false)[0]).toBe("caused by: socket closed"); + }); +}); diff --git a/server/typescript/packages/cli/test/unit/args-gen.test.ts b/server/typescript/packages/cli/test/unit/args-gen.test.ts index 3d0399d1a9..388485cfcf 100644 --- a/server/typescript/packages/cli/test/unit/args-gen.test.ts +++ b/server/typescript/packages/cli/test/unit/args-gen.test.ts @@ -12,10 +12,15 @@ describe("parseGenArgs", () => { noAntipatterns: false, strict: false, force: false, + verbose: false, limit: DEFAULT_ADVISORY_LIMIT, }); }); + test("--verbose", () => { + expect(parseGenArgs(["--verbose"]).verbose).toBe(true); + }); + test("--force", () => { expect(parseGenArgs(["--force"]).force).toBe(true); }); diff --git a/server/typescript/packages/cli/test/unit/config-resolver.test.ts b/server/typescript/packages/cli/test/unit/config-resolver.test.ts index ad933d7d20..be8bfd37e3 100644 --- a/server/typescript/packages/cli/test/unit/config-resolver.test.ts +++ b/server/typescript/packages/cli/test/unit/config-resolver.test.ts @@ -22,13 +22,13 @@ describe("resolveGenConfig", () => { // outDir/dialect/dbImport/extStyle. Only dryRun + entities come from flags. test("passes dryRun and entities through", () => { - const resolved = resolveGenConfig({ dryRun: true, entities: ["User", "Post"], baseline: "default", list: false, probe: false, noAntipatterns: false, strict: false, force: false, limit: DEFAULT_ADVISORY_LIMIT }); + const resolved = resolveGenConfig({ dryRun: true, entities: ["User", "Post"], baseline: "default", list: false, probe: false, noAntipatterns: false, strict: false, force: false, verbose: false, limit: DEFAULT_ADVISORY_LIMIT }); expect(resolved.dryRun).toBe(true); expect(resolved.entities).toEqual(["User", "Post"]); }); test("defaults: dryRun false, entities empty", () => { - const resolved = resolveGenConfig({ dryRun: false, entities: [], baseline: "default", list: false, probe: false, noAntipatterns: false, strict: false, force: false, limit: DEFAULT_ADVISORY_LIMIT }); + const resolved = resolveGenConfig({ dryRun: false, entities: [], baseline: "default", list: false, probe: false, noAntipatterns: false, strict: false, force: false, verbose: false, limit: DEFAULT_ADVISORY_LIMIT }); expect(resolved.dryRun).toBe(false); expect(resolved.entities).toEqual([]); }); diff --git a/server/typescript/packages/codegen-ts/src/import-path.ts b/server/typescript/packages/codegen-ts/src/import-path.ts index 017b2dbd78..2348a7fa26 100644 --- a/server/typescript/packages/codegen-ts/src/import-path.ts +++ b/server/typescript/packages/codegen-ts/src/import-path.ts @@ -5,6 +5,7 @@ import { relative as posixRelative } from "node:path/posix"; import { PACKAGE_SEPARATOR, type MetaData } from "@metaobjectsdev/metadata"; +import { CodegenError } from "./errors.js"; import { imp, Import } from "./poet.js"; import { withExt, withExtIfRelative, type ExtStyle, type RenderContext } from "./render-context.js"; @@ -78,9 +79,35 @@ export function valueObjectModuleSpecifier( extStyle: ExtStyle, ): string { if (vo === undefined) return crossEntitySpecifier(layout, fromPkg, fromPkg, voName, extStyle); + // The pre-1.3 shape was `(voName, ctx.packageOf, fromPkg, layout, extStyle)`. An owned template + // copied from 1.2 still passes it, and both shapes take five arguments, so nothing refuses the + // call before it runs: without this check the first symptom is a bare + // "node.resolutionKey is not a function" from deep inside the module walk. + if (!isNode(vo)) { + throw new CodegenError( + `valueObjectModuleSpecifier: the first argument must be the value object's node, got ${describeArg(vo)}. ` + + "Since 1.3.0 the signature is valueObjectModuleSpecifier(vo, voName, fromPkg, layout, extStyle); " + + "a template written for 1.2 that calls valueObjectModuleSpecifier(name, ctx.packageOf, fromPkg, layout, extStyle) " + + "passes ctx.resolveValueObject(field) first and the name second, or is refreshed with `meta eject `.", + ); + } return crossEntitySpecifier(layout, fromPkg, nodePackage(vo), vo.name, extStyle); } +/** True when `value` can be read as a metadata node here: it has a callable `resolutionKey`. */ +function isNode(value: unknown): value is MetaData { + return typeof value === "object" && value !== null && + typeof (value as { resolutionKey?: unknown }).resolutionKey === "function"; +} + +/** A short description of a wrong argument for the error above: a string is quoted, anything + * else is named by its type. */ +function describeArg(value: unknown): string { + if (typeof value === "string") return `the string "${value}"`; + if (value === null) return "null"; + return `${typeof value === "object" ? "an object" : `a ${typeof value}`} with no resolutionKey()`; +} + /** * The printer import of `` (the interface with `suffix` "", the Zod schema with * "InsertSchema") for the value object `field`'s `@objectRef` names, from a file in `fromPkg`. diff --git a/server/typescript/packages/codegen-ts/test/import-path.test.ts b/server/typescript/packages/codegen-ts/test/import-path.test.ts index 42ae58ab6f..796d9a59f8 100644 --- a/server/typescript/packages/codegen-ts/test/import-path.test.ts +++ b/server/typescript/packages/codegen-ts/test/import-path.test.ts @@ -12,6 +12,7 @@ import { barrelModuleSpecifier, valueObjectModuleSpecifier, } from "../src/import-path.js"; +import { CodegenError } from "../src/errors.js"; const model = (over: Partial = {}): ResolvedTarget => ({ name: "default", outDir: "db/gen", importBase: "@acme/db/generated", @@ -193,4 +194,23 @@ describe("valueObjectModuleSpecifier", () => { it("unresolved VO falls back to fromPkg (same-dir)", () => { expect(valueObjectModuleSpecifier(undefined, "Ghost", "acme::ai", "package", "none")).toBe("./Ghost"); }); + + it("refuses the pre-1.3 call shape (a name first) with a named error, not a bare TypeError", () => { + // An owned template copied from 1.2 calls (name, ctx.packageOf, fromPkg, layout, extStyle). + // Both shapes take five arguments, so the call has to be refused here, by name. + const packageOf = (name: string): string | undefined => (name === "Triple" ? "acme::common" : undefined); + const oldShape = valueObjectModuleSpecifier as unknown as (...args: unknown[]) => string; + const call = (): string => oldShape("Triple", packageOf, "acme::ai", "package", "none"); + expect(call).toThrow(CodegenError); + expect(call).toThrow(/first argument must be the value object's node, got the string "Triple"/); + expect(call).toThrow(/valueObjectModuleSpecifier\(vo, voName, fromPkg, layout, extStyle\)/); + expect(call).toThrow(/ctx\.resolveValueObject\(field\)/); + expect(call).not.toThrow(/resolutionKey is not a function/); + }); + + it("refuses any first argument that is not a node", () => { + const loose = valueObjectModuleSpecifier as unknown as (...args: unknown[]) => string; + expect(() => loose(null, "Triple", "acme::ai", "flat", "none")).toThrow(/got null/); + expect(() => loose({ name: "Triple" }, "Triple", "acme::ai", "flat", "none")).toThrow(/got an object with no resolutionKey\(\)/); + }); }); diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md index 0233f073fd..48d5681ee6 100644 --- a/tools/prerelease/estate-run.md +++ b/tools/prerelease/estate-run.md @@ -22,7 +22,8 @@ It refuses an estate whose git tree is not clean, links the candidate, installs the installed versions back** (a declared range is not proof of the version that ran: the run fails when the candidate is not in the read-back), regenerates and lists every changed file, regenerates **again** and requires that the second run writes zero files (by content and by -modification time; the check sees only files git reports, so a gitignored path is not checked), then runs the drift gate, your build, your tests and your database commands. +modification time; the check sees only files git reports, so a gitignored path is not checked: see +"Multi-module JVM estates" below), then runs the drift gate, your build, your tests and your database commands. A command you do not pass is reported `skipped`, never `passed`. However the run ended, including a `link` that failed partway, it puts the estate back on the commit it started on: it unlinks, then runs `git reset --hard` and `git clean -fd`. That deletes every untracked file in the estate, the regenerated @@ -34,6 +35,29 @@ are in the `case` block of `estate-run.sh`; `--install-cmd`, `--gen-cmd`, `--ver `--versions-cmd` override them. Rust has no estate path: a Rust consumer pins the commit (`docs/features/prerelease.md`, "Rust"). +### Multi-module JVM estates + +The Java default install is `mvn -B -q -U test-compile`: it builds every module of the reactor in +order, so a module whose code or tests depend on a sibling module resolves it from the reactor +instead of looking for it in a repository nobody installed it to. Two more things the defaults do +not cover, which the estate passes itself: + +- **Generation bound to a lifecycle phase.** The default `--gen-cmd` (`mvn -B -q + metaobjects:generate`) and `--verify-cmd` (`mvn -B -q metaobjects:verify`) call the goals on + their own, from the reactor root. An estate that binds generation to a phase in its poms, or + whose metadata loader class lives in a sibling module (the goal then fails with the loader + "not found on the Project ClassLoader" until that module is compiled), passes the phase that + runs it instead: for example `--gen-cmd 'mvn -B -q generate-sources'`, or + `--gen-cmd 'mvn -B -q test-compile'` when the loader must be compiled first, and the matching + `--verify-cmd` (the `metaobjects:verify` execution as the estate binds it, such as + `mvn -B -q verify -DskipTests`). +- **Generated output that git ignores.** The changed-files list and the second-run check see + only files git reports, so output under `target/generated-sources` or another ignored path + is not looked at. Snapshot those trees before the first gen and after each gen (with + `--keep-linked`, so the tree survives the run) and diff the snapshots: the first diff is the + "files changed" list the upgrade list must explain, and the second must be empty, by content + and by modification time. + ## Every candidate, every estate (the base run) 1. Link the candidate, install clean, and read the installed versions back. *(script)* diff --git a/tools/prerelease/estate-run.sh b/tools/prerelease/estate-run.sh index 7172893623..40cd07d08b 100755 --- a/tools/prerelease/estate-run.sh +++ b/tools/prerelease/estate-run.sh @@ -18,7 +18,8 @@ # 3. Regenerates, and lists every file that changed (each one must be explained by an item in # the CHANGELOG upgrade list). Then regenerates AGAIN: the second run must write zero files, # checked by content and by modification time. Both checks see only files git reports: -# a gitignored path (ignored generated output, .gen-state snapshots) is not looked at. +# a gitignored path (ignored generated output, .gen-state snapshots) is not looked at, so an +# estate whose generated output is gitignored diffs a snapshot of it itself (estate-run.md). # 4. Runs the drift gate (verify --codegen), the build, the tests and any --db-cmd. A command # you do not pass is reported as skipped, never as passed. # 5. Puts the estate back as it found it (unless --keep-linked), however the run ended, also @@ -54,7 +55,7 @@ while [ $# -gt 0 ]; do --db-cmd) DB_CMDS+=("$2"); shift 2 ;; --keep-linked) KEEP=1; shift ;; --no-link) NOLINK=1; shift ;; - -h|--help) sed -n '2,33p' "$0"; exit 0 ;; + -h|--help) sed -n '2,34p' "$0"; exit 0 ;; *) die "unknown option: $1" ;; esac done @@ -97,7 +98,13 @@ case "$PORT" in : "${VERIFY_CMD:=dotnet meta verify --codegen}" : "${VERSIONS_CMD:=dotnet list package | grep -i metaobjects; dotnet tool list | grep -i meta}" ;; java) - : "${INSTALL_CMD:=mvn -B -q -U dependency:resolve}" + # A reactor build, not `dependency:resolve`: in a multi-module estate whose modules depend on + # each other, resolve looks for the sibling modules in the repositories (where nothing has + # installed them) and fails before anything builds. `test-compile` resolves them from the + # reactor and builds main and test code in module order, without installing anything. + # Generation bound to a lifecycle phase, or a loader class in a sibling module, also needs + # --gen-cmd and --verify-cmd (estate-run.md, "Multi-module JVM estates"). + : "${INSTALL_CMD:=mvn -B -q -U test-compile}" : "${GEN_CMD:=mvn -B -q metaobjects:generate}" : "${VERIFY_CMD:=mvn -B -q metaobjects:verify}" : "${VERSIONS_CMD:=mvn -B dependency:list -DincludeGroupIds=com.metaobjects | grep 'com.metaobjects'}" ;; diff --git a/tools/prerelease/test-estate-run.sh b/tools/prerelease/test-estate-run.sh index 02ba2f6265..5a4507a241 100755 --- a/tools/prerelease/test-estate-run.sh +++ b/tools/prerelease/test-estate-run.sh @@ -14,6 +14,7 @@ # E12 --no-link still restores the estate; E13 --keep-linked does not # E10 a --report path inside the estate is refused (exit 2) # E11 a link that fails partway leaves the estate on its starting commit +# E14 the java install default is a reactor build (test-compile), not dependency:resolve # E7 a build command that fails is reported and the run exits 1; no command is "skipped", not "passed" set -uo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" @@ -95,6 +96,14 @@ t "E12 --no-link still restores the estate" e12 t "E13 --keep-linked leaves the regenerated tree in place" e13 t "E10 a report path inside the estate is refused" e10 t "E11 a link that fails partway still restores the estate" e11 +e14() { local d bin log; d="$(fresh "$IDEMPOTENT")"; bin="$(mktemp -d "$ROOT/bin.XXXXXX")"; log="$bin/mvn.log" + # A stub mvn that records its arguments, so the default the script picks is what is checked. + printf '#!/usr/bin/env bash\necho "$*" >> %q\n' "$log" > "$bin/mvn"; chmod +x "$bin/mvn" + PATH="$bin:$PATH" bash "$RUN" --project "$d" --port java --version 1.3.0-rc.1 --no-link --verify-cmd true \ + --gen-cmd 'sh gen.sh' $VERS 'echo com.metaobjects:x:8.3.0-rc.1' >/dev/null 2>&1; [ $? = 0 ] || return 1 + grep -qx -- '-B -q -U test-compile' "$log" && ! grep -q 'dependency:resolve' "$log"; } + +t "E14 the java install default builds the reactor" e14 t "E7 a failing build is reported; a missing command is skipped, not passed" e7 [ "$fails" = 0 ] && echo "all estate-run tests passed" || { echo "$fails failure(s)"; exit 1; } From 1a6987004250aef2f93d47c42937e48f9cf0d854 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Thu, 26 Nov 2026 17:40:18 -0500 Subject: [PATCH 2/6] no-mistakes(review): apply reviewer inline fixes --- tools/prerelease/estate-run.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md index 48d5681ee6..cc84ac6abc 100644 --- a/tools/prerelease/estate-run.md +++ b/tools/prerelease/estate-run.md @@ -53,10 +53,10 @@ not cover, which the estate passes itself: `mvn -B -q verify -DskipTests`). - **Generated output that git ignores.** The changed-files list and the second-run check see only files git reports, so output under `target/generated-sources` or another ignored path - is not looked at. Snapshot those trees before the first gen and after each gen (with - `--keep-linked`, so the tree survives the run) and diff the snapshots: the first diff is the - "files changed" list the upgrade list must explain, and the second must be empty, by content - and by modification time. + is not looked at. The script runs both gens itself, so snapshot those trees before the run + and after it (with `--keep-linked`, so the tree survives the run), then run your `--gen-cmd` + once more and snapshot again: the first diff is the "files changed" list the upgrade list + must explain, and the second must be empty, by content and by modification time. ## Every candidate, every estate (the base run) From 8738fdc04c833f4e198c08cf940c117683e75b37 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Thu, 26 Nov 2026 17:43:14 -0500 Subject: [PATCH 3/6] no-mistakes(review): List install-time regeneration; gate --verbose hint --- CHANGELOG.md | 3 +- .../packages/cli/src/lib/error-text.ts | 4 +- .../test/gen-generator-throw-cause.test.ts | 7 ++++ tools/prerelease/estate-run.md | 10 +++-- tools/prerelease/estate-run.sh | 38 ++++++++++++------- tools/prerelease/test-estate-run.sh | 9 +++++ 6 files changed, 53 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f1a4d12ce..9d5a265457 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,7 +48,8 @@ the one `metamodelVersion` value, `1.3`. ### Upgrading from 1.2.0 -Each item below is described in full under Security, Added, Changed or Fixed; this list is where to start. +Most items below are also described under Security, Added, Changed or Fixed; an item with no entry +there is described in full here. This list is where to start. - **`validator.atLeastOne` takes no `@max`.** A model that carries `@max: 1` on an `atLeastOne` fails to load; a rule meaning "exactly one of these fields" is the new `validator.exactlyOne`. diff --git a/server/typescript/packages/cli/src/lib/error-text.ts b/server/typescript/packages/cli/src/lib/error-text.ts index 7d0a80c5b1..374b04057a 100644 --- a/server/typescript/packages/cli/src/lib/error-text.ts +++ b/server/typescript/packages/cli/src/lib/error-text.ts @@ -24,6 +24,7 @@ export function describeError(err: unknown): string { export function describeErrorCause(err: unknown, verbose: boolean): string[] { const lines: string[] = []; const seen = new Set([err]); + let hasStack = false; let cur: unknown = err instanceof Error ? err.cause : undefined; while (cur !== undefined && cur !== null && !seen.has(cur)) { seen.add(cur); @@ -32,6 +33,7 @@ export function describeErrorCause(err: unknown, verbose: boolean): string[] { break; } const frames = stackFrames(cur); + if (frames.length > 0) hasStack = true; const at = !verbose && frames.length > 0 ? ` (${frames[0]})` : ""; lines.push(`caused by: ${cur.name}: ${describeError(cur)}${at}`); if (verbose) lines.push(...frames.map((f) => ` ${f}`)); @@ -41,7 +43,7 @@ export function describeErrorCause(err: unknown, verbose: boolean): string[] { if (verbose && err instanceof Error) lines.push(...stackFrames(err).map((f) => ` ${f}`)); return lines; } - if (!verbose) lines.push("run again with --verbose for the full stack"); + if (!verbose && hasStack) lines.push("run again with --verbose for the full stack"); return lines; } diff --git a/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts b/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts index 993de33035..53a0269edc 100644 --- a/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts +++ b/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts @@ -114,4 +114,11 @@ describe("describeErrorCause", () => { test("a non-Error cause is printed as text", () => { expect(describeErrorCause(new Error("x", { cause: "socket closed" }), false)[0]).toBe("caused by: socket closed"); }); + + test("the --verbose hint appears only when there is a stack to show", () => { + expect(describeErrorCause(new Error("x", { cause: "socket closed" }), false)).toEqual(["caused by: socket closed"]); + const stackless = new Error("inner"); + stackless.stack = undefined; + expect(describeErrorCause(new Error("x", { cause: stackless }), false)).toEqual(["caused by: Error: inner"]); + }); }); diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md index cc84ac6abc..858e85c1da 100644 --- a/tools/prerelease/estate-run.md +++ b/tools/prerelease/estate-run.md @@ -39,15 +39,19 @@ are in the `case` block of `estate-run.sh`; `--install-cmd`, `--gen-cmd`, `--ver The Java default install is `mvn -B -q -U test-compile`: it builds every module of the reactor in order, so a module whose code or tests depend on a sibling module resolves it from the reactor -instead of looking for it in a repository nobody installed it to. Two more things the defaults do -not cover, which the estate passes itself: +instead of looking for it in a repository nobody installed it to. It also runs `generate-sources`, +so an estate that binds a `generate` execution to that phase regenerates during the install: the +report lists those files under "Files changed by install", separately from the lockfile and before +the first gen, and every one that is not a lockfile needs an item in the upgrade list like any other +change. Two more things the defaults do not cover, which the estate passes itself: - **Generation bound to a lifecycle phase.** The default `--gen-cmd` (`mvn -B -q metaobjects:generate`) and `--verify-cmd` (`mvn -B -q metaobjects:verify`) call the goals on their own, from the reactor root. An estate that binds generation to a phase in its poms, or whose metadata loader class lives in a sibling module (the goal then fails with the loader "not found on the Project ClassLoader" until that module is compiled), passes the phase that - runs it instead: for example `--gen-cmd 'mvn -B -q generate-sources'`, or + runs it instead: for example `--gen-cmd 'mvn -B -q generate-sources'` (the install already ran + that phase once, so this gen and the second one must both find nothing left to write), or `--gen-cmd 'mvn -B -q test-compile'` when the loader must be compiled first, and the matching `--verify-cmd` (the `metaobjects:verify` execution as the estate binds it, such as `mvn -B -q verify -DskipTests`). diff --git a/tools/prerelease/estate-run.sh b/tools/prerelease/estate-run.sh index 40cd07d08b..ddd4e53ab9 100755 --- a/tools/prerelease/estate-run.sh +++ b/tools/prerelease/estate-run.sh @@ -15,8 +15,10 @@ # 2. Links the candidate (prerelease-link.sh link), installs clean, and reads the installed # versions back. A declared range is not proof of the version that ran, so the run fails # when the read-back does not contain the candidate. -# 3. Regenerates, and lists every file that changed (each one must be explained by an item in -# the CHANGELOG upgrade list). Then regenerates AGAIN: the second run must write zero files, +# 3. Lists every file the install changed (a lockfile, or generation the install ran, such as a +# `generate` execution bound to a phase the Java default reaches), then regenerates, and +# lists every file that changed (each one must be explained by an item in the CHANGELOG +# upgrade list, and so must every install-changed file that is not a lockfile). Then regenerates AGAIN: the second run must write zero files, # checked by content and by modification time. Both checks see only files git reports: # a gitignored path (ignored generated output, .gen-state snapshots) is not looked at, so an # estate whose generated output is gitignored diffs a snapshot of it itself (estate-run.md). @@ -55,7 +57,7 @@ while [ $# -gt 0 ]; do --db-cmd) DB_CMDS+=("$2"); shift 2 ;; --keep-linked) KEEP=1; shift ;; --no-link) NOLINK=1; shift ;; - -h|--help) sed -n '2,34p' "$0"; exit 0 ;; + -h|--help) sed -n '2,36p' "$0"; exit 0 ;; *) die "unknown option: $1" ;; esac done @@ -101,7 +103,9 @@ case "$PORT" in # A reactor build, not `dependency:resolve`: in a multi-module estate whose modules depend on # each other, resolve looks for the sibling modules in the repositories (where nothing has # installed them) and fails before anything builds. `test-compile` resolves them from the - # reactor and builds main and test code in module order, without installing anything. + # reactor and builds main and test code in module order, without installing anything. It also + # runs generate-sources, so a phase-bound `generate` execution regenerates during install: + # the report lists what the install changed on its own, before the first gen. # Generation bound to a lifecycle phase, or a loader class in a sibling module, also needs # --gen-cmd and --verify-cmd (estate-run.md, "Multi-module JVM estates"). : "${INSTALL_CMD:=mvn -B -q -U test-compile}" @@ -162,6 +166,7 @@ finish() { "$(date -u -d "@$STARTED" '+%Y-%m-%d %H:%M' 2>/dev/null || date -u '+%Y-%m-%d %H:%M')" \ "$(( $(date +%s) - STARTED ))" "$(git -C "$PROJECT" rev-parse --short=12 HEAD)" printf '| Step | Result | Time |\n|---|---|---|\n'; cat "$ROWS" + [ -s "$WORK/installed.txt" ] && { printf '\n## Files changed by install (%s)\n\nA lockfile is the install'"'"'s own. Any other path is generation the install ran, and needs an item in the CHANGELOG upgrade list.\n\n```\n' "$(wc -l < "$WORK/installed.txt")"; cat "$WORK/installed.txt"; printf '```\n'; } [ -s "$WORK/changed.txt" ] && { printf '\n## Files changed by regeneration (%s)\n\nEach one needs an item in the CHANGELOG upgrade list.\n\n```\n' "$(wc -l < "$WORK/changed.txt")"; cat "$WORK/changed.txt"; printf '```\n'; } [ -s "$WORK/versions.txt" ] && { printf '\n## Installed versions (read back)\n\n```\n'; cat "$WORK/versions.txt"; printf '```\n'; } cat "$DETAIL" @@ -181,7 +186,21 @@ else row "link $VERSION" "skipped (--no-link: the read-back below is the only proof)" 0 fi +# Each dirty path with a hash of its content, so a file changed again shows as a new line. +dirtymap() { + git -C "$PROJECT" status --porcelain --untracked-files=all | while IFS= read -r l; do + f="${l:3}"; f="${f##* -> }" + printf '%s %s\n' "$l" "$( [ -f "$PROJECT/$f" ] && sha256sum < "$PROJECT/$f" | cut -c1-16 || echo gone)" + done +} +# what changed between two maps, as status lines without the hash +changes() { comm -13 "$1" "$2" | sed 's/ [0-9a-f]\{16\}$//; s/ gone$//'; } + +dirtymap | sort > "$WORK/linked.txt" step "install (clean)" "$INSTALL_CMD" || finish +dirtymap | sort > "$WORK/base.txt" +changes "$WORK/linked.txt" "$WORK/base.txt" > "$WORK/installed.txt" +row "files changed by install" "$(wc -l < "$WORK/installed.txt")" 0 ( cd "$PROJECT" && bash -c "$VERSIONS_CMD" ) > "$WORK/versions.txt" 2>&1 # Every line that names a MetaObjects package must carry exactly the candidate (not rc.10 for rc.1, # not a package left on the release), and at least one must. @@ -195,17 +214,10 @@ fi # ── 2. regenerate; list what changed; regenerate again and expect nothing ───────────── # "Changed by regeneration" is what the first gen changed beyond what link and install already -# did (the repinned manifests, the lockfile): each dirty path with a hash of its content. -dirtymap() { - git -C "$PROJECT" status --porcelain --untracked-files=all | while IFS= read -r l; do - f="${l:3}"; f="${f##* -> }" - printf '%s %s\n' "$l" "$( [ -f "$PROJECT/$f" ] && sha256sum < "$PROJECT/$f" | cut -c1-16 || echo gone)" - done -} -dirtymap | sort > "$WORK/base.txt" +# did; what the install changed (the lockfile, and any generation it ran) is listed above it. step "gen (first run)" "$GEN_CMD" || finish dirtymap | sort > "$WORK/after.txt" -comm -13 "$WORK/base.txt" "$WORK/after.txt" | sed 's/ [0-9a-f]\{16\}$//; s/ gone$//' > "$WORK/changed.txt" +changes "$WORK/base.txt" "$WORK/after.txt" > "$WORK/changed.txt" row "files changed by the first gen" "$(wc -l < "$WORK/changed.txt")" 0 snapshot() { dirtymap | sha256sum; } diff --git a/tools/prerelease/test-estate-run.sh b/tools/prerelease/test-estate-run.sh index 5a4507a241..11a50c847f 100755 --- a/tools/prerelease/test-estate-run.sh +++ b/tools/prerelease/test-estate-run.sh @@ -15,6 +15,7 @@ # E10 a --report path inside the estate is refused (exit 2) # E11 a link that fails partway leaves the estate on its starting commit # E14 the java install default is a reactor build (test-compile), not dependency:resolve +# E15 a file the install writes (generation bound to a phase it runs) is listed in the report # E7 a build command that fails is reported and the run exits 1; no command is "skipped", not "passed" set -uo pipefail HERE="$(cd "$(dirname "$0")" && pwd)" @@ -104,6 +105,14 @@ e14() { local d bin log; d="$(fresh "$IDEMPOTENT")"; bin="$(mktemp -d "$ROOT/bin grep -qx -- '-B -q -U test-compile' "$log" && ! grep -q 'dependency:resolve' "$log"; } t "E14 the java install default builds the reactor" e14 +e15() { local d out; d="$(fresh "$IDEMPOTENT")" + # The install regenerates (as a phase-bound `generate` does under test-compile), so the first + # gen then changes nothing more: the file must still be listed, under the install. + out="$(bash "$RUN" --project "$d" --port java --version 1.3.0-rc.1 --no-link --verify-cmd true \ + --install-cmd 'echo generated > out.txt' --gen-cmd 'sh gen.sh' $VERS 'echo com.metaobjects:x:8.3.0-rc.1' 2>&1)"; [ $? = 0 ] || return 1 + grep -q 'files changed by install | 1 ' <<<"$out" && grep -q '## Files changed by install (1)' <<<"$out" \ + && grep -qx '?? out.txt' <<<"$out" && grep -q 'files changed by the first gen | 0 ' <<<"$out"; } +t "E15 a file the install generates is listed in the report" e15 t "E7 a failing build is reported; a missing command is skipped, not passed" e7 [ "$fails" = 0 ] && echo "all estate-run tests passed" || { echo "$fails failure(s)"; exit 1; } From 319002b9a01935dd94a3d3f4dd3831c92a7f73f7 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Thu, 26 Nov 2026 17:43:56 -0500 Subject: [PATCH 4/6] no-mistakes(review): apply reviewer inline fixes --- tools/prerelease/estate-run.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md index 858e85c1da..66bf027edb 100644 --- a/tools/prerelease/estate-run.md +++ b/tools/prerelease/estate-run.md @@ -41,8 +41,8 @@ The Java default install is `mvn -B -q -U test-compile`: it builds every module order, so a module whose code or tests depend on a sibling module resolves it from the reactor instead of looking for it in a repository nobody installed it to. It also runs `generate-sources`, so an estate that binds a `generate` execution to that phase regenerates during the install: the -report lists those files under "Files changed by install", separately from the lockfile and before -the first gen, and every one that is not a lockfile needs an item in the upgrade list like any other +report lists those files under "Files changed by install", beside the lockfile and separately from +the first gen's list, and every one that is not a lockfile needs an item in the upgrade list like any other change. Two more things the defaults do not cover, which the estate passes itself: - **Generation bound to a lifecycle phase.** The default `--gen-cmd` (`mvn -B -q From 982d1996dab68dabe6884f40ccc32cf4cff6cfe4 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Thu, 26 Nov 2026 18:22:18 -0500 Subject: [PATCH 5/6] no-mistakes(test): apply changes made during test validation --- .../packages/cli/test/gen-generator-throw-cause.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts b/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts index 53a0269edc..4bc2fd54a5 100644 --- a/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts +++ b/server/typescript/packages/cli/test/gen-generator-throw-cause.test.ts @@ -118,7 +118,7 @@ describe("describeErrorCause", () => { test("the --verbose hint appears only when there is a stack to show", () => { expect(describeErrorCause(new Error("x", { cause: "socket closed" }), false)).toEqual(["caused by: socket closed"]); const stackless = new Error("inner"); - stackless.stack = undefined; + (stackless as { stack?: string | undefined }).stack = undefined; expect(describeErrorCause(new Error("x", { cause: stackless }), false)).toEqual(["caused by: Error: inner"]); }); }); From cb877779aa3e5e99689eef2f936dfc946a23d0da Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Thu, 26 Nov 2026 18:34:07 -0500 Subject: [PATCH 6/6] no-mistakes(document): Update Kotlin enum column docs for TEXT default --- docs/features/field-types.md | 2 +- server/java/codegen-kotlin/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/features/field-types.md b/docs/features/field-types.md index 7a56005697..f99ec517ac 100644 --- a/docs/features/field-types.md +++ b/docs/features/field-types.md @@ -492,7 +492,7 @@ object AuthorTable : Table("authors") { val name = varchar("name", 200) val bio = varchar("bio", 2000).nullable() val priceCents = long("price_cents") - val status = enumerationByName("status", 64, AuthorStatus::class) + val status = enumerationByName("status", 32, AuthorStatus::class) // sized enum; with no length: customEnumeration("status", "TEXT", ...) val createdAt = timestampWithTimeZone("created_at") override val primaryKey = PrimaryKey(id) } diff --git a/server/java/codegen-kotlin/README.md b/server/java/codegen-kotlin/README.md index 03ca596ee2..613ab997ad 100644 --- a/server/java/codegen-kotlin/README.md +++ b/server/java/codegen-kotlin/README.md @@ -25,7 +25,7 @@ Kotlin codegen target for Spring-Boot-Kotlin consumers on Exposed + Flyway. Emit | `field.timestamp` | `java.time.Instant` | `timestampWithTimeZone(name)` | | `field.currency` | `Long` (minor units — wire format invariant) | `long(name)` | | `field.uuid` | `java.util.UUID` | `uuid(name)` | -| `field.enum` | typed Kotlin `enum class` (separate `.kt` file with `@Serializable`) | `enumerationByName(name, 64, ::class)` | +| `field.enum` | typed Kotlin `enum class` (separate `.kt` file with `@Serializable`) | `enumerationByName(name, n, ::class)` with a length (`@maxLength` or `enums.maxLength`), else `customEnumeration(name, "TEXT", ...)`; `@intValueMap` gives `customEnumeration(name, "INTEGER", ...)` | | `field.object` (`@storage="flattened"`) | reference to the generated VO data class | per-sub-field columns: `_` | | `field.object` (`@storage="jsonb"` or default) | reference to the generated VO data class | single `jsonb(name, { metaJsonbMapper.writeValueAsString(it) }, { metaJsonbMapper.readValue(it, VO::class.java) })` — backed by a generated per-package `MetaJsonbMapper.kt` Jackson `ObjectMapper` (array-of-VO uses a `TypeReference>`); consumers add `jackson-databind` + `jackson-module-kotlin` + `jackson-datatype-jsr310` (no `kotlin("plugin.serialization")` compiler plugin) |