Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 50 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,43 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
rule that is in force. A pipeline that read `.hashes.json` directly reads every file in
`.hashes/` instead. ADR-0064 Amendment 1;
[docs/features/migrations/per-package-hash-manifest.md](docs/features/migrations/per-package-hash-manifest.md).
- **Ignore the generation key and keep the hash manifest: two `.gitignore` lines.** `gen` now writes
an uncommitted `.metaobjects/.gen-state/.fingerprint-<port>.json` (one per module on the JVM). In a
project whose root `.gitignore` already ignores generated state, add
`**/.metaobjects/.gen-state/*` and `!**/.metaobjects/.gen-state/.hashes/`; otherwise the key shows
as untracked. The exception matters: the key stays uncommitted and the per-package hash manifest
under `.hashes/` stays committed, so do not ignore the whole `.metaobjects/` directory. A project
that took the 1.2.3 lines (`!**/.metaobjects/.gen-state/.hashes.json`) replaces that one.
- **Every join a generated view or report makes is `LEFT OUTER`.** A row whose reference is null,
or whose related row is missing, now appears with nulls in the joined columns instead of
vanishing. Expect the regenerated view bodies to differ in `meta migrate`: one view replacement
per view that joined through a required reference.
- **TypeScript and C#: a projection that extends another keeps its super's identity anchor.** Over a
table-per-hierarchy root, a projection whose own fields bind a subtype's column used to return
only that subtype's rows; its view now returns **every** row of the shared table, the subtype
column NULL on the others. The load warns when a projection's output widened this way.
- **`meta migrate` and `meta verify --db` refuse a foreign key onto columns the target does not hold
unique** (`FkTargetNotUniqueError`, listing every offending reference at once), where the
database refused it at apply time after earlier statements had run. A foreign key onto a
hand-made unique index can fail `verify --db` that passed before.
- **On Postgres the primary key's name is compared.** A convention switch or a table rename
renames the key in place, and `meta verify --db` reports a mismatch it used to pass.
- **`meta verify` exits 2 when `metaobjects.config.ts` exists but fails to load**, and prints that
load error (and so does `meta prompt-snapshot`), where it used to continue without the
config's providers and report an unknown subtype.
- **TypeScript and Python: two shared enums with one name are `ERR_NAME_COLLISION`.** The second
used to be dropped silently and its fields typed with the first one's members. Rename one.
- **TypeScript: an owned generator that imports one of ts-poet's `def`, `literalOf`, `arrayOf`,
`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.
- **`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
the read side already did. A cast such as `(Status)99` used to be stored as the last member's
integer.
- **C# and Java: a names class no longer extends its base's** when that would make a base constant
that is not a column of its own table reachable through it. It is emitted complete instead.
- **`metamodelVersion` is `1.3`.** Upgrade every port together.

