From 36fcbc5a49364c285f91cb09c65ae24993e7337d Mon Sep 17 00:00:00 2001 From: "open-design-crew[bot]" <299007234+open-design-crew[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:23:42 +0800 Subject: [PATCH] Freeze release notes with test and stable candidates (#464) Prepare read-only change drafts during candidate builds and seal their identity and hashes. Reuse frozen notes during publication while preserving legacy candidates and retries. Disclose truncated comparison history, deduplicate repeated pages, and keep acceptance status explicit. This merge does not dispatch a candidate build or publish a package. --- .github/scripts/motion-release-notes.mjs | 137 +++++++++++++++++----- .github/scripts/motion-release.mjs | 22 +++- .github/workflows/motion-candidate.yml | 14 ++- .github/workflows/motion-publish-test.yml | 1 + docs/product/architecture.md | 4 +- docs/release-workflows.md | 12 +- tests/release-fixture.mjs | 3 +- tests/release-notes.test.mjs | 126 +++++++++++++++++++- tests/release-workflows.test.mjs | 5 + 9 files changed, 274 insertions(+), 50 deletions(-) diff --git a/.github/scripts/motion-release-notes.mjs b/.github/scripts/motion-release-notes.mjs index 1a87618bb..9b76d8917 100644 --- a/.github/scripts/motion-release-notes.mjs +++ b/.github/scripts/motion-release-notes.mjs @@ -2,9 +2,93 @@ import assert from 'node:assert/strict'; import { readFile, writeFile } from 'node:fs/promises'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { releaseInputs, verifyDownloaded, repository } from './motion-release.mjs'; +import { releaseInputs, verifyDownloaded, repository, releaseChannel, candidateNoteIdentity } from './motion-release.mjs'; +import { sha256 } from '../../scripts/runtime-assets.mjs'; import { compareReleaseVersions } from '../../scripts/release-version.mjs'; +function githubApi(env, fetcher) { + return async (route, method = 'GET', data, allowMissing = false) => { + const response = await fetcher(`https://api.github.com/repos/${repository}${route}`, { + method, redirect: 'error', signal: AbortSignal.timeout(30_000), + headers: { Accept: 'application/vnd.github+json', ...(env.GH_TOKEN ? { Authorization: `Bearer ${env.GH_TOKEN}` } : {}), 'X-GitHub-Api-Version': '2022-11-28', 'Content-Type': 'application/json' }, + ...(data === undefined ? {} : { body: JSON.stringify(data) }), + }); + if (allowMissing && response.status === 404) return null; + assert(response.ok, `GitHub release ${method} ${route} failed: HTTP ${response.status}`); + return response.json(); + }; +} + +async function listReleases(api) { + const releases = []; + for (let page = 1; ; page++) { + assert(page <= 100, 'GitHub release history exceeds the bounded lookup'); + const batch = await api(`/releases?per_page=100&page=${page}`); + assert(Array.isArray(batch), 'Invalid GitHub release list'); + releases.push(...batch); + if (batch.length < 100) break; + } + return releases; +} + +function previousRelease(releases, version, prerelease) { + return releases.filter(r => !r.draft && r.prerelease === prerelease && /^v\d+\.\d+\.\d+(?:-test\.[1-9]\d*(?:\.[1-9]\d*)*)?$/.test(r.tag_name)) + .filter(r => compareReleaseVersions(r.tag_name.slice(1), version) < 0) + .sort((a, b) => compareReleaseVersions(b.tag_name.slice(1), a.tag_name.slice(1)))[0]; +} + +export async function prepareCandidateNotes(directory, { env = process.env, fetcher = fetch } = {}) { + const manifest = JSON.parse(await readFile(path.join(directory, 'release-npm.json'), 'utf8')); + const channel = releaseChannel(manifest.version), source = manifest.commit; + assert.equal(manifest.version, env.MOTION_VERSION); assert.equal(source, env.MOTION_SOURCE_SHA); + assert.match(source, /^[a-f0-9]{40}$/); + assert.equal(manifest.installer.url, `./openmotion-app-${manifest.version}.tgz`); + assert.equal(await sha256(path.join(directory, manifest.installer.url)), manifest.installer.sha256); + const api = githubApi(env, fetcher), previous = previousRelease(await listReleases(api), manifest.version, channel === 'test'); + let base, commits, link, warning = ''; + if (previous) { + let object = (await api(`/git/ref/tags/${previous.tag_name}`)).object; + for (let depth = 0; object.type === 'tag' && depth < 5; depth++) object = (await api(`/git/tags/${object.sha}`)).object; + assert.equal(object.type, 'commit'); assert.match(object.sha, /^[a-f0-9]{40}$/); base = object.sha; + link = `https://github.com/${repository}/compare/${base}...${source}`; + commits = []; + const seen = new Set(); + let total = 0, truncated = false; + for (let page = 1; page <= 10; page++) { + const compared = await api(`/compare/${base}...${source}?per_page=100&page=${page}`); + assert(['ahead', 'identical'].includes(compared.status), 'Published baseline must be an ancestor of the selected source'); + assert(Array.isArray(compared.commits) && Number.isSafeInteger(compared.total_commits) && compared.total_commits >= 0, 'Invalid comparison metadata'); + total = compared.total_commits; + const fresh = compared.commits.filter(commit => { + if (seen.has(commit.sha)) return false; + seen.add(commit.sha); return true; + }); + commits.push(...fresh); + if (commits.length >= total) break; + // A short or repeated page is incomplete evidence, not a candidate-build failure. + truncated = compared.commits.length < 100 || fresh.length !== compared.commits.length || page === 10; + if (truncated) break; + } + if (truncated) warning = `Only the first ${commits.length.toLocaleString('en-US')} of ${total.toLocaleString('en-US')} compared commits are shown; inspect the full comparison.`; + } else { + // First-channel history is bounded; use the full-history link for older changes. + commits = await api(`/commits?sha=${source}&per_page=100`); + link = `https://github.com/${repository}/commits/${source}`; + warning = 'No earlier GitHub Release exists in this channel. Showing up to 100 recent commits; this is not a complete release delta.'; + } + assert(Array.isArray(commits)); + const escape = text => text.replace(/[\\`*_[\]<>]/g, '\\$&'); + const rows = commits.map(commit => { + assert.match(commit.sha, /^[a-f0-9]{40}$/); assert.equal(typeof commit.commit?.message, 'string'); + const title = escape(commit.commit.message.split(/\r?\n/, 1)[0]); + return `- ${title} ([${commit.sha.slice(0, 7)}](https://github.com/${repository}/commit/${commit.sha}))`; + }); + const body = `# OpenMotion ${manifest.version}\n\nChannel: ${channel}; templates: ${manifest.templateEnvironment}.\nSource: [${source}](https://github.com/${repository}/commit/${source}).\nBaseline: ${previous ? `${previous.tag_name} (${base})` : 'not available'}.\n\n## Changes\n\n${warning ? warning + '\n\n' : ''}${rows.join('\n') || (previous && !warning ? 'No source commits since the baseline.' : 'No complete commit list is available; inspect the full history/comparison.')}\n\n[Full source comparison/history](${link})\n\n## Acceptance focus\n\nNOT PROVIDED — maintainers record the required checks and actual results in their private acceptance.md copy. No acceptance is implied.\n\n## Known issues\n\nNOT PROVIDED — review before distribution; this does not mean there are no known issues. Maintainers may edit the published GitHub Release prose.\n\n${candidateNoteIdentity({ version: manifest.version, sourceCommit: source, tgzSHA256: manifest.installer.sha256 })}\n`; + assert(Buffer.byteLength(body) <= 1024 * 1024, 'Candidate notes exceed 1 MiB'); + await writeFile(path.join(directory, 'release-notes.md'), body, { flag: 'wx' }); + return body; +} + export async function publishReleaseNotes(directory, { env = process.env, fetcher = fetch } = {}) { const inputs = releaseInputs(env); assert.notEqual(inputs.action, 'archive-only', 'Snapshot recovery must not create GitHub releases'); @@ -15,16 +99,7 @@ export async function publishReleaseNotes(directory, { env = process.env, fetche assert(env.GH_TOKEN, 'Missing scoped GitHub release token'); const origin = new URL(env.MOTION_INSTALL_PUBLIC_ORIGIN); assert(origin.protocol === 'https:' && origin.pathname === '/' && !origin.username && !origin.password && !origin.search && !origin.hash); - const api = async (route, method = 'GET', data, allowMissing = false) => { - const response = await fetcher(`https://api.github.com/repos/${repository}${route}`, { - method, redirect: 'error', signal: AbortSignal.timeout(30_000), - headers: { Accept: 'application/vnd.github+json', Authorization: `Bearer ${env.GH_TOKEN}`, 'X-GitHub-Api-Version': '2022-11-28', 'Content-Type': 'application/json' }, - ...(data === undefined ? {} : { body: JSON.stringify(data) }), - }); - if (allowMissing && response.status === 404) return null; - assert(response.ok, `GitHub release ${method} ${route} failed: HTTP ${response.status}`); - return response.json(); - }; + const api = githubApi(env, fetcher); const tag = 'v' + candidate.version, prerelease = inputs.channel === 'test'; const marker = ``; // Refuse an existing tag pointing at other bytes; never force or move a tag. @@ -34,27 +109,23 @@ export async function publishReleaseNotes(directory, { env = process.env, fetche for (let depth = 0; object.type === 'tag' && depth < 5; depth++) object = (await api(`/git/tags/${object.sha}`)).object; assert.equal(object.type, 'commit'); assert.equal(object.sha, candidate.sourceCommit, 'Release tag already identifies another source'); } - // Listing with write access includes drafts; the by-tag endpoint documents published releases only. - const releases = []; - for (let page = 1; ; page++) { - assert(page <= 100, 'GitHub release history exceeds the bounded lookup'); - const batch = await api(`/releases?per_page=100&page=${page}`); - assert(Array.isArray(batch), 'Invalid GitHub release list'); - releases.push(...batch); - if (batch.length < 100) break; - } + const releases = await listReleases(api); let release = releases.find(r => r.tag_name === tag); if (!release) { - const previous = releases.filter(r => !r.draft && r.prerelease === prerelease && /^v\d+\.\d+\.\d+(?:-test\.[1-9]\d*(?:\.[1-9]\d*)*)?$/.test(r.tag_name)) - .filter(r => compareReleaseVersions(r.tag_name.slice(1), candidate.version) < 0) - .sort((a, b) => compareReleaseVersions(b.tag_name.slice(1), a.tag_name.slice(1)))[0]; - const generated = await api('/releases/generate-notes', 'POST', { - tag_name: tag, target_commitish: candidate.sourceCommit, ...(previous ? { previous_tag_name: previous.tag_name } : {}), - }); - assert.equal(typeof generated.body, 'string', 'Missing generated release notes'); + let changes; + if (candidate.schemaVersion >= 3) changes = await readFile(path.join(directory, 'release-notes.md'), 'utf8'); + else { + // Older sealed candidates have no draft; retain their existing publication behavior. + const previous = previousRelease(releases, candidate.version, prerelease); + const generated = await api('/releases/generate-notes', 'POST', { + tag_name: tag, target_commitish: candidate.sourceCommit, ...(previous ? { previous_tag_name: previous.tag_name } : {}), + }); + assert.equal(typeof generated.body, 'string', 'Missing generated release notes'); + changes = `${previous ? '' : 'This is the first GitHub Release in this channel; the generated changes may include earlier repository history.\n\n'}${generated.body}`; + } const prefix = prerelease ? 'open-motion/dev' : 'open-motion'; - const body = `## Installation\n\n- [Exact ${candidate.version} installation](${origin.origin}/${prefix}/${candidate.version}/install.md)\n- [Current ${inputs.channel} installation](${origin.origin}/${prefix}/install.md)\n- npm: \`${candidate.packageName}@${candidate.version}\`; templates: **${prerelease ? 'DEV' : 'prod'}**.\n\n## Release identity\n\n- Source: [\`${candidate.sourceCommit}\`](https://github.com/${repository}/commit/${candidate.sourceCommit})\n- npm tgz SHA256: \`${candidate.tgzSHA256}\`\n- [Publication and verification](https://github.com/${repository}/actions/runs/${env.GITHUB_RUN_ID})\n\n${prerelease ? 'Test installation checks run separately and may still be pending.' : 'Both exact-version macOS ARM64 and Windows x64 installation checks passed.'} Live templates, real Agent creation and human audiovisual acceptance are separate checks.\n\n${previous ? '' : 'This is the first GitHub Release in this channel; the generated changes may include earlier repository history.\n\n'}${generated.body}\n\n${marker}\n`; - await writeFile(path.join(directory, 'release-notes.md'), body); + const body = `## Installation\n\n- [Exact ${candidate.version} installation](${origin.origin}/${prefix}/${candidate.version}/install.md)\n- [Current ${inputs.channel} installation](${origin.origin}/${prefix}/install.md)\n- npm: \`${candidate.packageName}@${candidate.version}\`; templates: **${prerelease ? 'DEV' : 'prod'}**.\n\n## Release identity\n\n- Source: [\`${candidate.sourceCommit}\`](https://github.com/${repository}/commit/${candidate.sourceCommit})\n- npm tgz SHA256: \`${candidate.tgzSHA256}\`\n- [Publication and verification](https://github.com/${repository}/actions/runs/${env.GITHUB_RUN_ID})\n\n${prerelease ? 'Test installation checks run separately and may still be pending.' : 'Both exact-version macOS ARM64 and Windows x64 installation checks passed.'} Live templates, real Agent creation and human audiovisual acceptance are separate checks.\n\n${changes}\n\n${marker}\n`; + await writeFile(path.join(directory, 'github-release-notes.md'), body); release = await api('/releases', 'POST', { tag_name: tag, target_commitish: candidate.sourceCommit, name: `OpenMotion ${candidate.version}`, body, draft: true, prerelease }); } assert.equal(release.tag_name, tag); assert.equal(release.prerelease, prerelease); @@ -65,7 +136,7 @@ export async function publishReleaseNotes(directory, { env = process.env, fetche make_latest: !prerelease && attempt.stage !== 'archived-superseded' ? 'true' : 'false' }); } assert.equal(release.draft, false); assert.equal(release.tag_name, tag); assert.equal(release.prerelease, prerelease); - await writeFile(path.join(directory, 'release-notes.md'), release.body); + await writeFile(path.join(directory, 'github-release-notes.md'), release.body); const record = { version: candidate.version, sourceCommit: candidate.sourceCommit, tgzSHA256: candidate.tgzSHA256, publicationRun: env.GITHUB_RUN_ID, releaseId: release.id, url: release.html_url, tag, prerelease, status: 'published' }; await writeFile(path.join(directory, 'github-release.json'), JSON.stringify(record, null, 2) + '\n'); @@ -73,6 +144,8 @@ export async function publishReleaseNotes(directory, { env = process.env, fetche } if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { - assert.equal(process.argv.length, 3, 'Usage: motion-release-notes.mjs '); - console.log(JSON.stringify(await publishReleaseNotes(path.resolve(process.argv[2])), null, 2)); + const prepare = process.argv[2] === 'prepare'; + assert.equal(process.argv.length, prepare ? 4 : 3, 'Usage: motion-release-notes.mjs [prepare] '); + const result = prepare ? await prepareCandidateNotes(path.resolve(process.argv[3])) : await publishReleaseNotes(path.resolve(process.argv[2])); + if (!prepare) console.log(JSON.stringify(result, null, 2)); } diff --git a/.github/scripts/motion-release.mjs b/.github/scripts/motion-release.mjs index 9c500af54..b8775390c 100644 --- a/.github/scripts/motion-release.mjs +++ b/.github/scripts/motion-release.mjs @@ -92,6 +92,10 @@ export async function validateSource(control, commit, version, run = runFile, ch await run('git', ['merge-base', '--is-ancestor', commit, 'refs/remotes/origin/main'], { cwd: control }); } +export function candidateNoteIdentity(candidate) { + return ``; +} + export async function sealCandidate(build, output, source, env = process.env) { const manifest = await json(path.join(build, 'release-npm.json')); assert.equal(manifest.commit, (await runFile('git', ['rev-parse', 'HEAD'], { cwd: source })).trim()); @@ -105,7 +109,7 @@ export async function sealCandidate(build, output, source, env = process.env) { const filename = manifest.installer.url.replace(/^\.\//, ''); assert.equal(filename, `openmotion-app-${manifest.version}.tgz`); await mkdir(output, { recursive: true }); - for (const name of [filename, 'release-npm.json', 'source-scan.json', 'package-scan.json']) await cp(path.join(build, name), path.join(output, name)); + for (const name of [filename, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'release-notes.md']) await cp(path.join(build, name), path.join(output, name)); const guide = await generateInstallGuide(path.join(output, filename), output); assert.equal(guide.packageName, '@openmotion/app'); assert.equal(guide.commit, env.MOTION_SOURCE_SHA); for (const name of ['source-scan.json', 'package-scan.json']) assert.equal((await json(path.join(output, name))).status, 'passed'); @@ -123,9 +127,11 @@ export async function sealCandidate(build, output, source, env = process.env) { const instructions = installTemplate.replace(/\{\{([A-Z0-9_]+)\}\}/g, (_, key) => { assert(Object.hasOwn(values, key)); return values[key]; }); assert(!instructions.includes('{{'), 'Unresolved candidate instructions'); await writeFile(path.join(output, 'candidate-install.md'), instructions); - const names = [filename, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'install.md', 'install-record.json', 'acceptance.md', 'candidate-install.md']; + const notes = await readFile(path.join(output, 'release-notes.md'), 'utf8'); + assert(Buffer.byteLength(notes) <= 1024 * 1024 && notes.includes(candidateNoteIdentity({ ...identity, version: manifest.version })), 'Candidate notes identity mismatch'); + const names = [filename, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'install.md', 'install-record.json', 'acceptance.md', 'candidate-install.md', 'release-notes.md']; const files = Object.fromEntries(await Promise.all(names.map(async name => [name, await sha256(path.join(output, name))]))); - const candidate = { schemaVersion: 2, kind: 'motion-candidate', packageName: guide.packageName, version: guide.version, + const candidate = { schemaVersion: 3, kind: 'motion-candidate', packageName: guide.packageName, version: guide.version, sourceCommit: guide.commit, tgz: filename, tgzSHA256: files[filename], integrity: integrity(await readFile(path.join(output, filename))), files, workflow: { repository, path: candidateWorkflow, ref: workflowRef, sha: env.GITHUB_SHA, runId: Number(env.GITHUB_RUN_ID), attempt: Number(env.GITHUB_RUN_ATTEMPT) }, @@ -184,7 +190,7 @@ async function verifyAuthorization(directory, inputs, env = process.env) { export async function verifyCandidate(directory, expectedSHA256, run) { const candidate = await json(path.join(directory, 'candidate.json')); - assert.equal(candidate.schemaVersion, 2); assert.equal(candidate.kind, 'motion-candidate'); assert.equal(candidate.packageName, '@openmotion/app'); + assert([2, 3].includes(candidate.schemaVersion), 'Unsupported candidate schema'); assert.equal(candidate.kind, 'motion-candidate'); assert.equal(candidate.packageName, '@openmotion/app'); checkReleaseVersion(candidate.version); assert.equal(candidate.tgz, `openmotion-app-${candidate.version}.tgz`); assert.equal(candidate.tgzSHA256, expectedSHA256); assert.match(expectedSHA256, hashPattern); assert.match(candidate.sourceCommit, /^[a-f0-9]{40}$/); @@ -196,8 +202,13 @@ export async function verifyCandidate(directory, expectedSHA256, run) { assert([repository, 'nexu-io/html-anything'].includes(receiptRepository), 'Untrusted candidate repository'); assert.deepEqual(candidate.workflow, { repository: receiptRepository, path: candidateWorkflow, ref, sha: run.head_sha, runId: run.id, attempt: run.run_attempt }); const names = [candidate.tgz, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'install.md', 'install-record.json', 'acceptance.md', 'candidate-install.md']; + if (candidate.schemaVersion >= 3) names.push('release-notes.md'); assert.deepEqual(Object.keys(candidate.files).sort(), names.sort()); for (const name of names) assert.equal(await sha256(path.join(directory, name)), candidate.files[name], 'Candidate file changed: ' + name); + if (candidate.schemaVersion >= 3) { + const notes = await readFile(path.join(directory, 'release-notes.md'), 'utf8'); + assert(Buffer.byteLength(notes) <= 1024 * 1024 && notes.includes(candidateNoteIdentity(candidate)), 'Candidate notes identity mismatch'); + } assert.equal(await sha256(path.join(directory, candidate.tgz)), expectedSHA256); assert.equal(integrity(await readFile(path.join(directory, candidate.tgz))), candidate.integrity); const guide = await json(path.join(directory, 'install-record.json')); @@ -244,7 +255,7 @@ export async function downloadCandidate(version, directory, expectedSHA256, fetc try { const archive = path.join(work, 'candidate.zip'); await writeFile(archive, bytes); const entries = (await runFile('unzip', ['-Z1', archive])).trim().split('\n'); - assert(entries.length === 9 && new Set(entries).size === 9, 'Unexpected candidate artifact files'); + assert([9, 10].includes(entries.length) && new Set(entries).size === entries.length, 'Unexpected candidate artifact files'); assert(entries.every(name => /^[a-zA-Z0-9._-]+$/.test(name) && name.length < 160), 'Unsafe candidate artifact entry'); await mkdir(directory, { recursive: true }); for (const name of entries) { @@ -252,6 +263,7 @@ export async function downloadCandidate(version, directory, expectedSHA256, fetc await writeFile(path.join(directory, name), stdout); } const candidate = await verifyCandidate(directory, expectedSHA256 || (await json(path.join(directory, 'candidate.json'))).tgzSHA256, run); + assert.deepEqual(entries.sort(), ['candidate.json', ...Object.keys(candidate.files)].sort(), 'Unexpected candidate artifact files'); assert.equal(candidate.version, version, 'Artifact version differs from the accepted version'); await writeJSON(path.join(directory, 'provenance.json'), { runId: run.id, attempt: run.run_attempt, head_branch: run.head_branch, head_sha: run.head_sha, artifactId: artifact.id, digest: artifact.digest }); return candidate; diff --git a/.github/workflows/motion-candidate.yml b/.github/workflows/motion-candidate.yml index 8dcb8b434..71c26b5cd 100644 --- a/.github/workflows/motion-candidate.yml +++ b/.github/workflows/motion-candidate.yml @@ -133,7 +133,17 @@ jobs: node source/scripts/package-npm.mjs "$RUNNER_TEMP/build" "$MOTION_VERSION" --template-env="$MOTION_TEMPLATE_ENVIRONMENT" cp "$RUNNER_TEMP/source-scan.json" "$RUNNER_TEMP/build/source-scan.json" node control/.github/scripts/motion-scan.mjs package "$RUNNER_TEMP/build/openmotion-app-$MOTION_VERSION.tgz" "$RUNNER_TEMP/build/package-scan.json" "$RUNNER_TEMP/scanner/gitleaks" - node control/.github/scripts/motion-release.mjs seal "$RUNNER_TEMP/build" "$RUNNER_TEMP/candidate" source + - name: Prepare read-only release notes for this exact candidate + env: + GH_TOKEN: ${{ github.token }} + MOTION_SOURCE_SHA: ${{ steps.source.outputs.source_sha }} + MOTION_VERSION: ${{ steps.source.outputs.version }} + run: node control/.github/scripts/motion-release-notes.mjs prepare "$RUNNER_TEMP/build" + - name: Seal the package and notes together + env: + MOTION_SOURCE_SHA: ${{ steps.source.outputs.source_sha }} + MOTION_VERSION: ${{ steps.source.outputs.version }} + run: node control/.github/scripts/motion-release.mjs seal "$RUNNER_TEMP/build" "$RUNNER_TEMP/candidate" source - name: Retain the immutable candidate id: artifact uses: actions/upload-artifact@v7.0.2 @@ -147,6 +157,8 @@ jobs: node --input-type=module <<'JS' import { readFileSync, appendFileSync } from 'node:fs'; const c = JSON.parse(readFileSync(process.env.RUNNER_TEMP + '/candidate/candidate.json')); + const notes = readFileSync(process.env.RUNNER_TEMP + '/candidate/release-notes.md', 'utf8'); const run = `https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; appendFileSync(process.env.GITHUB_STEP_SUMMARY, `## Candidate ready for acceptance\n\nVersion: ${c.version}\n\nSource: ${c.sourceCommit}\n\nTGZ SHA256: ${c.tgzSHA256}\n\n[Download motion-candidate-${c.version}](${run}#artifacts), extract it and give the folder to your Agent with this instruction:\n\n> Follow candidate-install.md in this folder to install this exact local candidate into an isolated test profile, application home, project data and Skills directory. Verify host loading without waiting for background video-component preparation. Run prepare only when explicitly asked to wait or before requested media/capture/export acceptance checks. Record actual results in a private copy of acceptance.md; mark unrun checks NOT RUN. Do not publish.\n\nUse candidate-install.md before publication, not the sibling registry install.md. To publish, manually open Motion npm publication, select the same channel and enter ${c.version}; no acceptance checkbox is required. Nothing was published by this build.\n`); + appendFileSync(process.env.GITHUB_STEP_SUMMARY, `\n\n---\n\n## Candidate release notes (unpublished)\n\n${notes}`); JS diff --git a/.github/workflows/motion-publish-test.yml b/.github/workflows/motion-publish-test.yml index 29520ce03..a13c86e54 100644 --- a/.github/workflows/motion-publish-test.yml +++ b/.github/workflows/motion-publish-test.yml @@ -526,6 +526,7 @@ jobs: name: github-release-${{ inputs.version }}-${{ github.run_id }}-${{ github.run_attempt }} path: | ${{ runner.temp }}/candidate/release-notes.md + ${{ runner.temp }}/candidate/github-release-notes.md ${{ runner.temp }}/candidate/github-release.json retention-days: 30 if-no-files-found: warn diff --git a/docs/product/architecture.md b/docs/product/architecture.md index d63e6bd6c..3b5d3f9aa 100644 --- a/docs/product/architecture.md +++ b/docs/product/architecture.md @@ -386,13 +386,13 @@ The MCP handbook media example initiates provider inspection before gathering mi ## 演进约束 -Source automatic installation is the default repository route. With no arguments, the public bootstrap clones the selected source and registers its plugin after one dependency install and Studio build. Published npm application installation is an explicit alternative through docs/install.md, which selects a published stable/prod or isolated test/DEV guide. Codex can also use an explicit --package with an exact version or hash-verified candidate; other hosts use their published setup commands. Source and npm setup share onboarding while preserving the selected installation/workspace. Existing packages retain their own embedded behavior. Candidate-build, npm-publication and snapshot-recovery entries are manual; merging source changes does not publish or update hosted guides. Existing user data, credentials and unrelated host settings are preserved. PR CI scans tracked source without publication credentials for every change. Only explicitly allowlisted presentation documents with unchanged installation sections and code blocks use link/media-reference checks instead of Studio, rendering and package validation; Skills, installation guides, examples, assets and unknown paths retain the full gate, including both npm archive scans. Rendering package downloads are reused by runner image version, with a weekly fallback when image-version metadata is unavailable. Code and configuration changes also receive maintainability analysis. Separate manual candidate-build and npm-publication entries implement build → local testing → manual publish. New candidate builds, npm publication and snapshot recovery run only from main in nexu-io/openmotion. Frozen receipts from the former repository name and feature/motion producer runs remain readable with their original run/hash identity. The build freezes the selected dispatch commit (or an explicitly integrated source SHA). Test builds use DEV; an empty test version uses the next source patch plus short test.N from the workflow counter and historical offset, without rewriting the source baseline. Reruns add an attempt suffix. Stable builds require an explicit new version and prod configuration. Each immutable candidate includes candidate-install.md and an identity-filled acceptance checklist. Publication resolves a unique unexpired artifact from a successful registered build, checks official ZIP/file hashes and source integration, then records the actual operator. No acceptance checkbox or independent approval environment is enabled; the receipt is not proof of private tests or review. +Source automatic installation is the default repository route. With no arguments, the public bootstrap clones the selected source and registers its plugin after one dependency install and Studio build. Published npm application installation is an explicit alternative through docs/install.md, which selects a published stable/prod or isolated test/DEV guide. Codex can also use an explicit --package with an exact version or hash-verified candidate; other hosts use their published setup commands. Source and npm setup share onboarding while preserving the selected installation/workspace. Existing packages retain their own embedded behavior. Candidate-build, npm-publication and snapshot-recovery entries are manual; merging source changes does not publish or update hosted guides. Existing user data, credentials and unrelated host settings are preserved. PR CI scans tracked source without publication credentials for every change. Only explicitly allowlisted presentation documents with unchanged installation sections and code blocks use link/media-reference checks instead of Studio, rendering and package validation; Skills, installation guides, examples, assets and unknown paths retain the full gate, including both npm archive scans. Rendering package downloads are reused by runner image version, with a weekly fallback when image-version metadata is unavailable. Code and configuration changes also receive maintainability analysis. Separate manual candidate-build and npm-publication entries implement build → local testing → manual publish. New candidate builds, npm publication and snapshot recovery run only from main in nexu-io/openmotion. Frozen receipts from the former repository name and feature/motion producer runs remain readable with their original run/hash identity. The build freezes the selected dispatch commit (or an explicitly integrated source SHA). Test builds use DEV; an empty test version uses the next source patch plus short test.N from the workflow counter and historical offset, without rewriting the source baseline. Reruns add an attempt suffix. Stable builds require an explicit new version and prod configuration. Each immutable candidate includes candidate-install.md, an identity-filled acceptance checklist and a hash-bound release-notes.md draft. Both channels derive changes from read-only same-channel published Release/tag history and the frozen source SHA, display the draft in the build summary and disclose missing/truncated baselines. Short or repeated comparison pages retain unique entries with explicit incomplete counts instead of blocking the candidate build. Acceptance focus and known issues remain unfilled review inputs; they are not inferred from CI. Schema-3 receipts require notes, while schema-2 receipts remain compatible. Publication resolves a unique unexpired artifact from a successful registered build, checks official ZIP/file hashes and source integration, then records the actual operator. No acceptance checkbox or independent approval environment is enabled; the receipt is not proof of private tests or review. Test publishes the same tgz under npm candidate, promotes test in an npm-OIDC-only job with bounded propagation retries, then archives and advances the DEV guide. Mac/Windows cold installs follow as non-blocking checks with visible warnings. Stable uses the same trusted workflow filename and publicly stages the exact prod tgz under stage. Both matching Mac/Windows installation reports must pass before latest advances; test is preserved, prod snapshots follow, and the stable guide advances last. Stage is public. A separate read-only installation workflow can recheck an exact public test or stable version using the shared registry-download retries. npm and R2 are not atomic; storage failure can leave the guide on the earlier version. Builds can continue during acceptance; publication serialization, version checks and ETag writes prevent an older completion from regressing the guide. Snapshot-only recovery requires an identical existing npm version and never moves tags or the default. No private template contents or credentials are bundled. npm trusted-publisher configuration must name the renamed repository and remains a separate activation prerequisite. Live prod templates, real Agent creation and human playback remain release acceptance responsibilities, separate from build and native-install evidence. See [release workflows](../release-workflows.md) and [package checks](../test-packages.md). Downstream publication jobs consume immutable producer artifact IDs retained across partial retries; native Mac and Windows jobs expose separate report identities. OIDC authenticates publication, but automatic npm provenance is disabled for prebuilt candidates because the publication workflow SHA differs from the application source. Candidate/manifest/hash records provide traceability without claiming a signed build attestation. Test and stable share source/hash/scanning and retry controls; stable release records additionally retain both matching native reports. Skills marketplace/platform publication is not implemented. The bundled Skills are installed into local hosts only. -The manual publication definition includes an isolated GitHub-only Release-notes job after successful npm and guide delivery. It creates an exact-source draft before publishing; test is a Pre-release and an unsuperseded stable release may become Latest. Notes include install links, source/hash, verification scope and generated change history. First-channel notes declare their history-range limitation. Conflicting tags/releases are preserved; retries keep published maintainer prose. Notes failures warn without undoing package delivery, and archive-only recovery never creates Releases. This extension does not change npm workflow activation itself. Automatic test numbering additionally reads published npm latest/test/candidate tags and advances beyond them, so a source-version reset cannot reset public package numbering; explicit versions retain the existing path. +The manual publication definition includes an isolated GitHub-only Release-notes job after successful npm and guide delivery. It creates an exact-source draft before publishing; test is a Pre-release and an unsuperseded stable release may become Latest. For new candidates, Notes reuse the sealed draft and add install links, source/hash and verification scope; a separate github-release-notes.md holds the final body so immutable candidate files are unchanged. Older schema-2 candidates retain publication-time generation. First-channel notes declare their history-range limitation. Conflicting tags/releases are preserved; retries keep published maintainer prose. Notes failures warn without undoing package delivery, and archive-only recovery never creates Releases. This extension does not change npm workflow activation itself. Automatic test numbering additionally reads published npm latest/test/candidate tags and advances beyond them, so a source-version reset cannot reset public package numbering; explicit versions retain the existing path. 已确认方向是继续支持多 Agent 接入、可编辑工程与一个工作区内的发现/制作闭环。 diff --git a/docs/release-workflows.md b/docs/release-workflows.md index ab1fdd086..e3768d29d 100644 --- a/docs/release-workflows.md +++ b/docs/release-workflows.md @@ -6,7 +6,7 @@ Use two manual Actions entries: **Motion candidate build**, then **Motion npm pu | Operator step | Automated work | | --- | --- | -| Build: select `main` and channel; leave test version empty or enter a stable version | Freeze the current `main` SHA and template environment, check/build/scan once, retain the candidate and show download/install instructions | +| Build: select `main` and channel; leave test version empty or enter a stable version | Freeze the current `main` SHA and template environment, check/build/scan once, freeze release notes with the candidate and show notes/download/install instructions | | Optional local testing | Use `candidate-install.md` and the local tgz in an isolated host; retain completed `acceptance.md` internally | | Publish: select the same channel and enter the exact candidate version | Find the unique candidate, verify source/hashes and publish the same tgz. Test advances `test` before non-blocking native checks; stable requires both native checks before `latest`. Archive snapshots and update the corresponding guide last | @@ -117,7 +117,7 @@ A same-repository PR changing this workflow, registry helpers or their tests run Stable uses the prod paths above and npm `latest`; test keeps the DEV paths and npm `test`. Existing legacy `/versions//install.md` objects remain immutable. -Each version archives the exact tgz, manifests, generated blank acceptance checklist, both installation guides, scans, candidate identity, the schema-2 release record; later platform reports are retained as Actions artifacts. The release record contains package/source identity and the manual operator authorization; it does not claim independent review or attest private test results. Completed private acceptance material is never uploaded. `test-promotion.json` retains the prior tag, exact package, promotion outcome. The immutable release record includes channel verification and template environment. Test marks native checks as post-publication; stable records both matching native reports and their hashes as `passed-before-latest`. These reports explicitly retain unrun model/human checks. Snapshot recovery preserves a prior immutable release record while retaining its own fresh operator authorization in its attempt artifact. +Each version archives the exact tgz, manifests, generated blank acceptance checklist, both installation guides, scans, sealed candidate notes when present, candidate identity, the schema-2 release record; later platform reports are retained as Actions artifacts. The release record contains package/source identity and the manual operator authorization; it does not claim independent review or attest private test results. Completed private acceptance material is never uploaded. `test-promotion.json` retains the prior tag, exact package, promotion outcome. The immutable release record includes channel verification and template environment. Test marks native checks as post-publication; stable records both matching native reports and their hashes as `passed-before-latest`. These reports explicitly retain unrun model/human checks. Snapshot recovery preserves a prior immutable release record while retaining its own fresh operator authorization in its attempt artifact. Builds have no publication lock, so another version can build during acceptance. Test/stable publication and snapshot recovery share one workflow-wide concurrency group with cancellation disabled. GitHub concurrency is not a durable FIFO: it retains one running and one newest pending run; do not enqueue a batch. Publish one accepted version at a time. A superseded candidate can retain version snapshots without moving the default. Default-guide version comparison plus ETag conditional writes prevent late older completion from rolling a newer entry back; unrecognized or conflicting same-version guide bytes require inspection. @@ -142,6 +142,12 @@ After separately authorized default-branch/npm setup, build a new candidate and ## GitHub Release notes +Both test/DEV and stable/prod candidate builds prepare `release-notes.md` before sealing the candidate. The existing contents-read token reads published same-channel GitHub Releases and immutable tag/commit history; no Release or tag is created by a build. Notes freeze the version, template environment, source SHA, tgz checksum, baseline and source changes. The ZIP includes the draft, and the Actions summary displays it. Schema-3 candidates require its identity and SHA256; schema-2 candidates remain readable without a draft. The previous baseline is the highest lower-version published GitHub Release in the same channel, not an unpublished candidate or an npm tag with no GitHub Release. A first-channel draft explicitly discloses its limited 100-commit history; ordinary comparisons paginate up to 1,000 commits, and short/empty or repeated pages stop enumeration with unique rows, explicit shown/total counts and a full comparison link instead of failing the build. An incomplete empty result is not reported as an empty release delta. Missing GitHub metadata or diverged history stops note preparation rather than silently claiming a complete delta. + +Acceptance focus and known issues are marked NOT PROVIDED, not inferred from CI. Keep actual results in the private acceptance copy; generated notes are an aid to review, not acceptance. Do not edit sealed ZIP contents or rehash them to bypass verification. Maintainers can edit published GitHub Release prose; retries preserve those edits. Preparing notes does not add another manual entry, approval environment or publication permission. + +Publication reuses the schema-3 candidate's exact draft and only adds final installation links and verified publication identity. It writes the final display body to `github-release-notes.md`, preserving the sealed `release-notes.md` for retries and immutable snapshots. Older schema-2 candidates retain the GitHub-generated publication-time fallback. + This extension requires the manual npm entry points to be enabled; their restoration is tracked in [PR #444](https://github.com/nexu-io/openmotion/pull/444). It does not change the repository source-installation default or enable those roots itself. After the matching test or stable snapshot succeeds, **Publish GitHub Release notes** prepares a draft and publishes it at `v`, targeting the candidate's source commit rather than the publication workflow SHA. Test releases are marked **Pre-release** and never become GitHub Latest. Stable releases become Latest only when this publication was not superseded. No GitHub Release is created for candidate builds, PR checks or snapshot-only recovery. @@ -150,6 +156,6 @@ The note includes the exact npm version, DEV/prod environment, immutable and mov The implementation follows Open Design's draft-before-publication pattern in `.github/workflows/release-stable.yml` and `.github/scripts/release/github/stable-notes.sh`, scaled to this npm application. It does not copy desktop signing, updater feeds or multilingual website publication. -The notes job alone executes with `contents: write`; it receives neither npm OIDC nor R2 secrets and never executes candidate application code. The recovery caller grants the reusable workflow a contents-write permission ceiling so GitHub can validate its conditional notes job, but archive-only always skips that job and its running jobs retain contents-read. Existing conflicting tags or release identities stop instead of being overwritten. An already published matching Release is preserved on retry, including maintainer edits. A draft left by a partial failure can finish with the same identity. Notes failures produce a warning without rolling back delivered npm packages or guides; inspect the retained `release-notes.md`/`github-release.json` artifact and rerun the same publication version to retry. GitHub Release creation may require repository/organization Actions policy to permit the scoped write token. That permission and live publication need independent verification. +The notes job alone executes with `contents: write`; it receives neither npm OIDC nor R2 secrets and never executes candidate application code. The recovery caller grants the reusable workflow a contents-write permission ceiling so GitHub can validate its conditional notes job, but archive-only always skips that job and its running jobs retain contents-read. Existing conflicting tags or release identities stop instead of being overwritten. An already published matching Release is preserved on retry, including maintainer edits. A draft left by a partial failure can finish with the same identity. Notes failures produce a warning without rolling back delivered npm packages or guides; inspect the retained `release-notes.md`/`github-release-notes.md`/`github-release.json` artifact and rerun the same publication version to retry. GitHub Release creation may require repository/organization Actions policy to permit the scoped write token. That permission and live publication need independent verification. These workflows remain specific to OpenMotion. A later organization template can expose project-specific build/package/storage inputs and reuse the proven controls; npm trust and repository secrets must still be configured for each caller. No organization template or repository setting is created by this change. diff --git a/tests/release-fixture.mjs b/tests/release-fixture.mjs index c68bd627c..78df98edc 100644 --- a/tests/release-fixture.mjs +++ b/tests/release-fixture.mjs @@ -3,7 +3,7 @@ import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; import { runFile, sha256, writeJSON } from '../scripts/runtime-assets.mjs'; -import { sealCandidate, repository, candidateWorkflow, publicationWorkflow, authorizationReceipt } from '../.github/scripts/motion-release.mjs'; +import { sealCandidate, repository, candidateWorkflow, publicationWorkflow, authorizationReceipt, candidateNoteIdentity } from '../.github/scripts/motion-release.mjs'; export async function candidateFixture(t, branch = 'main', options = {}) { const work = await mkdtemp(path.join(os.tmpdir(), 'motion-release-test-')); @@ -32,6 +32,7 @@ export async function candidateFixture(t, branch = 'main', options = {}) { for (const name of ['source-scan.json', 'package-scan.json']) await writeJSON(path.join(build, name), { status: 'passed' }); const env = { MOTION_RELEASE_CHANNEL: channel, MOTION_SOURCE_SHA: commit, MOTION_VERSION: version, GITHUB_SHA: 'b'.repeat(40), GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/${branch}`, GITHUB_RUN_ID: '123', GITHUB_RUN_ATTEMPT: '1' }; + await writeFile(path.join(build, 'release-notes.md'), `## Changes\n\nFrozen candidate changes\n\n${candidateNoteIdentity({ version, sourceCommit: commit, tgzSHA256: await sha256(tgz) })}\n`); const candidate = await sealCandidate(build, directory, root, env); const provenance = { head_branch: branch, head_sha: env.GITHUB_SHA, runId: 123, attempt: 1 }; await writeJSON(path.join(directory, 'provenance.json'), provenance); diff --git a/tests/release-notes.test.mjs b/tests/release-notes.test.mjs index 8231c82d2..b877660f4 100644 --- a/tests/release-notes.test.mjs +++ b/tests/release-notes.test.mjs @@ -1,9 +1,9 @@ import test from 'node:test'; import assert from 'node:assert/strict'; -import { readFile, writeFile } from 'node:fs/promises'; +import { readFile, writeFile, rm } from 'node:fs/promises'; import path from 'node:path'; import { candidateFixture } from './release-fixture.mjs'; -import { publishReleaseNotes } from '../.github/scripts/motion-release-notes.mjs'; +import { publishReleaseNotes, prepareCandidateNotes } from '../.github/scripts/motion-release-notes.mjs'; async function fixture(t, version = '0.6.8') { const f = await candidateFixture(t, 'main', { version }); @@ -34,15 +34,16 @@ for (const [version, prefix, prerelease] of [['0.6.8', 'open-motion', false], [' assert.equal(create.target_commitish, f.candidate.sourceCommit); assert.equal(create.draft, true); assert.equal(create.prerelease, prerelease); assert(create.body.includes(`/${prefix}/${version}/install.md`) && create.body.includes(f.candidate.tgzSHA256)); assert(create.body.includes('real Agent creation and human audiovisual acceptance are separate')); - const generated = f.writes.find(w => w.route === '/releases/generate-notes').data; - assert.equal(generated.target_commitish, f.candidate.sourceCommit); - assert.equal(generated.previous_tag_name, prerelease ? undefined : 'v0.6.7'); + assert(!f.writes.some(w => w.route === '/releases/generate-notes'), 'New candidates reuse their frozen draft'); + assert(create.body.includes('Frozen candidate changes')); + const original = await readFile(path.join(f.directory, 'release-notes.md'), 'utf8'); assert.equal(f.writes.at(-1).data.make_latest, prerelease ? 'false' : 'true'); const count = f.writes.length; f.changeRelease({ body: f.getRelease().body + '\nMaintainer edit\n' }); await publishReleaseNotes(f.directory, f); assert.equal(f.writes.length, count, 'Published releases are not overwritten on retry'); - assert((await readFile(path.join(f.directory, 'release-notes.md'), 'utf8')).includes('Maintainer edit')); + assert.equal(await readFile(path.join(f.directory, 'release-notes.md'), 'utf8'), original, 'Sealed notes remain immutable across publication and retries'); + assert((await readFile(path.join(f.directory, 'github-release-notes.md'), 'utf8')).includes('Maintainer edit')); }); } @@ -89,3 +90,116 @@ test('GitHub Release writing is isolated from npm/R2 and never runs for archive- const recovery = await readFile(new URL('../.github/workflows/motion-publication-recovery.yml', import.meta.url), 'utf8'); assert(recovery.includes('contents: write') && recovery.includes('archive_only: true'), 'The reusable caller must permit the conditional Release job without running it'); }); + +for (const version of ['0.6.8', '0.6.8-test.14']) test(`${version} candidate notes use read-only exact-source history and the same-channel baseline`, async t => { + const f = await fixture(t, version), source = f.candidate.sourceCommit, base = 'a'.repeat(40); + await rm(path.join(f.build, 'release-notes.md')); + const previous = version.includes('-test.') ? 'v0.6.8-test.13' : 'v0.6.7'; + const calls = []; + const commits = Array.from({ length: 101 }, (_, i) => ({ sha: (i + 1).toString(16).padStart(40, '0'), commit: { message: i === 0 ? 'Fix ![external](https://bad.invalid)