From 4c8234705b55c1e487da2555409f85c9ff5a1804 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 18:59:43 -0500 Subject: [PATCH 1/9] docs(changelog): correct the C# namespace and primary-key entries; add the missing upgrade items --- CHANGELOG.md | 58 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31e524e19c..a5e2a42d39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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-.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 @@ -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 `_pkey` records their names (not compared; - nothing churns). See `docs/features/migrations-and-drift.md`, "Schema conventions". + database whose primary keys are not named `
_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 @@ -1776,11 +1815,13 @@ Each item below is described in full under Security, Added, Changed or Fixed; th any build globs or `` 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: `Names`, `FilterAllowlist`, `Routes`, `Queries` @@ -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 From 451a4208a38802edf0280b3893cb84c9aeeb093f Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 19:01:58 -0500 Subject: [PATCH 2/9] feat(prerelease): staged-candidate log, full-candidate command and the Rust git pin --- docs/features/prerelease.md | 54 +++++++++++++++++++++++++++++ docs/ports/rust.md | 6 ++++ package.json | 3 +- scripts/prerelease-version.mjs | 32 +++++++++++++++++ scripts/prerelease.mjs | 16 ++++++++- scripts/test-prerelease-version.mjs | 27 ++++++++++++++- tools/prerelease/candidates.md | 9 +++++ 7 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 tools/prerelease/candidates.md diff --git a/docs/features/prerelease.md b/docs/features/prerelease.md index 2131f79d65..5eedaf7ee8 100644 --- a/docs/features/prerelease.md +++ b/docs/features/prerelease.md @@ -136,6 +136,60 @@ 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 publishes 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. 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 = "" } +``` + +```bash +cargo install --git https://github.com/metaobjectsdev/metaobjects --rev 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 ` 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 +`#`), the way the other ports read their resolved versions. + +--- + ## 3. Consuming — one command in each direction ```bash diff --git a/docs/ports/rust.md b/docs/ports/rust.md index 29666cd447..a68f8ca742 100644 --- a/docs/ports/rust.md +++ b/docs/ports/rust.md @@ -39,6 +39,12 @@ from the checkout: cargo install --path /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 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 ]` | 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. | diff --git a/package.json b/package.json index 2051a2ba7c..0fa436d54b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/prerelease-version.mjs b/scripts/prerelease-version.mjs index e54510abf0..48d1560634 100644 --- a/scripts/prerelease-version.mjs +++ b/scripts/prerelease-version.mjs @@ -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) { @@ -99,6 +101,36 @@ 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, appended by the script and committed by\n" + + "the person who ran it. `Commit` is the `HEAD` the candidate was built from (`+dirty` when tracked\n" + + "files outside the version declarations were modified). `Registries` names ecosystems, never\n" + + "hosts. A Rust consumer pins that commit (docs/features/prerelease.md, \"Rust\").\n\n" + + "| Candidate | Commit | Date (UTC) | Registries |\n|---|---|---|---|\n"; + +/** + * One row of the candidate log. `candidate` is the canonical `-rc.`; `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`; +} + +/** 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(); /** diff --git a/scripts/prerelease.mjs b/scripts/prerelease.mjs index db5c71a18f..b594caa0ca 100644 --- a/scripts/prerelease.mjs +++ b/scripts/prerelease.mjs @@ -6,6 +6,7 @@ // bun run prerelease:publish # next iteration, npm + Maven (the default scope) // bun run prerelease:publish --only npm,csharp # pick ports // bun run prerelease:publish --only all # all four +// bun run prerelease:candidate # the same: a FULL candidate, every registry // bun run prerelease:publish --iter 5 # pin the iteration number // bun run prerelease:publish --base 0.25.0 # override the in-development version // @@ -64,7 +65,7 @@ import { join } from "node:path"; import { mavenVersion } from "./maven-coordinate.mjs"; import { TIER_ORDER } from "./publish-set.mjs"; import { - changelogVersions, collectPages, decideBase, installRestoreHandlers, releasedVersion, run as runStep, + appendCandidateLog, candidateLogRow, changelogVersions, collectPages, decideBase, installRestoreHandlers, releasedVersion, run as runStep, } from "./prerelease-version.mjs"; const argv = process.argv.slice(2); @@ -417,6 +418,19 @@ if (wants("java")) { } restore(); +if (!DRY) { + // The repository's record of which commit each candidate was built from. Appended after the + // version declarations are restored, so the entry is the only change this run leaves behind. + const logPath = join(ROOT, "tools/prerelease/candidates.md"); + const LOG = "tools/prerelease/candidates.md"; + const dirtyOther = sh("git status --porcelain --untracked-files=no").split("\n") + .filter((l) => l.trim() && !l.endsWith(LOG)).length > 0; + appendCandidateLog(logPath, candidateLogRow({ + candidate: CANON, commit: sh("git rev-parse HEAD").trim(), dirty: dirtyOther, + date: new Date(), registries: ONLY, + })); + ok(`recorded ${CANON} in ${LOG} — commit that line`); +} if (DRY) { console.log(`\n\x1b[32m\x1b[1m✔ dry run of ${CANON} passed; nothing was published.\x1b[0m\n`); } else { diff --git a/scripts/test-prerelease-version.mjs b/scripts/test-prerelease-version.mjs index 0b07f458bd..63df00c387 100644 --- a/scripts/test-prerelease-version.mjs +++ b/scripts/test-prerelease-version.mjs @@ -9,6 +9,7 @@ // P2 the iteration counter reads every page of the registry's listing. // P3 a SIGTERM restores the version files, as exit and SIGINT already did, and stops a step that // is still running instead of letting the run publish the remaining registries first. +// P5 every published candidate leaves one row in the committed log: candidate, commit, date, registries. // P4 only CHANGELOG sections on the released major line or the next one count; the old Maven-only [7.x] sections // made a cut after 1.2.0 propose 7.20.12. import assert from "node:assert/strict"; @@ -18,7 +19,8 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { pathToFileURL } from "node:url"; import { - changelogVersions, collectPages, decideBase, latestReleaseTag, releasedVersion, run, + CANDIDATE_LOG_HEADER, appendCandidateLog, candidateLogRow, changelogVersions, collectPages, decideBase, + latestReleaseTag, releasedVersion, run, } from "./prerelease-version.mjs"; let fails = 0; @@ -168,5 +170,28 @@ await test("a step resolves to its stdout and rejects on a non-zero exit", async await assert.rejects(run("echo boom >&2; exit 3"), /exit 3.*\n.*boom/s); }); +await test("a candidate row names the commit, the date and the registries, and never a host", () => { + const sha = "0123456789abcdef0123456789abcdef01234567"; + assert.equal( + candidateLogRow({ candidate: "1.3.0-rc.1", commit: sha, dirty: false, date: new Date("2026-11-20T09:05:59Z"), registries: ["npm", "java"] }), + "| 1.3.0-rc.1 | `0123456789ab` | 2026-11-20 09:05 | npm, java |\n"); + assert.match(candidateLogRow({ candidate: "1.3.0-rc.2", commit: sha, dirty: true, date: new Date(0), registries: ["npm"] }), /`0123456789ab\+dirty`/); + assert.throws(() => candidateLogRow({ candidate: "1.3.0", commit: sha, dirty: false, date: new Date(0), registries: ["npm"] }), /not a candidate/); + assert.throws(() => candidateLogRow({ candidate: "1.3.0-rc.1", commit: "abc", dirty: false, date: new Date(0), registries: ["npm"] }), /full commit sha/); + assert.throws(() => candidateLogRow({ candidate: "1.3.0-rc.1", commit: sha, dirty: false, date: new Date(0), registries: [] }), /at least one registry/); +}); + +await test("the candidate log is created with its header once and then only appended to", () => { + const dir = mkdtempSync(join(tmpdir(), "mo-candidate-log-")); + try { + const path = join(dir, "nested", "candidates.md"); + appendCandidateLog(path, "| a |\n"); + appendCandidateLog(path, "| b |\n"); + assert.equal(readFileSync(path, "utf8"), `${CANDIDATE_LOG_HEADER}| a |\n| b |\n`); + } finally { + rmSync(dir, { recursive: true, force: true }); + } +}); + if (fails) { console.error(`${fails} failure(s)`); process.exit(1); } console.log("all prerelease-version tests passed"); diff --git a/tools/prerelease/candidates.md b/tools/prerelease/candidates.md new file mode 100644 index 0000000000..11c0bcaaca --- /dev/null +++ b/tools/prerelease/candidates.md @@ -0,0 +1,9 @@ +# Staged candidates + +One row per `bun run prerelease:publish` that published, appended by the script and committed by +the person who ran it. `Commit` is the `HEAD` the candidate was built from (`+dirty` when tracked +files outside the version declarations were modified). `Registries` names ecosystems, never +hosts. A Rust consumer pins that commit (docs/features/prerelease.md, "Rust"). + +| Candidate | Commit | Date (UTC) | Registries | +|---|---|---|---| From 45c04e3824ec277eee1aa2326c29980e545be29d Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 19:04:11 -0500 Subject: [PATCH 3/9] feat(prerelease): the estate run sheet and a script for its mechanical steps --- docs/RELEASING.md | 7 + scripts/ci-local.sh | 2 +- tools/prerelease/estate-run.md | 93 ++++++++++++++ tools/prerelease/estate-run.sh | 190 ++++++++++++++++++++++++++++ tools/prerelease/test-estate-run.sh | 59 +++++++++ 5 files changed, 350 insertions(+), 1 deletion(-) create mode 100644 tools/prerelease/estate-run.md create mode 100755 tools/prerelease/estate-run.sh create mode 100755 tools/prerelease/test-estate-run.sh diff --git a/docs/RELEASING.md b/docs/RELEASING.md index 3e69c2ab3e..d0056190da 100644 --- a/docs/RELEASING.md +++ b/docs/RELEASING.md @@ -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 diff --git a/scripts/ci-local.sh b/scripts/ci-local.sh index a2962f53cd..51edf0119b 100755 --- a/scripts/ci-local.sh +++ b/scripts/ci-local.sh @@ -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 '*' diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md new file mode 100644 index 0000000000..7ea5d88884 --- /dev/null +++ b/tools/prerelease/estate-run.md @@ -0,0 +1,93 @@ +# Running an adopter estate against a staged candidate + +A candidate (`1.3.0-rc.N`) is proved on real estates before the next one is cut. Every corpus in +this repository can be green while an application built on the release is broken, because the +defects live where features meet, in models no fixture composes. This page is the run sheet +(1.0 gate G3d, `docs/RELEASING.md` §2c, is the same idea for the final cut). An agent does the +run; nobody needs to do it by hand. + +Publishing the candidate is `bun run prerelease:candidate` +([docs/features/prerelease.md](../../docs/features/prerelease.md), "Staged candidates"); the commit +each candidate was built from is in [candidates.md](candidates.md). + +## The mechanical part: `estate-run.sh` + +```bash +tools/prerelease/estate-run.sh --project --port ts|python|csharp|java \ + --version 1.3.0-rc.N --build-cmd '' --test-cmd '' \ + [--db-cmd '']... [--report ] +``` + +It refuses an estate whose git tree is not clean, links the candidate, installs clean and **reads +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), then runs the drift gate, your build, your tests and your database commands. +A command you do not pass is reported `skipped`, never `passed`. It unlinks on the way out, however +the run ended, and prints a report. `--no-link` is for an estate already linked another way; +`--keep-linked` leaves the link in place. `--help` lists the per-port defaults and the flags that +override them. Rust has no estate path: a Rust consumer pins the commit +(`docs/features/prerelease.md`, "Rust"). + +## Every candidate, every estate (the base run) + +1. Link the candidate, install clean, and read the installed versions back. *(script)* +2. Regenerate. Then regenerate again: **the second run must write zero files.** *(script)* +3. `verify` with the drift gate on. Build. Run the estate's tests. *(script, given the commands)* +4. On an estate with a database: `meta migrate --dry-run` and, on Postgres, `meta verify --db`. + Schema is owned by the Node `meta` in every port, so a non-TypeScript estate runs these from a + TypeScript install. *(script, given `--db-cmd`)* +5. Boot the app and compare a few API answers with the released version. *(by hand or agent)* +6. Record: files changed, time taken, every failure with its message. Unlink. *(script)* + +## What each candidate adds + +**rc.1, "as built".** Every diff must be explained by an item in the CHANGELOG upgrade list +("Upgrading from 1.2.0"). A diff that is not there is a CHANGELOG defect or a bug, and it is +fixed before rc.2. Watch for: + +- `400 unknown_fields` from forms that post whole records; +- one view replacement per view that joins through a required reference; +- new `verify --db` failures on a foreign key onto a hand-made unique index; +- `RESTART WITH` in the first C# EF migration; +- classes missing on JVM estates whose pom carries ``; +- owned generator copies that no longer load; +- a template that now raises on a misspelt variable. + +**rc.2, new output, TypeScript and Python estates.** + +- Expect every generated file to change once, in layout only. Check it by formatting the old and + the new tree with the estate's own formatter and comparing: what remains must be empty or listed. +- Count hand-edited generated files. On TypeScript the three-way merge conflicts more than usual, + because the base layout changed under every edit. Move edits into hooks or owned generators + first where that is possible, and report the count. +- Owned generator copies from 1.2 must still load and generate. +- Commit the new hash manifest (`.metaobjects/.gen-state/.hashes/`). +- C#, Java and Kotlin estates run the base run only and must see **no** diff against rc.1. + +**rc.3, new output, C#, Java and Kotlin; TypeScript service code.** + +- C#, Java and Kotlin estates: the same one-time layout diff. There was no formatter before, so the + check is compile plus tests plus the API comparison. +- TypeScript and Python estates: the base run only, no diff against rc.2. +- One or two TypeScript estates pilot the service code on one package (the rc.4 steps below), + before four ports copy the design. + +**rc.4, service code everywhere.** On every estate: + +1. Pick one package that has a real status field. Declare its lifecycle (states and transitions), + one real operation, and its permission points. +2. Add the service generators for that package only, using the port's filter. Leave the other + packages on the existing generators, which proves the two coexist. +3. Write the policy, the operation bodies and the event hook against the generated interfaces. + Supply the actor resolver. +4. Call the service from one caller that is not HTTP (a job or a test) and confirm it gets the + same refusals. +5. Report what the vocabulary could not express. The vocabulary is experimental, and this is the + last point where it can change cheaply. + +## The report + +Attach the script's report to the estate's tracking note, plus: the manual step 5 result, the +hand-edit count (rc.2), and any diff the upgrade list did not explain. A failure is a finding +with its message and the step that raised it, never a summary. diff --git a/tools/prerelease/estate-run.sh b/tools/prerelease/estate-run.sh new file mode 100755 index 0000000000..c096b6f393 --- /dev/null +++ b/tools/prerelease/estate-run.sh @@ -0,0 +1,190 @@ +#!/usr/bin/env bash +# Run one adopter estate against a staged candidate: the mechanical part of the estate run +# sheet (tools/prerelease/estate-run.md). It does steps 1 to 4 and 6 of "every candidate, every +# estate" and prints a report; booting the app and comparing API answers stays a person's (or an +# agent's) step, and the report says so. +# +# tools/prerelease/estate-run.sh --project --port ts|python|csharp|java \ +# --version 1.3.0-rc.N [--build-cmd ] [--test-cmd ] [--db-cmd ]... \ +# [--install-cmd ] [--gen-cmd ] [--verify-cmd ] [--versions-cmd ] \ +# [--report ] [--keep-linked] [--no-link] +# +# What it does, in order: +# 1. Refuses a project whose git tree is not clean: "files changed" is only a number +# when it starts from nothing. +# 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, +# checked by content and by modification time. +# 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. Unlinks (unless --keep-linked), however the run ended. +# +# Each estate passes its own build, test and database commands; the generation and install +# defaults below are the port's documented ones. Rust has no estate path: pin a commit +# (docs/features/prerelease.md, "Rust"). +# +# Exit status: 0 when every step that ran passed, 1 when one failed, 2 on bad usage. +set -uo pipefail + +HERE="$(cd "$(dirname "$0")" && pwd)" +PROJECT="$PWD"; PORT=""; VERSION=""; REPORT=""; KEEP=0; NOLINK=0 +INSTALL_CMD=""; GEN_CMD=""; VERIFY_CMD=""; VERSIONS_CMD=""; BUILD_CMD=""; TEST_CMD="" +DB_CMDS=() + +die() { printf '\033[31m✗ %s\033[0m\n' "$*" >&2; exit 2; } +while [ $# -gt 0 ]; do + case "$1" in + --project) PROJECT="$(cd "$2" && pwd)" || die "no such project: $2"; shift 2 ;; + --port) PORT="$2"; shift 2 ;; + --version) VERSION="$2"; shift 2 ;; + --report) REPORT="$2"; shift 2 ;; + --install-cmd) INSTALL_CMD="$2"; shift 2 ;; + --gen-cmd) GEN_CMD="$2"; shift 2 ;; + --verify-cmd) VERIFY_CMD="$2"; shift 2 ;; + --versions-cmd) VERSIONS_CMD="$2"; shift 2 ;; + --build-cmd) BUILD_CMD="$2"; shift 2 ;; + --test-cmd) TEST_CMD="$2"; shift 2 ;; + --db-cmd) DB_CMDS+=("$2"); shift 2 ;; + --keep-linked) KEEP=1; shift ;; + --no-link) NOLINK=1; shift ;; + -h|--help) sed -n '2,31p' "$0"; exit 0 ;; + *) die "unknown option: $1" ;; + esac +done + +[[ "$VERSION" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)-rc\.([0-9]+)$ ]] || die "--version must be a candidate such as 1.3.0-rc.1, got '$VERSION'" +MAJOR="${BASH_REMATCH[1]}"; MINOR="${BASH_REMATCH[2]}"; PATCH="${BASH_REMATCH[3]}"; ITER="${BASH_REMATCH[4]}" +# The version each registry spells (scripts/prerelease.mjs, `V`): npm and NuGet verbatim, PyPI +# in PEP 440 form, Maven with its major at npm's plus 7. +case "$PORT" in + ts|csharp) EXPECT="$VERSION" ;; + python) EXPECT="$MAJOR.$MINOR.${PATCH}rc$ITER" ;; + java) EXPECT="$((MAJOR + 7)).$MINOR.$PATCH-rc.$ITER" ;; + *) die "--port must be ts, python, csharp or java, got '$PORT'" ;; +esac + +git -C "$PROJECT" rev-parse --show-toplevel >/dev/null 2>&1 || die "$PROJECT is not a git repository" +[ -z "$(git -C "$PROJECT" status --porcelain --untracked-files=all)" ] \ + || die "$PROJECT has uncommitted changes — commit or stash them first, so 'files changed' means what the candidate changed" + +# ── the port's documented commands; an estate overrides any of them ─────────────────── +case "$PORT" in + ts) + if ls "$PROJECT"/bun.lock* >/dev/null 2>&1; then PM="bun install" + elif [ -f "$PROJECT/pnpm-lock.yaml" ]; then PM="pnpm install" + elif [ -f "$PROJECT/yarn.lock" ]; then PM="yarn install" + else PM="npm install"; fi + : "${INSTALL_CMD:=rm -rf node_modules && $PM}" + : "${GEN_CMD:=npx --no-install meta gen}" + : "${VERIFY_CMD:=npx --no-install meta verify --codegen}" + : "${VERSIONS_CMD:=for d in node_modules/@metaobjectsdev/*/; do node -p \"require('./\${d}package.json').name + '@' + require('./\${d}package.json').version\"; done}" ;; + python) + if [ -f "$PROJECT/uv.lock" ]; then INST="uv sync"; else INST="python3 -m venv .venv && .venv/bin/pip install -e ."; fi + : "${INSTALL_CMD:=rm -rf .venv && $INST}" + : "${GEN_CMD:=.venv/bin/metaobjects gen}" + : "${VERIFY_CMD:=.venv/bin/metaobjects verify --codegen}" + : "${VERSIONS_CMD:=.venv/bin/python -c \"import importlib.metadata as m; print('metaobjects@' + m.version('metaobjects'))\"}" ;; + csharp) + : "${INSTALL_CMD:=dotnet tool restore && dotnet restore --force}" + : "${GEN_CMD:=dotnet meta gen}" + : "${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}" + : "${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'}" ;; +esac + +# ── bookkeeping ─────────────────────────────────────────────────────────────────────── +WORK="$(mktemp -d "${DEV_SCRATCH:-${TMPDIR:-/tmp}}/estate-run.XXXXXX")" +ROWS="$WORK/rows"; DETAIL="$WORK/detail"; : > "$ROWS"; : > "$DETAIL" +FAILED=0; LINKED=0; STARTED="$(date +%s)" + +cleanup() { + local code=$? + if [ "$LINKED" = 1 ] && [ "$KEEP" = 0 ]; then + "$HERE/prerelease-link.sh" unlink --project "$PROJECT" >"$WORK/unlink.log" 2>&1 \ + && echo "unlinked $PROJECT" >&2 || { echo "! unlink failed:" >&2; cat "$WORK/unlink.log" >&2; } + fi + rm -rf "$WORK" + exit "$code" +} +trap cleanup EXIT + +row() { printf '| %s | %s | %ss |\n' "$1" "$2" "$3" >> "$ROWS"; } +fail_detail() { # name, log + { printf '\n### Failure: %s\n\n```\n' "$1"; tail -n 40 "$2"; printf '```\n'; } >> "$DETAIL" +} + +# step ; returns the command's status, records the row and, on failure, the log tail. +step() { + local name="$1" cmd="$2" log="$WORK/${1//[^A-Za-z0-9]/_}.log" t0 rc + t0="$(date +%s)" + ( cd "$PROJECT" && bash -c "$cmd" ) >"$log" 2>&1; rc=$? + if [ "$rc" = 0 ]; then row "$name" "passed" "$(( $(date +%s) - t0 ))" + else row "$name" "**FAILED** (exit $rc)" "$(( $(date +%s) - t0 ))"; fail_detail "$name" "$log"; FAILED=1; fi + return "$rc" +} +skipped() { row "$1" "skipped (no command given)" 0; } + +finish() { + local out; out="${REPORT:-$WORK/report.md}" + { + printf '# Estate run: %s, %s, %s\n\n' "$(basename "$PROJECT")" "$PORT" "$VERSION" + printf 'Started %s UTC, %ss in all. Estate commit `%s`.\n\n' \ + "$(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/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" + printf '\n## Not done by this script\n\nBoot the app and compare a few API answers with the released version; on an estate with a\ndatabase, also `meta migrate --dry-run` and, on Postgres, `meta verify --db` if you passed no\n`--db-cmd`. Record the result next to this report.\n' + } > "$out" + cat "$out"; [ -n "$REPORT" ] && { echo; echo "report: $out"; } + [ "$FAILED" = 0 ] || exit 1 + exit 0 +} + +# ── 1. link, install clean, read the versions back ──────────────────────────────────── +if [ "$NOLINK" = 0 ]; then + if ( cd "$PROJECT" && "$HERE/prerelease-link.sh" link --project "$PROJECT" --version "$VERSION" ) >"$WORK/link.log" 2>&1 + then LINKED=1; row "link $VERSION" "passed" 0 + else row "link $VERSION" "**FAILED**" 0; fail_detail "link $VERSION" "$WORK/link.log"; FAILED=1; finish; fi +else + row "link $VERSION" "skipped (--no-link: the read-back below is the only proof)" 0 +fi + +step "install (clean)" "$INSTALL_CMD" || finish +( cd "$PROJECT" && bash -c "$VERSIONS_CMD" ) > "$WORK/versions.txt" 2>&1 +if grep -qF -- "$EXPECT" "$WORK/versions.txt"; then row "installed version is $EXPECT" "passed" 0 +else row "installed version is $EXPECT" "**FAILED** (not in the read-back)" 0; fail_detail "installed version" "$WORK/versions.txt"; FAILED=1; finish; fi + +# ── 2. regenerate; list what changed; regenerate again and expect nothing ───────────── +step "gen (first run)" "$GEN_CMD" || finish +git -C "$PROJECT" status --porcelain --untracked-files=all > "$WORK/changed.txt" +row "files changed by the first gen" "$(wc -l < "$WORK/changed.txt")" 0 + +snapshot() { { git -C "$PROJECT" status --porcelain --untracked-files=all; git -C "$PROJECT" diff | sha256sum + git -C "$PROJECT" ls-files -co --exclude-standard -z | xargs -0 -r -I{} sha256sum "$PROJECT/{}" 2>/dev/null; } | sha256sum; } +BEFORE="$(snapshot)"; MARK="$WORK/mark"; touch "$MARK"; sleep 1 +step "gen (second run)" "$GEN_CMD" || finish +REWRITTEN="$(cd "$PROJECT" && git ls-files -co --exclude-standard | while IFS= read -r f; do [ "$f" -nt "$MARK" ] && echo "$f"; done)" +if [ "$(snapshot)" = "$BEFORE" ] && [ -z "$REWRITTEN" ]; then row "second gen writes zero files" "passed" 0 +else + row "second gen writes zero files" "**FAILED**" 0 + { printf '\n### Failure: second gen wrote files\n\n```\n'; printf '%s\n' "$REWRITTEN"; printf '```\n'; } >> "$DETAIL"; FAILED=1 +fi + +# ── 3. gates ────────────────────────────────────────────────────────────────────────── +step "verify --codegen (drift gate)" "$VERIFY_CMD" +if [ -n "$BUILD_CMD" ]; then step "build" "$BUILD_CMD"; else skipped "build"; fi +if [ -n "$TEST_CMD" ]; then step "tests" "$TEST_CMD"; else skipped "tests"; fi +if [ "${#DB_CMDS[@]}" -gt 0 ]; then + i=0; for c in "${DB_CMDS[@]}"; do i=$((i + 1)); step "database check $i" "$c"; done +else skipped "database checks"; fi + +finish diff --git a/tools/prerelease/test-estate-run.sh b/tools/prerelease/test-estate-run.sh new file mode 100755 index 0000000000..244e605c72 --- /dev/null +++ b/tools/prerelease/test-estate-run.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# Tests for tools/prerelease/estate-run.sh, against a throwaway git project with stub commands. +# +# bash tools/prerelease/test-estate-run.sh +# +# E1 a clean run passes and lists the files the first gen changed +# E2 a gen that writes on every run fails "second gen writes zero files" +# E3 a gen that rewrites identical bytes (new mtime only) fails the same check +# E4 an installed version that is not the candidate fails the run +# E5 a dirty project is refused (exit 2) before anything runs +# E6 each port spells the candidate its own way (PyPI rcN, Maven major + 7) +# 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)" +RUN="$HERE/estate-run.sh" +ROOT="$(mktemp -d "${DEV_SCRATCH:-${TMPDIR:-/tmp}}/estate-run-test.XXXXXX")" +trap 'rm -rf "$ROOT"' EXIT +fails=0 +t() { local name="$1"; shift; if "$@"; then echo "ok: $name"; else echo "FAIL: $name"; fails=$((fails + 1)); fi; } + +fresh() { # fresh → prints the project dir + local d; d="$(mktemp -d "$ROOT/p.XXXXXX")" + ( cd "$d" && git init -q && git config user.email t@t && git config user.name t + printf '%s\n' "$1" > gen.sh; echo seed > seed.txt; git add -A && git commit -q -m seed ) + echo "$d" +} +run() { # run [extra args...] + local d="$1" v="$2" port="$3"; shift 3 + bash "$RUN" --project "$d" --port "$port" --version "$v" --no-link --install-cmd true \ + --verify-cmd true --gen-cmd 'sh gen.sh' "$@" 2>&1 +} +IDEMPOTENT='[ "$(cat out.txt 2>/dev/null)" = "generated" ] || echo generated > out.txt' +VERS='--versions-cmd' + +e1() { local d out; d="$(fresh "$IDEMPOTENT")"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' --build-cmd true)"; rc=$? + [ $rc = 0 ] && grep -q 'second gen writes zero files | passed' <<<"$out" && grep -q '?? out.txt' <<<"$out"; } +e2() { local d out; d="$(fresh 'echo x >> out.txt')"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo cli@1.3.0-rc.1')"; rc=$? + [ $rc = 1 ] && grep -q 'second gen writes zero files | \*\*FAILED' <<<"$out"; } +e3() { local d out; d="$(fresh 'echo generated > out.txt')"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo cli@1.3.0-rc.1')"; rc=$? + [ $rc = 1 ] && grep -q 'second gen writes zero files | \*\*FAILED' <<<"$out"; } +e4() { local d out; d="$(fresh "$IDEMPOTENT")"; out="$(run "$d" 1.3.0-rc.2 ts $VERS 'echo @metaobjectsdev/cli@^1.3.0-rc.1')"; rc=$? + [ $rc = 1 ] && grep -q 'installed version is 1.3.0-rc.2 | \*\*FAILED' <<<"$out"; } +e5() { local d out; d="$(fresh "$IDEMPOTENT")"; echo dirt > "$d/seed.txt"; out="$(run "$d" 1.3.0-rc.1 ts $VERS true)"; rc=$? + [ $rc = 2 ] && grep -q 'uncommitted changes' <<<"$out"; } +e6() { local d1 d2 o1 o2; d1="$(fresh "$IDEMPOTENT")"; d2="$(fresh "$IDEMPOTENT")" + o1="$(run "$d1" 1.3.0-rc.4 python $VERS 'echo metaobjects@1.3.0rc4')"; o2="$(run "$d2" 1.3.0-rc.4 java $VERS 'echo com.metaobjects:x:8.3.0-rc.4')" + grep -q 'installed version is 1.3.0rc4 | passed' <<<"$o1" && grep -q 'installed version is 8.3.0-rc.4 | passed' <<<"$o2"; } +e7() { local d out; d="$(fresh "$IDEMPOTENT")"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo cli@1.3.0-rc.1' --build-cmd 'echo boom >&2; exit 3')"; rc=$? + [ $rc = 1 ] && grep -q 'build | \*\*FAILED\*\* (exit 3)' <<<"$out" && grep -q 'boom' <<<"$out" && grep -q 'tests | skipped' <<<"$out"; } + +t "E1 a clean run passes and lists what the first gen changed" e1 +t "E2 a gen that writes on every run fails the zero-write check" e2 +t "E3 a gen that rewrites identical bytes fails the zero-write check" e3 +t "E4 a read-back without the candidate fails the run" e4 +t "E5 a dirty project is refused" e5 +t "E6 PyPI and Maven spell the candidate their own way" e6 +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 b96d59f953354ca67aff22f2670c134763fd2910 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 19:08:56 -0500 Subject: [PATCH 4/9] fix(prerelease): restore the estate to its start commit, check every package version, record partial publishes --- scripts/prerelease.mjs | 44 +++++++++++++++++++---------- tools/prerelease/estate-run.sh | 42 +++++++++++++++++++++------ tools/prerelease/test-estate-run.sh | 23 +++++++++++++-- 3 files changed, 82 insertions(+), 27 deletions(-) diff --git a/scripts/prerelease.mjs b/scripts/prerelease.mjs index b594caa0ca..3d1d697e0f 100644 --- a/scripts/prerelease.mjs +++ b/scripts/prerelease.mjs @@ -278,6 +278,12 @@ const VERSION_FILES = [ const dirty = sh(`git status --porcelain -- ${VERSION_FILES.map((f) => `'${f}'`).join(" ")}`).trim(); if (dirty) die(`version-bearing files are dirty — commit or stash first:\n${dirty}`); ok("version-bearing files clean"); +// Whether the tree the candidate is built from has uncommitted work, taken now, before any +// version edit and before restore(). New untracked files count; the candidate log itself does not. +const CANDIDATE_LOG = "tools/prerelease/candidates.md"; +const builtFromDirtyTree = sh("git status --porcelain --untracked-files=all").split("\n") + .some((l) => l.trim() && l.slice(3) !== CANDIDATE_LOG); +const published = []; // registries this run actually published to, in order // The tracked files those same pathspecs cover — restore() may only revert files whose // pre-run cleanliness this gate actually verified. const covered = new Set( @@ -300,7 +306,24 @@ const restore = () => { if (!touched.length) return; try { sh(`git checkout -- ${touched.map((f) => `'${f}'`).join(" ")}`); } catch {} }; -installRestoreHandlers(restore); +// The repository's record of which commit each candidate was built from. It is written however the +// run ends, because a run that stops after one registry has still burned the candidate number +// there, and a Rust consumer pins the commit this row names. Written after restore(), so the +// entry is the only change the run leaves behind. +let recorded = false; +const recordCandidate = () => { + if (recorded || DRY || !published.length) return; recorded = true; + const stopped = ONLY.filter((p) => !published.includes(p)); + try { + appendCandidateLog(join(ROOT, CANDIDATE_LOG), candidateLogRow({ + candidate: CANON, commit: sh("git rev-parse HEAD").trim(), dirty: builtFromDirtyTree, date: new Date(), + registries: stopped.length ? [...published, `stopped before ${stopped.join(", ")}`] : published, + })); + console.log(`recorded ${CANON} in ${CANDIDATE_LOG} — commit that line`); + } catch (e) { console.error(`could not record ${CANON} in ${CANDIDATE_LOG}: ${e.message}`); } +}; +const restoreAndRecord = () => { restore(); recordCandidate(); }; +installRestoreHandlers(restoreAndRecord); const scratch = (name) => { const d = join(SCRATCH, name); rmSync(d, { recursive: true, force: true }); mkdirSync(d, { recursive: true }); return d; }; // Kept between runs (so Maven does not re-download the world every time) and deliberately @@ -355,6 +378,7 @@ if (wants("npm")) { info(`published ${pkg.short}@${V.npm}`); } ok(DRY ? "npm: dry run, nothing published" : `npm: ${ordered.length} packages @ ${V.npm} (dist-tag prerelease)`); + if (!DRY) published.push("npm"); } // ── python ──────────────────────────────────────────────────────────────────────────── @@ -369,6 +393,7 @@ if (wants("python")) { await run(`cd server/python && uv publish --publish-url "${PYPI_URL}" --username "${OWNER}" --password "${TOKEN}" ${dist}/*`); ok(`python: metaobjects ${V.pypi} → ${expectedHost}`); } else ok("python: dry run, nothing published"); + if (!DRY) published.push("python"); } // ── csharp ──────────────────────────────────────────────────────────────────────────── @@ -383,6 +408,7 @@ if (wants("csharp")) { await run(`dotnet nuget push "${out}/*.nupkg" --source "${NUGET_SRC}" --api-key "${TOKEN}"`); ok(`csharp: 4 packages @ ${V.nuget} → ${expectedHost}`); } else ok("csharp: dry run, nothing published"); + if (!DRY) published.push("csharp"); } // ── java / kotlin ───────────────────────────────────────────────────────────────────── @@ -415,22 +441,10 @@ if (wants("java")) { ` -DaltDeploymentRepository="mo-prerelease::${MAVEN_URL}"`, { stdio: "inherit" }); ok(DRY ? "java: dry run, built (package), nothing deployed" : `java: reactor @ ${V.maven} → ${expectedHost}`); + if (!DRY) published.push("java"); } -restore(); -if (!DRY) { - // The repository's record of which commit each candidate was built from. Appended after the - // version declarations are restored, so the entry is the only change this run leaves behind. - const logPath = join(ROOT, "tools/prerelease/candidates.md"); - const LOG = "tools/prerelease/candidates.md"; - const dirtyOther = sh("git status --porcelain --untracked-files=no").split("\n") - .filter((l) => l.trim() && !l.endsWith(LOG)).length > 0; - appendCandidateLog(logPath, candidateLogRow({ - candidate: CANON, commit: sh("git rev-parse HEAD").trim(), dirty: dirtyOther, - date: new Date(), registries: ONLY, - })); - ok(`recorded ${CANON} in ${LOG} — commit that line`); -} +restoreAndRecord(); if (DRY) { console.log(`\n\x1b[32m\x1b[1m✔ dry run of ${CANON} passed; nothing was published.\x1b[0m\n`); } else { diff --git a/tools/prerelease/estate-run.sh b/tools/prerelease/estate-run.sh index c096b6f393..e8698db3b7 100755 --- a/tools/prerelease/estate-run.sh +++ b/tools/prerelease/estate-run.sh @@ -20,7 +20,10 @@ # checked by content and by modification time. # 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. Unlinks (unless --keep-linked), however the run ended. +# 5. Puts the estate back as it found it (unless --keep-linked), however the run ended: unlink, +# then `git reset --hard` to the commit it started on and `git clean -fd`. That is safe only +# because step 1 required a clean tree, and it is why a dirty tree is refused. Ignored files +# (node_modules, .venv, bin, obj) stay as the candidate installed them: reinstall afterwards. # # Each estate passes its own build, test and database commands; the generation and install # defaults below are the port's documented ones. Rust has no estate path: pin a commit @@ -50,7 +53,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,31p' "$0"; exit 0 ;; + -h|--help) sed -n '2,30p' "$0"; exit 0 ;; *) die "unknown option: $1" ;; esac done @@ -103,12 +106,16 @@ esac WORK="$(mktemp -d "${DEV_SCRATCH:-${TMPDIR:-/tmp}}/estate-run.XXXXXX")" ROWS="$WORK/rows"; DETAIL="$WORK/detail"; : > "$ROWS"; : > "$DETAIL" FAILED=0; LINKED=0; STARTED="$(date +%s)" +START_HEAD="$(git -C "$PROJECT" rev-parse HEAD)" cleanup() { local code=$? if [ "$LINKED" = 1 ] && [ "$KEEP" = 0 ]; then "$HERE/prerelease-link.sh" unlink --project "$PROJECT" >"$WORK/unlink.log" 2>&1 \ - && echo "unlinked $PROJECT" >&2 || { echo "! unlink failed:" >&2; cat "$WORK/unlink.log" >&2; } + || { echo "! unlink failed:" >&2; cat "$WORK/unlink.log" >&2; } + # unlink repins to the public latest; the estate goes back to the commit it started on instead. + git -C "$PROJECT" reset -q --hard "$START_HEAD" && git -C "$PROJECT" clean -qfd \ + && echo "restored $PROJECT to ${START_HEAD:0:12}" >&2 || echo "! could not restore $PROJECT to $START_HEAD" >&2 fi rm -rf "$WORK" exit "$code" @@ -160,19 +167,36 @@ fi step "install (clean)" "$INSTALL_CMD" || finish ( cd "$PROJECT" && bash -c "$VERSIONS_CMD" ) > "$WORK/versions.txt" 2>&1 -if grep -qF -- "$EXPECT" "$WORK/versions.txt"; then row "installed version is $EXPECT" "passed" 0 -else row "installed version is $EXPECT" "**FAILED** (not in the read-back)" 0; fail_detail "installed version" "$WORK/versions.txt"; FAILED=1; finish; fi +# 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. +VCOUNT="$(grep -ci 'metaobjects' "$WORK/versions.txt")" +STALE="$(grep -i 'metaobjects' "$WORK/versions.txt" | grep -vE -- "(^|[^0-9A-Za-z.+-])${EXPECT//./\\.}([^0-9A-Za-z.+-]|$)")" +if [ "$VCOUNT" -gt 0 ] && [ -z "$STALE" ]; then row "installed version is $EXPECT" "passed ($VCOUNT lines)" 0 +else + row "installed version is $EXPECT" "**FAILED** (${VCOUNT} package lines, $(printf '%s' "$STALE" | grep -c .) not on the candidate)" 0 + fail_detail "installed version" "$WORK/versions.txt"; FAILED=1; finish +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" step "gen (first run)" "$GEN_CMD" || finish -git -C "$PROJECT" status --porcelain --untracked-files=all > "$WORK/changed.txt" +dirtymap | sort > "$WORK/after.txt" +comm -13 "$WORK/base.txt" "$WORK/after.txt" | sed 's/ [0-9a-f]\{16\}$//; s/ gone$//' > "$WORK/changed.txt" row "files changed by the first gen" "$(wc -l < "$WORK/changed.txt")" 0 -snapshot() { { git -C "$PROJECT" status --porcelain --untracked-files=all; git -C "$PROJECT" diff | sha256sum - git -C "$PROJECT" ls-files -co --exclude-standard -z | xargs -0 -r -I{} sha256sum "$PROJECT/{}" 2>/dev/null; } | sha256sum; } +snapshot() { dirtymap | sha256sum; } +INSTALLED='(^|/)(node_modules|\.venv|bin|obj|target)/' BEFORE="$(snapshot)"; MARK="$WORK/mark"; touch "$MARK"; sleep 1 step "gen (second run)" "$GEN_CMD" || finish -REWRITTEN="$(cd "$PROJECT" && git ls-files -co --exclude-standard | while IFS= read -r f; do [ "$f" -nt "$MARK" ] && echo "$f"; done)" +REWRITTEN="$(cd "$PROJECT" && git ls-files -co --exclude-standard | grep -vE "$INSTALLED" | while IFS= read -r f; do [ "$f" -nt "$MARK" ] && echo "$f"; done)" if [ "$(snapshot)" = "$BEFORE" ] && [ -z "$REWRITTEN" ]; then row "second gen writes zero files" "passed" 0 else row "second gen writes zero files" "**FAILED**" 0 diff --git a/tools/prerelease/test-estate-run.sh b/tools/prerelease/test-estate-run.sh index 244e605c72..7310dee80a 100755 --- a/tools/prerelease/test-estate-run.sh +++ b/tools/prerelease/test-estate-run.sh @@ -9,6 +9,8 @@ # E4 an installed version that is not the candidate fails the run # E5 a dirty project is refused (exit 2) before anything runs # E6 each port spells the candidate its own way (PyPI rcN, Maven major + 7) +# E8 a package left on another version, or rc.10 for rc.1, fails the read-back check +# E9 the estate is put back on its starting commit after the run # 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)" @@ -34,9 +36,9 @@ VERS='--versions-cmd' e1() { local d out; d="$(fresh "$IDEMPOTENT")"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' --build-cmd true)"; rc=$? [ $rc = 0 ] && grep -q 'second gen writes zero files | passed' <<<"$out" && grep -q '?? out.txt' <<<"$out"; } -e2() { local d out; d="$(fresh 'echo x >> out.txt')"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo cli@1.3.0-rc.1')"; rc=$? +e2() { local d out; d="$(fresh 'echo x >> out.txt')"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1')"; rc=$? [ $rc = 1 ] && grep -q 'second gen writes zero files | \*\*FAILED' <<<"$out"; } -e3() { local d out; d="$(fresh 'echo generated > out.txt')"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo cli@1.3.0-rc.1')"; rc=$? +e3() { local d out; d="$(fresh 'echo generated > out.txt')"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1')"; rc=$? [ $rc = 1 ] && grep -q 'second gen writes zero files | \*\*FAILED' <<<"$out"; } e4() { local d out; d="$(fresh "$IDEMPOTENT")"; out="$(run "$d" 1.3.0-rc.2 ts $VERS 'echo @metaobjectsdev/cli@^1.3.0-rc.1')"; rc=$? [ $rc = 1 ] && grep -q 'installed version is 1.3.0-rc.2 | \*\*FAILED' <<<"$out"; } @@ -45,15 +47,30 @@ e5() { local d out; d="$(fresh "$IDEMPOTENT")"; echo dirt > "$d/seed.txt"; out=" e6() { local d1 d2 o1 o2; d1="$(fresh "$IDEMPOTENT")"; d2="$(fresh "$IDEMPOTENT")" o1="$(run "$d1" 1.3.0-rc.4 python $VERS 'echo metaobjects@1.3.0rc4')"; o2="$(run "$d2" 1.3.0-rc.4 java $VERS 'echo com.metaobjects:x:8.3.0-rc.4')" grep -q 'installed version is 1.3.0rc4 | passed' <<<"$o1" && grep -q 'installed version is 8.3.0-rc.4 | passed' <<<"$o2"; } -e7() { local d out; d="$(fresh "$IDEMPOTENT")"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo cli@1.3.0-rc.1' --build-cmd 'echo boom >&2; exit 3')"; rc=$? +e7() { local d out; d="$(fresh "$IDEMPOTENT")"; out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' --build-cmd 'echo boom >&2; exit 3')"; rc=$? [ $rc = 1 ] && grep -q 'build | \*\*FAILED\*\* (exit 3)' <<<"$out" && grep -q 'boom' <<<"$out" && grep -q 'tests | skipped' <<<"$out"; } +e8() { local d out; d="$(fresh "$IDEMPOTENT")" + out="$(run "$d" 1.3.0-rc.1 ts $VERS 'printf "%s\n" @metaobjectsdev/cli@1.3.0-rc.1 @metaobjectsdev/metadata@1.2.3')"; [ $? = 1 ] || return 1 + out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.10')"; [ $? = 1 ] || return 1 + out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo nothing about the product')"; [ $? = 1 ]; } +e9() { local d before; d="$(fresh "$IDEMPOTENT")"; before="$(git -C "$d" rev-parse HEAD)" + # --no-link skips the restore (nothing was linked), so link through a stub that edits a tracked file. + mkdir -p "$d/tools"; cp "$HERE/estate-run.sh" "$d/tools/estate-run.sh" + printf '#!/usr/bin/env bash\nif [ "$1" = link ]; then echo pinned >> seed.txt; fi\nexit 0\n' > "$d/tools/prerelease-link.sh"; chmod +x "$d/tools/prerelease-link.sh" + git -C "$d" add -A && git -C "$d" commit -q -m tools; before="$(git -C "$d" rev-parse HEAD)" + bash "$d/tools/estate-run.sh" --project "$d" --port ts --version 1.3.0-rc.1 --install-cmd true --verify-cmd true \ + --gen-cmd 'sh gen.sh' $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' >/dev/null 2>&1; [ $? = 0 ] || return 1 + [ "$(git -C "$d" rev-parse HEAD)" = "$before" ] && [ -z "$(git -C "$d" status --porcelain --untracked-files=all)" ]; } + t "E1 a clean run passes and lists what the first gen changed" e1 t "E2 a gen that writes on every run fails the zero-write check" e2 t "E3 a gen that rewrites identical bytes fails the zero-write check" e3 t "E4 a read-back without the candidate fails the run" e4 t "E5 a dirty project is refused" e5 t "E6 PyPI and Maven spell the candidate their own way" e6 +t "E8 a stale package or rc.10 fails the read-back check" e8 +t "E9 the estate is put back on its starting commit" e9 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 19903b3e1de3d196f101b01228edc2dde73290e4 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 19:13:54 -0500 Subject: [PATCH 5/9] no-mistakes(review): record partial publishes, restore estate on failure --- scripts/prerelease.mjs | 15 +++++++++++---- tools/prerelease/estate-run.md | 12 ++++++++---- tools/prerelease/estate-run.sh | 22 +++++++++++++++------- tools/prerelease/test-estate-run.sh | 15 +++++++++++++++ 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/scripts/prerelease.mjs b/scripts/prerelease.mjs index 3d1d697e0f..1859164901 100644 --- a/scripts/prerelease.mjs +++ b/scripts/prerelease.mjs @@ -283,7 +283,9 @@ ok("version-bearing files clean"); const CANDIDATE_LOG = "tools/prerelease/candidates.md"; const builtFromDirtyTree = sh("git status --porcelain --untracked-files=all").split("\n") .some((l) => l.trim() && l.slice(3) !== CANDIDATE_LOG); -const published = []; // registries this run actually published to, in order +const published = []; // registries this run published to completely, in order +const started = []; // registries whose first publish call began; one that is not in `published` was cut short +const begin = (eco) => { if (!DRY) started.push(eco); }; // The tracked files those same pathspecs cover — restore() may only revert files whose // pre-run cleanliness this gate actually verified. const covered = new Set( @@ -312,12 +314,13 @@ const restore = () => { // entry is the only change the run leaves behind. let recorded = false; const recordCandidate = () => { - if (recorded || DRY || !published.length) return; recorded = true; - const stopped = ONLY.filter((p) => !published.includes(p)); + if (recorded || DRY || !started.length) return; recorded = true; + const cutShort = started.filter((p) => !published.includes(p)).map((p) => `${p} (cut short)`); + const stopped = ONLY.filter((p) => !started.includes(p)); try { appendCandidateLog(join(ROOT, CANDIDATE_LOG), candidateLogRow({ candidate: CANON, commit: sh("git rev-parse HEAD").trim(), dirty: builtFromDirtyTree, date: new Date(), - registries: stopped.length ? [...published, `stopped before ${stopped.join(", ")}`] : published, + registries: [...published, ...cutShort, ...(stopped.length ? [`stopped before ${stopped.join(", ")}`] : [])], })); console.log(`recorded ${CANON} in ${CANDIDATE_LOG} — commit that line`); } catch (e) { console.error(`could not record ${CANON} in ${CANDIDATE_LOG}: ${e.message}`); } @@ -372,6 +375,7 @@ if (wants("npm")) { if (seen !== NPM_REG) die(`bun would publish to ${seen}, not ${NPM_REG} — aborting`); ok(`bun publish target verified by dry-run: ${seen}`); + begin("npm"); if (!DRY) for (const pkg of ordered) { await run("bun publish --tag prerelease", { cwd: join(ROOT, pkg.dir), env: { ...process.env, HOME: home } }); @@ -389,6 +393,7 @@ if (wants("python")) { const dist = scratch("pydist"); await run(`cd server/python && uv build --out-dir ${dist}`); ok(`python built ${V.pypi}`); + begin("python"); if (!DRY) { await run(`cd server/python && uv publish --publish-url "${PYPI_URL}" --username "${OWNER}" --password "${TOKEN}" ${dist}/*`); ok(`python: metaobjects ${V.pypi} → ${expectedHost}`); @@ -404,6 +409,7 @@ if (wants("csharp")) { "MetaObjects.Codegen/MetaObjects.Codegen", "MetaObjects.Cli/MetaObjects.Cli"]; for (const p of projs) await run(`cd server/csharp && dotnet pack ${p}.csproj -c Release -o ${out} -p:Version=${V.nuget} --nologo -v q`); ok(`csharp packed ${V.nuget} (4 packages)`); + begin("csharp"); if (!DRY) { await run(`dotnet nuget push "${out}/*.nupkg" --source "${NUGET_SRC}" --api-key "${TOKEN}"`); ok(`csharp: 4 packages @ ${V.nuget} → ${expectedHost}`); @@ -437,6 +443,7 @@ if (wants("java")) { // `package` for a dry run, not `install`: a dry run must not write artifacts anywhere. const goal = DRY ? "package" : "deploy"; const repo = keptScratch("m2repo"); + begin("java"); await run(`cd server/java && mvn -B -s ${settings} -Dmaven.repo.local=${repo} ${goal} -DskipTests` + ` -DaltDeploymentRepository="mo-prerelease::${MAVEN_URL}"`, { stdio: "inherit" }); diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md index 7ea5d88884..b9d64f0591 100644 --- a/tools/prerelease/estate-run.md +++ b/tools/prerelease/estate-run.md @@ -23,9 +23,12 @@ the installed versions back** (a declared range is not proof of the version that 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), then runs the drift gate, your build, your tests and your database commands. -A command you do not pass is reported `skipped`, never `passed`. It unlinks on the way out, however -the run ended, and prints a report. `--no-link` is for an estate already linked another way; -`--keep-linked` leaves the link in place. `--help` lists the per-port defaults and the flags that +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 +output included, so the estate must start clean and `--report` must name a file outside it (a path +inside the estate is refused). `--keep-linked` skips the restore and leaves the link and the +regenerated tree in place. `--no-link` skips link and unlink but still restores the estate. `--help` lists the per-port defaults and the flags that override them. Rust has no estate path: a Rust consumer pins the commit (`docs/features/prerelease.md`, "Rust"). @@ -62,7 +65,8 @@ fixed before rc.2. Watch for: because the base layout changed under every edit. Move edits into hooks or owned generators first where that is possible, and report the count. - Owned generator copies from 1.2 must still load and generate. -- Commit the new hash manifest (`.metaobjects/.gen-state/.hashes/`). +- Commit the new hash manifest (`.metaobjects/.gen-state/.hashes/`). The end-of-run restore wipes it, + so run with `--keep-linked`, commit the manifest in the estate, then `prerelease-link.sh unlink`. - C#, Java and Kotlin estates run the base run only and must see **no** diff against rc.1. **rc.3, new output, C#, Java and Kotlin; TypeScript service code.** diff --git a/tools/prerelease/estate-run.sh b/tools/prerelease/estate-run.sh index e8698db3b7..25e24edc1e 100755 --- a/tools/prerelease/estate-run.sh +++ b/tools/prerelease/estate-run.sh @@ -20,8 +20,8 @@ # checked by content and by modification time. # 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: unlink, -# then `git reset --hard` to the commit it started on and `git clean -fd`. That is safe only +# 5. Puts the estate back as it found it (unless --keep-linked), however the run ended, also +# when link failed partway or --no-link was given: unlink, then `git reset --hard` to the commit it started on and `git clean -fd`. That is safe only # because step 1 required a clean tree, and it is why a dirty tree is refused. Ignored files # (node_modules, .venv, bin, obj) stay as the candidate installed them: reinstall afterwards. # @@ -102,17 +102,25 @@ case "$PORT" in : "${VERSIONS_CMD:=mvn -B dependency:list -DincludeGroupIds=com.metaobjects | grep 'com.metaobjects'}" ;; esac +if [ -n "$REPORT" ]; then + [ -d "$(dirname "$REPORT")" ] || die "--report directory does not exist: $(dirname "$REPORT")" + REPORT="$(cd "$(dirname "$REPORT")" && pwd)/$(basename "$REPORT")" + case "$REPORT" in "$PROJECT"/*) die "--report $REPORT is inside the estate, and the restore at the end deletes untracked files there: write it outside" ;; esac +fi + # ── bookkeeping ─────────────────────────────────────────────────────────────────────── WORK="$(mktemp -d "${DEV_SCRATCH:-${TMPDIR:-/tmp}}/estate-run.XXXXXX")" ROWS="$WORK/rows"; DETAIL="$WORK/detail"; : > "$ROWS"; : > "$DETAIL" -FAILED=0; LINKED=0; STARTED="$(date +%s)" +FAILED=0; STARTED="$(date +%s)" START_HEAD="$(git -C "$PROJECT" rev-parse HEAD)" cleanup() { local code=$? - if [ "$LINKED" = 1 ] && [ "$KEEP" = 0 ]; then - "$HERE/prerelease-link.sh" unlink --project "$PROJECT" >"$WORK/unlink.log" 2>&1 \ - || { echo "! unlink failed:" >&2; cat "$WORK/unlink.log" >&2; } + if [ "$KEEP" = 0 ]; then + if [ "$NOLINK" = 0 ]; then + "$HERE/prerelease-link.sh" unlink --project "$PROJECT" >"$WORK/unlink.log" 2>&1 \ + || { echo "! unlink failed:" >&2; cat "$WORK/unlink.log" >&2; } + fi # unlink repins to the public latest; the estate goes back to the commit it started on instead. git -C "$PROJECT" reset -q --hard "$START_HEAD" && git -C "$PROJECT" clean -qfd \ && echo "restored $PROJECT to ${START_HEAD:0:12}" >&2 || echo "! could not restore $PROJECT to $START_HEAD" >&2 @@ -159,7 +167,7 @@ finish() { # ── 1. link, install clean, read the versions back ──────────────────────────────────── if [ "$NOLINK" = 0 ]; then if ( cd "$PROJECT" && "$HERE/prerelease-link.sh" link --project "$PROJECT" --version "$VERSION" ) >"$WORK/link.log" 2>&1 - then LINKED=1; row "link $VERSION" "passed" 0 + then row "link $VERSION" "passed" 0 else row "link $VERSION" "**FAILED**" 0; fail_detail "link $VERSION" "$WORK/link.log"; FAILED=1; finish; fi else row "link $VERSION" "skipped (--no-link: the read-back below is the only proof)" 0 diff --git a/tools/prerelease/test-estate-run.sh b/tools/prerelease/test-estate-run.sh index 7310dee80a..ac71d3a68a 100755 --- a/tools/prerelease/test-estate-run.sh +++ b/tools/prerelease/test-estate-run.sh @@ -11,6 +11,8 @@ # E6 each port spells the candidate its own way (PyPI rcN, Maven major + 7) # E8 a package left on another version, or rc.10 for rc.1, fails the read-back check # E9 the estate is put back on its starting commit after the run +# E10 a --report path inside the estate is refused (exit 2) +# E11 a link that fails partway leaves the estate on its starting commit # 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)" @@ -63,6 +65,17 @@ e9() { local d before; d="$(fresh "$IDEMPOTENT")"; before="$(git -C "$d" rev-par --gen-cmd 'sh gen.sh' $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' >/dev/null 2>&1; [ $? = 0 ] || return 1 [ "$(git -C "$d" rev-parse HEAD)" = "$before" ] && [ -z "$(git -C "$d" status --porcelain --untracked-files=all)" ]; } +e10() { local d out; d="$(fresh "$IDEMPOTENT")" + out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' --report "$d/report.md")"; rc=$? + [ $rc = 2 ] && grep -q 'inside the estate' <<<"$out"; } +e11() { local d before; d="$(fresh "$IDEMPOTENT")" + mkdir -p "$d/tools"; cp "$HERE/estate-run.sh" "$d/tools/estate-run.sh" + printf '#!/usr/bin/env bash\nif [ "$1" = link ]; then echo pinned >> seed.txt; exit 1; fi\nexit 0\n' > "$d/tools/prerelease-link.sh"; chmod +x "$d/tools/prerelease-link.sh" + git -C "$d" add -A && git -C "$d" commit -q -m tools + bash "$d/tools/estate-run.sh" --project "$d" --port ts --version 1.3.0-rc.1 --install-cmd true --verify-cmd true \ + --gen-cmd 'sh gen.sh' >/dev/null 2>&1; [ $? = 1 ] || return 1 + [ -z "$(git -C "$d" status --porcelain --untracked-files=all)" ]; } + t "E1 a clean run passes and lists what the first gen changed" e1 t "E2 a gen that writes on every run fails the zero-write check" e2 t "E3 a gen that rewrites identical bytes fails the zero-write check" e3 @@ -71,6 +84,8 @@ t "E5 a dirty project is refused" e5 t "E6 PyPI and Maven spell the candidate their own way" e6 t "E8 a stale package or rc.10 fails the read-back check" e8 t "E9 the estate is put back on its starting commit" e9 +t "E10 a report path inside the estate is refused" e10 +t "E11 a link that fails partway still restores the estate" e11 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 2567c3a1f813614980847988f60785904f919289 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 19:16:35 -0500 Subject: [PATCH 6/9] no-mistakes(review): document gitignore blind spot, test restore flags --- tools/prerelease/estate-run.md | 2 +- tools/prerelease/estate-run.sh | 3 ++- tools/prerelease/test-estate-run.sh | 11 ++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md index b9d64f0591..46c698804c 100644 --- a/tools/prerelease/estate-run.md +++ b/tools/prerelease/estate-run.md @@ -22,7 +22,7 @@ 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), 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), 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 diff --git a/tools/prerelease/estate-run.sh b/tools/prerelease/estate-run.sh index 25e24edc1e..a552f7cd61 100755 --- a/tools/prerelease/estate-run.sh +++ b/tools/prerelease/estate-run.sh @@ -17,7 +17,8 @@ # 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, -# checked by content and by modification time. +# 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. # 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 diff --git a/tools/prerelease/test-estate-run.sh b/tools/prerelease/test-estate-run.sh index ac71d3a68a..02ba2f6265 100755 --- a/tools/prerelease/test-estate-run.sh +++ b/tools/prerelease/test-estate-run.sh @@ -11,6 +11,7 @@ # E6 each port spells the candidate its own way (PyPI rcN, Maven major + 7) # E8 a package left on another version, or rc.10 for rc.1, fails the read-back check # E9 the estate is put back on its starting commit after the run +# 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 # E7 a build command that fails is reported and the run exits 1; no command is "skipped", not "passed" @@ -57,7 +58,7 @@ e8() { local d out; d="$(fresh "$IDEMPOTENT")" out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.10')"; [ $? = 1 ] || return 1 out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo nothing about the product')"; [ $? = 1 ]; } e9() { local d before; d="$(fresh "$IDEMPOTENT")"; before="$(git -C "$d" rev-parse HEAD)" - # --no-link skips the restore (nothing was linked), so link through a stub that edits a tracked file. + # Link through a stub that edits a tracked file, so the restore has a pinned manifest to undo. mkdir -p "$d/tools"; cp "$HERE/estate-run.sh" "$d/tools/estate-run.sh" printf '#!/usr/bin/env bash\nif [ "$1" = link ]; then echo pinned >> seed.txt; fi\nexit 0\n' > "$d/tools/prerelease-link.sh"; chmod +x "$d/tools/prerelease-link.sh" git -C "$d" add -A && git -C "$d" commit -q -m tools; before="$(git -C "$d" rev-parse HEAD)" @@ -65,6 +66,12 @@ e9() { local d before; d="$(fresh "$IDEMPOTENT")"; before="$(git -C "$d" rev-par --gen-cmd 'sh gen.sh' $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' >/dev/null 2>&1; [ $? = 0 ] || return 1 [ "$(git -C "$d" rev-parse HEAD)" = "$before" ] && [ -z "$(git -C "$d" status --porcelain --untracked-files=all)" ]; } +e12() { local d; d="$(fresh "$IDEMPOTENT")" + run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' >/dev/null; [ $? = 0 ] || return 1 + [ ! -e "$d/out.txt" ] && [ -z "$(git -C "$d" status --porcelain --untracked-files=all)" ]; } +e13() { local d; d="$(fresh "$IDEMPOTENT")" + run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' --keep-linked >/dev/null; [ $? = 0 ] || return 1 + [ -e "$d/out.txt" ]; } e10() { local d out; d="$(fresh "$IDEMPOTENT")" out="$(run "$d" 1.3.0-rc.1 ts $VERS 'echo @metaobjectsdev/cli@1.3.0-rc.1' --report "$d/report.md")"; rc=$? [ $rc = 2 ] && grep -q 'inside the estate' <<<"$out"; } @@ -84,6 +91,8 @@ t "E5 a dirty project is refused" e5 t "E6 PyPI and Maven spell the candidate their own way" e6 t "E8 a stale package or rc.10 fails the read-back check" e8 t "E9 the estate is put back on its starting commit" e9 +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 t "E7 a failing build is reported; a missing command is skipped, not passed" e7 From ddac0562ad657b98b2fa9eabc65ee7c18c5b939c Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 21:19:44 -0500 Subject: [PATCH 7/9] no-mistakes(test): Test cut-short registry rows in candidate log --- scripts/prerelease-version.mjs | 11 +++++++++++ scripts/prerelease.mjs | 6 ++---- scripts/test-prerelease-version.mjs | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/scripts/prerelease-version.mjs b/scripts/prerelease-version.mjs index 48d1560634..d76412f106 100644 --- a/scripts/prerelease-version.mjs +++ b/scripts/prerelease-version.mjs @@ -122,6 +122,17 @@ export function candidateLogRow({ candidate, commit, dirty, date, registries }) 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)) { diff --git a/scripts/prerelease.mjs b/scripts/prerelease.mjs index 1859164901..a0c5c9b0ec 100644 --- a/scripts/prerelease.mjs +++ b/scripts/prerelease.mjs @@ -65,7 +65,7 @@ import { join } from "node:path"; import { mavenVersion } from "./maven-coordinate.mjs"; import { TIER_ORDER } from "./publish-set.mjs"; import { - appendCandidateLog, candidateLogRow, changelogVersions, collectPages, decideBase, installRestoreHandlers, releasedVersion, run as runStep, + appendCandidateLog, candidateLogRow, candidateRegistries, changelogVersions, collectPages, decideBase, installRestoreHandlers, releasedVersion, run as runStep, } from "./prerelease-version.mjs"; const argv = process.argv.slice(2); @@ -315,12 +315,10 @@ const restore = () => { let recorded = false; const recordCandidate = () => { if (recorded || DRY || !started.length) return; recorded = true; - const cutShort = started.filter((p) => !published.includes(p)).map((p) => `${p} (cut short)`); - const stopped = ONLY.filter((p) => !started.includes(p)); try { appendCandidateLog(join(ROOT, CANDIDATE_LOG), candidateLogRow({ candidate: CANON, commit: sh("git rev-parse HEAD").trim(), dirty: builtFromDirtyTree, date: new Date(), - registries: [...published, ...cutShort, ...(stopped.length ? [`stopped before ${stopped.join(", ")}`] : [])], + registries: candidateRegistries({ published, started, only: ONLY }), })); console.log(`recorded ${CANON} in ${CANDIDATE_LOG} — commit that line`); } catch (e) { console.error(`could not record ${CANON} in ${CANDIDATE_LOG}: ${e.message}`); } diff --git a/scripts/test-prerelease-version.mjs b/scripts/test-prerelease-version.mjs index 63df00c387..5a94e3d18d 100644 --- a/scripts/test-prerelease-version.mjs +++ b/scripts/test-prerelease-version.mjs @@ -19,7 +19,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { pathToFileURL } from "node:url"; import { - CANDIDATE_LOG_HEADER, appendCandidateLog, candidateLogRow, changelogVersions, collectPages, decideBase, + CANDIDATE_LOG_HEADER, appendCandidateLog, candidateLogRow, candidateRegistries, changelogVersions, collectPages, decideBase, latestReleaseTag, releasedVersion, run, } from "./prerelease-version.mjs"; @@ -193,5 +193,20 @@ await test("the candidate log is created with its header once and then only appe } }); +await test("a registry cut short mid-publish is named in the row, and later ones as stopped before", () => { + // npm began and never finished (package k of 14 failed): the number is burned there. + assert.deepEqual(candidateRegistries({ published: [], started: ["npm"], only: ["npm", "python", "csharp", "java"] }), + ["npm (cut short)", "stopped before python, csharp, java"]); + // npm done, python cut short. + assert.deepEqual(candidateRegistries({ published: ["npm"], started: ["npm", "python"], only: ["npm", "python", "java"] }), + ["npm", "python (cut short)", "stopped before java"]); + // A clean full run has no qualifier. + assert.deepEqual(candidateRegistries({ published: ["npm", "java"], started: ["npm", "java"], only: ["npm", "java"] }), ["npm", "java"]); + // A cut-short npm still yields a row a Rust consumer can pin. + const sha = "0123456789abcdef0123456789abcdef01234567"; + const registries = candidateRegistries({ published: [], started: ["npm"], only: ["npm"] }); + assert.match(candidateLogRow({ candidate: "1.3.0-rc.1", commit: sha, dirty: false, date: new Date(0), registries }), /npm \(cut short\) \|\n$/); +}); + if (fails) { console.error(`${fails} failure(s)`); process.exit(1); } console.log("all prerelease-version tests passed"); From 0e271d79d739fa4f23962b964a79d86b6669b9c9 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 22:28:47 -0500 Subject: [PATCH 8/9] no-mistakes(document): Fix Stale C# namespace, candidate log docs --- docs/CONFORMANCE.md | 9 +++++---- docs/features/prerelease.md | 9 ++++++--- tools/prerelease/estate-run.md | 6 ++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/docs/CONFORMANCE.md b/docs/CONFORMANCE.md index 5e5114c432..d2a8e51f8c 100644 --- a/docs/CONFORMANCE.md +++ b/docs/CONFORMANCE.md @@ -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` - (`/`; 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`. + (`/` 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`. diff --git a/docs/features/prerelease.md b/docs/features/prerelease.md index 5eedaf7ee8..3f46c3a581 100644 --- a/docs/features/prerelease.md +++ b/docs/features/prerelease.md @@ -154,11 +154,14 @@ The default scope is npm and Maven only, so a Python or a C# estate gets nothing `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 publishes appends one row to +**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. It names -ecosystems, never the registry host. The script writes the row after it has restored 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 +` (cut short)`, because its candidate number is taken there, and a registry the run +was asked for but never reached reads `stopped before `. 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. diff --git a/tools/prerelease/estate-run.md b/tools/prerelease/estate-run.md index 46c698804c..fafbe068c8 100644 --- a/tools/prerelease/estate-run.md +++ b/tools/prerelease/estate-run.md @@ -28,8 +28,10 @@ A command you do not pass is reported `skipped`, never `passed`. However the run `git reset --hard` and `git clean -fd`. That deletes every untracked file in the estate, the regenerated output included, so the estate must start clean and `--report` must name a file outside it (a path inside the estate is refused). `--keep-linked` skips the restore and leaves the link and the -regenerated tree in place. `--no-link` skips link and unlink but still restores the estate. `--help` lists the per-port defaults and the flags that -override them. Rust has no estate path: a Rust consumer pins the commit +regenerated tree in place. `--no-link` skips link and unlink but still restores the estate. `--help` +lists the flags. The default install, generation, verify and version-read commands for each port +are in the `case` block of `estate-run.sh`; `--install-cmd`, `--gen-cmd`, `--verify-cmd` and +`--versions-cmd` override them. Rust has no estate path: a Rust consumer pins the commit (`docs/features/prerelease.md`, "Rust"). ## Every candidate, every estate (the base run) From 1238a5645cdca6015b74566ccfbccc6e38b43473 Mon Sep 17 00:00:00 2001 From: Doug Mealing Date: Fri, 20 Nov 2026 22:29:36 -0500 Subject: [PATCH 9/9] no-mistakes(document): Fix candidate log header and estate help --- scripts/prerelease-version.mjs | 6 ++---- tools/prerelease/candidates.md | 6 ++---- tools/prerelease/estate-run.sh | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/prerelease-version.mjs b/scripts/prerelease-version.mjs index d76412f106..ca9813b2b1 100644 --- a/scripts/prerelease-version.mjs +++ b/scripts/prerelease-version.mjs @@ -104,10 +104,8 @@ export async function collectPages(fetchPage, limit = 50, maxPages = 1000) { /** 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, appended by the script and committed by\n" + - "the person who ran it. `Commit` is the `HEAD` the candidate was built from (`+dirty` when tracked\n" + - "files outside the version declarations were modified). `Registries` names ecosystems, never\n" + - "hosts. A Rust consumer pins that commit (docs/features/prerelease.md, \"Rust\").\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"; /** diff --git a/tools/prerelease/candidates.md b/tools/prerelease/candidates.md index 11c0bcaaca..8122cb27fb 100644 --- a/tools/prerelease/candidates.md +++ b/tools/prerelease/candidates.md @@ -1,9 +1,7 @@ # Staged candidates -One row per `bun run prerelease:publish` that published, appended by the script and committed by -the person who ran it. `Commit` is the `HEAD` the candidate was built from (`+dirty` when tracked -files outside the version declarations were modified). `Registries` names ecosystems, never -hosts. A Rust consumer pins that commit (docs/features/prerelease.md, "Rust"). +One row per `bun run prerelease:publish` that published or was cut short. The columns, and the rule +to commit each row, are in docs/features/prerelease.md, section 2a. | Candidate | Commit | Date (UTC) | Registries | |---|---|---|---| diff --git a/tools/prerelease/estate-run.sh b/tools/prerelease/estate-run.sh index a552f7cd61..7172893623 100755 --- a/tools/prerelease/estate-run.sh +++ b/tools/prerelease/estate-run.sh @@ -54,7 +54,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,30p' "$0"; exit 0 ;; + -h|--help) sed -n '2,33p' "$0"; exit 0 ;; *) die "unknown option: $1" ;; esac done