### Security
Expand Down Expand Up @@ -856,8 +893,10 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
migrations and one built by `meta migrate` match. A project can supply its own conventions
object from `metaobjects.config.ts`; an unknown preset name, or an object missing a member, is
refused by name. The PK name is now introspected too, so a `baseline --from-db` snapshot of a
database whose primary keys are not named `<table>_pkey` records their names (not compared;
nothing churns). See `docs/features/migrations-and-drift.md`, "Schema conventions".
database whose primary keys are not named `<table>_pkey` records their names. On Postgres the name
is then compared, so a convention switch or a table rename renames the key in place and
`meta verify --db` reports a mismatch it used to pass (see "A constraint or index whose only change
is its name is renamed in place", below). See `docs/features/migrations-and-drift.md`, "Schema conventions".
- **`migrate.checks.skipRedundant`: leave out the CHECKs a column type already enforces.** Set in
`.metaobjects/config.json` (default `false`), `meta migrate` and `meta verify --db` leave out a
`validator.length` maximum the column's `VARCHAR(n)` enforces (not on SQLite or D1, which do not
Expand Down Expand Up @@ -1776,11 +1815,13 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
any build globs or `<Compile>` items that named the flat files. Python and the JVM ports follow
in #544–#549 (`docs/CONFORMANCE.md`, "Generated paths keyed by package").

- **Breaking, C#: a generated type's namespace is its metadata package (rulings R64, R65).** With
no binding for it, a packaged type's namespace is the package itself, each `::` segment
PascalCased (`acme::alpha` → `Acme.Alpha`), as the Java and Kotlin ports map packages, whether
or not a namespace is configured. `--namespace` / `csharp.namespace` (`GenConfig.Namespace`) now
places only the objects with no package and the artifacts of no single object: the context and
- **C#, opt-in: with `csharp.packageNamespaces: true`, a generated type's namespace is its metadata
package (rulings R64, R65).** This is **not** the default: with the setting off (its default) and
a `csharp.namespace` configured, every type stays in that namespace and the output is
byte-identical to 1.2.0. With the setting on and no binding for a type, a packaged type's
namespace is the package itself, each `::` segment PascalCased (`acme::alpha` → `Acme.Alpha`),
as the Java and Kotlin ports map packages, even when a namespace is configured.
`--namespace` / `csharp.namespace` (`GenConfig.Namespace`) then places only the objects with no package and the artifacts of no single object: the context and
its design-time services, the callable wrappers, the template tier (render helpers, parsers,
extractors, output prompts) and the shared runtime helpers. A per-object companion follows its
object into the package namespace: `<X>Names`, `<X>FilterAllowlist`, `<X>Routes`, `<X>Queries`
Expand All @@ -1800,7 +1841,8 @@ Each item below is described in full under Security, Added, Changed or Fixed; th
keeps its meaning (the package mapping applies only to the default `Flatten`). A hook override
on `DbContextGenerator` receives the `global::`-qualified type as its `owner` argument
(`global::Acme.Alpha.Note`), which it can splice into `Entity<{owner}>` as before. A `@provided`
enum is the adopter's type and is named as configured, unchanged. **Upgrade note:** on the next
enum is the adopter's type and is named as configured, unchanged. **Upgrade note:** none unless you
turn the setting on. When you do, on the next
`gen`, every generated type in a package that no `PackageNamespaces`, `TypeOverrides` or
`Convention` entry maps moves once, from the configured namespace to its package's namespace,
together with its routes, reverse finders, names, filter allowlist and report export; update
Expand Down
9 changes: 5 additions & 4 deletions docs/CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ the metadata package, so two packages that each declare an object of the same na
collide on an output path. State per port:

- *Done, C#:* every per-object generator writes through `OutputPaths.Of`
(`<package segments>/<file>`; root-level objects at the root). The path follows the metadata
package, not `PackageNamespaces`. Since rc.19 R65 the namespace follows the package too
(`acme::alpha` → `Acme.Alpha`) unless a binding maps it; every cross-namespace reference is
`global::`-qualified. Tests: `OutputPathsTests`, `PackageNamespaceTests`.
(`<package segments>/<file>` under `csharp.outputLayout: "package"`, opt-in; flat otherwise;
root-level objects at the root). The path follows the metadata package, not `PackageNamespaces`.
The namespace follows the package only with `csharp.packageNamespaces: true`, opt-in since
1.3.0 (R64, R65; `acme::alpha` → `Acme.Alpha`), unless a binding maps it; every cross-namespace
reference is `global::`-qualified. Tests: `OutputPathsTests`, `PackageNamespaceTests`.
- *Done, TypeScript:* `outputLayout` defaults to `"flat"`; `"package"` is opt-in (ruling
R63). Tests: `barrel-layout.test.ts` (the barrel exports the same
names in both layouts), `naming/name-claims.test.ts`.
Expand Down
7 changes: 7 additions & 0 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,13 @@ strategy mismatches) that the unit suites missed.

### 2c. Run an adopter estate against the RC (1.0 gate G3d)

> **Staged candidates.** The checklist below is the final-cut gate. Each staged candidate
> (`1.3.0-rc.N`, published to the private registry with `bun run prerelease:candidate`) has its
> own run sheet and a script for its mechanical steps:
> [`tools/prerelease/estate-run.md`](../tools/prerelease/estate-run.md) and
> `tools/prerelease/estate-run.sh`. The commit each candidate was built from is recorded in
> [`tools/prerelease/candidates.md`](../tools/prerelease/candidates.md).

Every corpus in this repo can be green while a real application built on the release is
broken — the defects live where features meet, in models no fixture composes. Before
promoting, run at least one adopter estate against the candidate, end to end, and treat a
Expand Down
57 changes: 57 additions & 0 deletions docs/features/prerelease.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,63 @@ model and never was the durable one. These are:

