fix(release): reject release candidates with stale plugin manifests
The publication checkpoint validated package, lockfile, server and generated metadata versions but not the plugin manifests, so a candidate could be tagged with a manifest version or pinned server launch left at the previous release. Validate both fields in both manifests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
c224ce482a
commit
5806c94008
@@ -4,6 +4,16 @@ import { z } from "zod";
|
||||
const shaSchema = z.string().regex(/^[a-f0-9]{40}$/u);
|
||||
const versionSchema = z.object({ version: z.string() });
|
||||
const manifestSchema = z.object({ ".": z.string() });
|
||||
const PLUGIN_MANIFEST_PATHS = [
|
||||
".claude-plugin/plugin.json",
|
||||
".codex-plugin/plugin.json",
|
||||
];
|
||||
const PLUGIN_PACKAGE_SPECIFIER_PREFIX = "rea-agents@";
|
||||
const pluginManifestSchema = versionSchema.extend({
|
||||
mcpServers: z.object({
|
||||
rea: z.object({ args: z.array(z.string()) }),
|
||||
}),
|
||||
});
|
||||
const sectionsSchema = z.object({
|
||||
versioning: z.string().optional(),
|
||||
"changelog-sections": z.array(
|
||||
@@ -189,6 +199,21 @@ async function validateCandidate(git, sha, version, commits) {
|
||||
["server.json", server.version],
|
||||
["server.json rea-agents package", npmPackage.version],
|
||||
);
|
||||
// A stale manifest keeps the previous plugin cache key or launches the
|
||||
// previous server, so both are version authority like server.json.
|
||||
for (const path of PLUGIN_MANIFEST_PATHS) {
|
||||
const manifest = await readJson(git, sha, path, pluginManifestSchema);
|
||||
const specifier = manifest.mcpServers.rea.args[1];
|
||||
versions.push(
|
||||
[path, manifest.version],
|
||||
[
|
||||
`${path} rea-agents server launch`,
|
||||
specifier?.startsWith(PLUGIN_PACKAGE_SPECIFIER_PREFIX)
|
||||
? specifier.slice(PLUGIN_PACKAGE_SPECIFIER_PREFIX.length)
|
||||
: specifier,
|
||||
],
|
||||
);
|
||||
}
|
||||
// Catalogs are generated and checked from this candidate by the release job;
|
||||
// they are not version authority stored in the immutable source tree.
|
||||
const generated = await git([
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { cp, mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { afterAll, expect, it } from "vitest";
|
||||
import { z } from "zod";
|
||||
@@ -19,6 +19,18 @@ const verifier = fileURLToPath(
|
||||
new URL("../../../scripts/verify-release-checkpoint.mjs", import.meta.url),
|
||||
);
|
||||
|
||||
const pluginManifestPaths = [
|
||||
".claude-plugin/plugin.json",
|
||||
".codex-plugin/plugin.json",
|
||||
] as const;
|
||||
|
||||
const pluginManifest = (version: string, launchVersion = version) => ({
|
||||
version,
|
||||
mcpServers: {
|
||||
rea: { args: ["-y", `rea-agents@${launchVersion}`, "mcp"] },
|
||||
},
|
||||
});
|
||||
|
||||
async function metadata(
|
||||
directory: string,
|
||||
version: string,
|
||||
@@ -27,7 +39,12 @@ async function metadata(
|
||||
) {
|
||||
await mkdir(join(directory, "docs"), { recursive: true });
|
||||
await mkdir(join(directory, "src"), { recursive: true });
|
||||
for (const path of pluginManifestPaths)
|
||||
await mkdir(join(directory, dirname(path)), { recursive: true });
|
||||
const files = {
|
||||
...Object.fromEntries(
|
||||
pluginManifestPaths.map((path) => [path, pluginManifest(version)]),
|
||||
),
|
||||
"package.json": { name: "rea-agents", version },
|
||||
"package-lock.json": { version, packages: { "": { version } } },
|
||||
".release-please-manifest.json": { ".": version },
|
||||
@@ -565,6 +582,29 @@ it.each([
|
||||
});
|
||||
});
|
||||
|
||||
it.each(
|
||||
pluginManifestPaths.flatMap((path) => [
|
||||
{ path, stale: "version", manifest: pluginManifest("5.1.0", "6.0.0") },
|
||||
{
|
||||
path,
|
||||
stale: "server launch",
|
||||
manifest: pluginManifest("6.0.0", "5.1.0"),
|
||||
},
|
||||
]),
|
||||
)("rejects a stale plugin $stale in $path", async ({ path, manifest }) => {
|
||||
const f = await fixture();
|
||||
await candidate(f, "6.0.0");
|
||||
await writeFile(join(f.directory, path), JSON.stringify(manifest));
|
||||
await git(f.directory, ["add", "."]);
|
||||
await git(f.directory, ["commit", "-m", "chore: stale plugin manifest"]);
|
||||
await expect(verify(f)).rejects.toMatchObject({
|
||||
code: 1,
|
||||
stderr: expect.stringContaining(
|
||||
"declares 5.1.0; release branch requires 6.0.0",
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
it("checks a publish merge using its pre-release first parent baseline", async () => {
|
||||
const f = await fixture();
|
||||
const sourceSha = await candidate(f, "6.0.0");
|
||||
|
||||
Reference in New Issue
Block a user