---

## 2a. Staged candidates

A release that arrives as a series of candidates (`1.3.0-rc.1`, `-rc.2`, …), each run against
the adopter estates before the next is cut, uses this tool and **not** `bun run release`.
`release.mjs` always publishes to public npm `latest`, commits the version and dates the
CHANGELOG; the private-registry path does none of that, and it does not run the maintenance-branch
check that gates the final cut (`docs/RELEASING.md`, Step 0).

**A full candidate, every registry:**

```bash
bun run prerelease:candidate # = bun run prerelease:publish --only all
```

The default scope is npm and Maven only, so a Python or a C# estate gets nothing from a bare
`prerelease:publish`. Use the full command for any candidate an estate in those ports will run;
name a narrower `--only` only for a fix you are iterating on one port.

**The log.** Every run that starts a publish appends one row to
[`tools/prerelease/candidates.md`](../../tools/prerelease/candidates.md): the candidate, the full
`HEAD` it was built from (shortened to 12 characters, `+dirty` when tracked files outside the
version declarations were modified), the UTC date, and the ecosystems published. A run that stops
partway still writes its row: a registry whose publish began but did not finish reads
`<ecosystem> (cut short)`, because its candidate number is taken there, and a registry the run
was asked for but never reached reads `stopped before <ecosystem>`. A dry run writes no row. It
names ecosystems, never the registry host. The script writes the row after it has restored the
version files, so the row is the only change the run leaves; **commit it**, so the repository
records what each candidate was built from. Build a candidate from a commit that is already
pushed: a sha nobody can fetch is not a record.

**Estate runs.** What an estate does with a candidate is
[`tools/prerelease/estate-run.md`](../../tools/prerelease/estate-run.md), with
`tools/prerelease/estate-run.sh` for the mechanical part.

### Rust

There is no Rust candidate on the private registry: the three crates are `publish = false` and
the registry serves npm, PyPI, NuGet and Maven. A Rust consumer **pins the commit** the
candidate's row in the log names:

```toml
[dependencies]
metaobjects = { git = "https://github.com/metaobjectsdev/metaobjects", rev = "<commit from candidates.md>" }
```

```bash
cargo install --git https://github.com/metaobjectsdev/metaobjects --rev <commit> metaobjects-cli
```

Cargo finds each crate by name inside the repository, so the same `rev` serves
`metaobjects`, `metaobjects-codegen` and `metaobjects-cli`. Use the full 40-character sha for
`rev` (the log shortens it; `git rev-parse <short>` expands it in a clone). `cargo meta --version` prints
only the crate version, so read the commit back from `Cargo.lock`'s `source` line (it ends in
`#<sha>`), the way the other ports read their resolved versions.

---

## 3. Consuming — one command in each direction

```bash
Expand Down
6 changes: 6 additions & 0 deletions docs/ports/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ from the checkout:
cargo install --path <repo-root>/server/rust/metaobjects-cli
```

To use a candidate or any other commit without a checkout, pin it from git
(`cargo install --git https://github.com/metaobjectsdev/metaobjects --rev <commit> metaobjects-cli`,
and the same `git` + `rev` on a `metaobjects` dependency). The candidate log
(`tools/prerelease/candidates.md`) names the commit each staged candidate was built from; see
[Pre-releases, "Rust"](../features/prerelease.md#rust).

| Command | What it does |
|---|---|
| `cargo meta init [--project <dir>]` | Scaffolds `.metaobjects/config.json`, `.metaobjects/.gitignore` (which keeps `.gen-state/.hashes/` committed) and a first `metaobjects/meta.app.yaml`. It writes only what is missing, and never adds an empty metadata file to a project that already has metadata. |
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"site:preview": "bun scripts/site-preview.ts",
"clean": "rm -rf server/typescript/packages/*/dist server/typescript/packages/*/*.tsbuildinfo client/web/packages/*/dist client/web/packages/*/*.tsbuildinfo",
"release": "bun scripts/release.mjs",
"prerelease:publish": "bun scripts/prerelease.mjs"
"prerelease:publish": "bun scripts/prerelease.mjs",
"prerelease:candidate": "bun scripts/prerelease.mjs --only all"
},
"devDependencies": {
"bun-types": "latest",
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ gate_site_reference() { bun_install && bun scripts/build-site-reference.ts --che
# exercised) are the ones worth a test at all. See scripts/maven-coordinate.mjs.
# And the publish workflows' tag check (scripts/check-release-tag.mjs), whose test also reads
# each real manifest, so a layout change fails here rather than on a release tag.
gate_release_tag() { bun test scripts/finish-release.test.ts scripts/eject-release-gate.test.ts && node scripts/test-maven-coordinate.mjs && node scripts/test-prerelease-version.mjs && node scripts/test-check-release-tag.mjs && node scripts/test-changelog-promote.mjs && node scripts/test-release-branch.mjs && bash tools/prerelease/test-prerelease-link.sh; }
gate_release_tag() { bun test scripts/finish-release.test.ts scripts/eject-release-gate.test.ts && node scripts/test-maven-coordinate.mjs && node scripts/test-prerelease-version.mjs && node scripts/test-check-release-tag.mjs && node scripts/test-changelog-promote.mjs && node scripts/test-release-branch.mjs && bash tools/prerelease/test-prerelease-link.sh && bash tools/prerelease/test-estate-run.sh; }

# ── repo-root scripts/ typechecks ─────────────────────────────────────────────
# `bun test` transpiles per file and never typechecks, and `bun run --filter '*'
Expand Down
41 changes: 41 additions & 0 deletions scripts/prerelease-version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// does this cut get?" from a source that cannot be wrong in the way the old one was.

import { spawn } from "node:child_process";
import { appendFileSync, existsSync, mkdirSync, writeFileSync } from "node:fs";
import { dirname } from "node:path";

/** Compare two plain x.y.z versions: negative, zero or positive. */
export function cmpVer(a, b) {
Expand Down Expand Up @@ -99,6 +101,45 @@ export async function collectPages(fetchPage, limit = 50, maxPages = 1000) {
throw new Error(`the listing did not end within ${maxPages} pages`);
}

/** The header of the committed candidate log (tools/prerelease/candidates.md). */
export const CANDIDATE_LOG_HEADER =
"# Staged candidates\n\n" +
"One row per `bun run prerelease:publish` that published or was cut short. The columns, and the rule\n" +
"to commit each row, are in docs/features/prerelease.md, section 2a.\n\n" +
"| Candidate | Commit | Date (UTC) | Registries |\n|---|---|---|---|\n";

/**
* One row of the candidate log. `candidate` is the canonical `<base>-rc.<N>`; `registries` the
* ecosystems actually published (npm, python, csharp, java).
*/
export function candidateLogRow({ candidate, commit, dirty, date, registries }) {
if (!/^\d+\.\d+\.\d+-rc\.\d+$/.test(candidate)) throw new Error(`not a candidate version: ${candidate}`);
if (!/^[0-9a-f]{40}$/.test(commit)) throw new Error(`not a full commit sha: ${commit}`);
if (!registries.length) throw new Error("a candidate row names at least one registry");
const day = date.toISOString().slice(0, 16).replace("T", " ");
return `| ${candidate} | \`${commit.slice(0, 12)}${dirty ? "+dirty" : ""}\` | ${day} | ${registries.join(", ")} |\n`;
}

/**
* The registries a run names in its log row. `published` finished, `started` began a publish call,
* `only` is the ordered selection the run was asked for. One that started and did not finish was
* cut short, and its candidate number is burned there; one never started is reported as stopped before.
*/
export function candidateRegistries({ published, started, only }) {
const cutShort = started.filter((p) => !published.includes(p)).map((p) => `${p} (cut short)`);
const stopped = only.filter((p) => !started.includes(p));
return [...published, ...cutShort, ...(stopped.length ? [`stopped before ${stopped.join(", ")}`] : [])];
}

/** Append `row` to the log at `path`, creating it with its header when it does not exist. */
export function appendCandidateLog(path, row) {
if (!existsSync(path)) {
mkdirSync(dirname(path), { recursive: true });
writeFileSync(path, CANDIDATE_LOG_HEADER);
}
appendFileSync(path, row);
}

const active = new Set();

/**
Expand Down
Loading
Loading