The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.
TypeScript agent-skillsagentic-aiai-agentsai-videobyokclaude-codecodexdeepseek-harnessdsh-plugingenerative-ailocal-firstmcpmotionmotion-graphicsmultimodalopenmotionreverse-engineeringvideo-editingvideo-generationworkbuddy
feat(motion): simplify test releases to build, accept and approve
luogaobf3c1f1db4b8
diff --git a/.github/scripts/motion-release.mjs b/.github/scripts/motion-release.mjsindex e58948a5..884fc0f0 100644--- a/.github/scripts/motion-release.mjs+++ b/.github/scripts/motion-release.mjs@@ -7,13 +7,16 @@ 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 { checkReleaseVersion } from '../../scripts/release-version.mjs';+import { checkReleaseVersion, compareReleaseVersions } from '../../scripts/release-version.mjs';import { generateInstallGuide } from '../../scripts/install-guide.mjs';import { publishGuide, storagePlan } from './publish-install-guide.mjs';import { scanPackage, scanSource } from './motion-scan.mjs';export const repository = 'nexu-io/html-anything';-export const candidateWorkflow = '.github/workflows/motion-candidate.yml';+export const candidateWorkflow = '.github/workflows/motion-publish-test.yml';+export const recoveryWorkflow = '.github/workflows/motion-publication-recovery.yml';+export const publicationEnvironment = 'motion-test-publish';+export const candidateJobName = 'Build immutable candidate';const exec = promisify(execFile), hashPattern = /^[a-f0-9]{64}$/;const json = async file => JSON.parse(await readFile(file, 'utf8'));const integrity = bytes => 'sha512-' + createHash('sha512').update(bytes).digest('base64');@@ -23,12 +26,19 @@ export function releaseInputs(env = process.env) {assert.equal(env.GITHUB_EVENT_NAME, 'workflow_dispatch', 'Manual invocation required');assert.equal(env.GITHUB_REF, 'refs/heads/main', 'Run the trusted workflow registered on main');assert(['publish-test', 'archive-only'].includes(env.MOTION_RELEASE_ACTION), 'Unknown release action');- assert.equal(env.MOTION_APPROVED, 'true', 'Explicit release approval is required');- assert.match(env.MOTION_EXPECTED_SHA256 || '', hashPattern, 'Require the accepted tgz SHA256');- assert.match(env.MOTION_ACCEPTANCE_SHA256 || '', hashPattern, 'Require the digest of the internal acceptance record');+ const workflow = env.GITHUB_WORKFLOW_REF;+ assert([candidateWorkflow, recoveryWorkflow].some(p => workflow === `${repository}/${p}@refs/heads/main`), 'Require a trusted manual entry');+ if (workflow.includes(recoveryWorkflow)) assert.equal(env.MOTION_RELEASE_ACTION, 'archive-only', 'Recovery never publishes or moves a channel');+ if (env.MOTION_EXPECTED_SHA256) assert.match(env.MOTION_EXPECTED_SHA256, hashPattern);assert(/^[1-9]\d*$/.test(env.MOTION_CANDIDATE_RUN || ''), 'Require a candidate workflow run ID');return { action: env.MOTION_RELEASE_ACTION, expectedSHA256: env.MOTION_EXPECTED_SHA256,- acceptanceSHA256: env.MOTION_ACCEPTANCE_SHA256, candidateRun: env.MOTION_CANDIDATE_RUN };+ candidateRun: env.MOTION_CANDIDATE_RUN, artifactId: env.MOTION_CANDIDATE_ARTIFACT_ID };+}++export async function resolveSource(control, requested, version, run = runFile) {+ const commit = requested || (await run('git', ['rev-parse', 'refs/remotes/origin/feature/motion'], { cwd: control })).trim();+ await validateSource(control, commit, version, run);+ return commit;}export async function validateSource(control, commit, version, run = runFile) {@@ -52,9 +62,16 @@ export async function sealCandidate(build, output, source, env = process.env) {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');- const names = [filename, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'install.md', 'install-record.json'];+ const template = await readFile(new URL('../../docs/templates/release-record.md', import.meta.url), 'utf8');+ assert(template.includes('<!-- CANDIDATE_IDENTITY -->'), 'Acceptance template needs its generated identity marker');+ const identity = { package: `${guide.packageName}@${guide.version}`, sourceCommit: guide.commit,+ workflowCommit: env.GITHUB_SHA, candidateRun: Number(env.GITHUB_RUN_ID), attempt: Number(env.GITHUB_RUN_ATTEMPT),+ tgz: filename, tgzSHA256: await sha256(path.join(output, filename)), applicationSHA256: guide.applicationSHA256, locks: guide.locks,+ templateEnvironment: 'prod' };+ await writeFile(path.join(output, 'acceptance.md'), template.replace('<!-- CANDIDATE_IDENTITY -->', '```json\n' + JSON.stringify(identity, null, 2) + '\n```'));+ const names = [filename, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'install.md', 'install-record.json', 'acceptance.md'];const files = Object.fromEntries(await Promise.all(names.map(async name => [name, await sha256(path.join(output, name))])));- const candidate = { schemaVersion: 1, kind: 'motion-candidate', packageName: guide.packageName, version: guide.version,+ const candidate = { schemaVersion: 2, 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: 'refs/heads/main', sha: env.GITHUB_SHA,runId: Number(env.GITHUB_RUN_ID), attempt: Number(env.GITHUB_RUN_ATTEMPT) },@@ -63,11 +80,14 @@ export async function sealCandidate(build, output, source, env = process.env) {return candidate;}-export function validateRun(run, artifact) {+export function validateRun(run, artifact, job, attempt) {assert.equal(run.event, 'workflow_dispatch'); assert.equal(run.head_branch, 'main');- assert.equal(run.head_repository?.full_name, repository); assert.equal(run.status, 'completed'); assert.equal(run.conclusion, 'success');+ assert.equal(run.head_repository?.full_name, repository);assert.equal(run.path.split('@')[0], candidateWorkflow, 'Candidate must come from the registered workflow');- assert.equal(artifact.name, `motion-candidate-${run.id}-${run.run_attempt}`);+ assert(Number.isSafeInteger(attempt) && attempt > 0 && attempt <= run.run_attempt, 'Invalid producer attempt');+ assert.equal(job.name, candidateJobName); assert.equal(job.status, 'completed'); assert.equal(job.conclusion, 'success');+ assert.equal(job.run_id, run.id); assert.equal(job.head_sha, run.head_sha);+ assert.equal(artifact.name, `motion-candidate-${run.id}-${attempt}`);assert.equal(artifact.workflow_run?.id, run.id); assert.equal(artifact.expired, false);assert.match(artifact.digest || '', /^sha256:[a-f0-9]{64}$/, 'Require the GitHub artifact digest');assert(artifact.size_in_bytes > 0 && artifact.size_in_bytes < 150 * 1024 * 1024, 'Unexpected artifact size');@@ -80,14 +100,65 @@ async function github(route, fetcher = fetch) {return response.json();}+export function validatePublicationEnvironment(environment, branches) {+ assert.equal(environment.name, publicationEnvironment);+ const rule = environment.protection_rules?.find(r => r.type === 'required_reviewers');+ assert(rule?.reviewers?.length > 0 && rule.prevent_self_review === true, 'Configure independent required reviewers and prevent self-review');+ assert.equal(environment.can_admins_bypass, false, 'Disable environment protection bypass');+ assert.equal(environment.deployment_branch_policy?.custom_branch_policies, true, 'Restrict the publication environment to main');+ assert.equal(environment.deployment_branch_policy?.protected_branches, false);+ assert.deepEqual(branches.branch_policies?.map(b => ({ name: b.name, type: b.type })).sort((a, b) => a.name.localeCompare(b.name)), [{ name: 'main', type: 'branch' }]);+}++export async function checkPublicationEnvironment(fetcher = fetch) {+ const environment = await github(`/environments/${publicationEnvironment}`, fetcher);+ const branches = await github(`/environments/${publicationEnvironment}/deployment-branch-policies?per_page=100`, fetcher);+ validatePublicationEnvironment(environment, branches);+}++export function approvalReceipt(candidate, reviews, run, action, observedAt = new Date().toISOString()) {+ // shortcut: GitHub reviews are run-scoped; use deployment-specific receipts if the API gains attempt identities.+ const reviewers = [...new Set(reviews.filter(r => r.state === 'approved' && r.comment?.trim() === 'PASS' &&+ r.environments?.some(e => e.name === publicationEnvironment) && r.user?.login &&+ ![run.actor?.login, run.triggering_actor?.login].includes(r.user.login)).map(r => r.user.login))].sort();+ assert(reviewers.length > 0, 'Require an independent environment approval with the non-sensitive comment PASS');+ return { schemaVersion: 1, environment: publicationEnvironment, publicationRun: run.id, action,+ version: candidate.version, tgzSHA256: candidate.tgzSHA256, candidateRun: candidate.workflow,+ reviewers, observedAt, historySHA256: createHash('sha256').update(JSON.stringify(reviews)).digest('hex'),+ scope: 'run-review-history; the protected npm job enforces approval for its execution' };+}++export async function recordApproval(directory, inputs, fetcher = fetch, env = process.env) {+ await checkPublicationEnvironment(fetcher);+ const candidate = await verifyDownloaded(directory, inputs.expectedSHA256);+ const run = await github(`/actions/runs/${env.GITHUB_RUN_ID}`, fetcher);+ assert.equal(run.head_branch, 'main'); assert.equal(run.event, 'workflow_dispatch');+ assert.equal(run.head_sha, env.GITHUB_SHA);+ assert.equal(run.path.split('@')[0], env.GITHUB_WORKFLOW_REF.slice(repository.length + 1).split('@')[0]);+ const reviews = await github(`/actions/runs/${run.id}/approvals`, fetcher);+ await writeJSON(path.join(directory, 'approval.json'), approvalReceipt(candidate, reviews, run, inputs.action));+}++async function verifyApproval(directory, inputs, env = process.env) {+ const candidate = await verifyDownloaded(directory, inputs.expectedSHA256), approval = await json(path.join(directory, 'approval.json'));+ assert.equal(approval.schemaVersion, 1);+ assert.equal(approval.environment, publicationEnvironment); assert.equal(approval.version, candidate.version);+ assert.equal(approval.tgzSHA256, candidate.tgzSHA256); assert.equal(approval.action, inputs.action);+ assert.deepEqual(approval.candidateRun, candidate.workflow);+ assert.equal(String(approval.publicationRun), env.GITHUB_RUN_ID, 'Approval belongs to another publication run');+ assert(Array.isArray(approval.reviewers) && approval.reviewers.length > 0 && approval.reviewers.every(v => typeof v === 'string' && v.length > 0));+ assert.match(approval.historySHA256, hashPattern);+ return approval;+}+export async function verifyCandidate(directory, expectedSHA256, run) {const candidate = await json(path.join(directory, 'candidate.json'));- assert.equal(candidate.schemaVersion, 1); assert.equal(candidate.kind, 'motion-candidate'); assert.equal(candidate.packageName, '@openmotion/app');+ assert.equal(candidate.schemaVersion, 2); assert.equal(candidate.kind, 'motion-candidate'); assert.equal(candidate.packageName, '@openmotion/app');checkReleaseVersion(candidate.version); assert(candidate.version.includes('-test.'));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}$/);assert.deepEqual(candidate.workflow, { repository, path: candidateWorkflow, ref: 'refs/heads/main', 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'];+ const names = [candidate.tgz, 'release-npm.json', 'source-scan.json', 'package-scan.json', 'install.md', 'install-record.json', 'acceptance.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);assert.equal(await sha256(path.join(directory, candidate.tgz)), expectedSHA256);@@ -123,12 +194,18 @@ export async function platformReports(directory, candidate) {return reports;}-export async function downloadCandidate(runId, directory, expectedSHA256, fetcher = fetch) {+export async function downloadCandidate(runId, directory, expectedSHA256, fetcher = fetch, artifactId) {assert(/^[1-9]\d*$/.test(runId));const run = await github(`/actions/runs/${runId}`, fetcher);const { artifacts } = await github(`/actions/runs/${runId}/artifacts?per_page=100`, fetcher);- const matches = artifacts.filter(a => a.name === `motion-candidate-${run.id}-${run.run_attempt}`); assert.equal(matches.length, 1, 'Candidate artifact missing or ambiguous');- const artifact = matches[0]; validateRun(run, artifact);+ const matches = artifacts.filter(a => artifactId ? String(a.id) === String(artifactId) : new RegExp(`^motion-candidate-${run.id}-[1-9]\\d*$`).test(a.name));+ assert(matches.length > 0, 'Candidate artifact missing');+ matches.sort((a, b) => Number(b.name.split('-').at(-1)) - Number(a.name.split('-').at(-1)));+ const artifact = matches[0], attempt = Number(artifact.name.split('-').at(-1));+ assert.equal(matches.filter(a => a.name === artifact.name).length, 1, 'Candidate artifact ambiguous');+ const { jobs } = await github(`/actions/runs/${run.id}/attempts/${attempt}/jobs?per_page=100`, fetcher);+ const builds = jobs.filter(j => j.name === candidateJobName); assert.equal(builds.length, 1, 'Successful candidate producer is missing or ambiguous');+ validateRun(run, artifact, builds[0], attempt);const redirect = await fetcher(`https://api.github.com/repos/${repository}/actions/artifacts/${artifact.id}/zip`, {redirect: 'manual', signal: AbortSignal.timeout(30_000), headers: { Authorization: `Bearer ${process.env.GH_TOKEN || process.env.GITHUB_TOKEN}` } });assert.equal(redirect.status, 302); const url = new URL(redirect.headers.get('location')); assert.equal(url.protocol, 'https:'); assert(!url.username && !url.password);@@ -140,15 +217,15 @@ export async function downloadCandidate(runId, directory, expectedSHA256, fetchetry {const archive = path.join(work, 'candidate.zip'); await writeFile(archive, bytes);const entries = (await runFile('unzip', ['-Z1', archive])).trim().split('\n');- assert(entries.length === 7 && new Set(entries).size === 7, 'Unexpected candidate artifact files');+ assert(entries.length === 8 && new Set(entries).size === 8, '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) {const { stdout } = await exec('unzip', ['-p', archive, name], { encoding: 'buffer', maxBuffer: 150 * 1024 * 1024 });await writeFile(path.join(directory, name), stdout);}- const candidate = await verifyCandidate(directory, expectedSHA256, run);- await writeJSON(path.join(directory, 'provenance.json'), { runId: run.id, attempt: run.run_attempt, head_sha: run.head_sha, artifactId: artifact.id, digest: artifact.digest });+ const candidate = await verifyCandidate(directory, expectedSHA256 || (await json(path.join(directory, 'candidate.json'))).tgzSHA256, { ...run, run_attempt: attempt });+ await writeJSON(path.join(directory, 'provenance.json'), { runId: run.id, attempt, head_sha: run.head_sha, artifactId: artifact.id, digest: artifact.digest });return candidate;} finally { await rm(work, { recursive: true, force: true }); }}@@ -162,10 +239,12 @@ export async function registryPackage(candidate, fetcher = fetch) {return { version: version || null, tags: data['dist-tags'] || {} };}-export async function publishNpm(directory, inputs, { fetcher = fetch, run = runFile } = {}) {+export async function publishNpm(directory, inputs, { fetcher = fetch, run = runFile, env = process.env } = {}) {const candidate = await verifyDownloaded(directory, inputs.expectedSHA256);+ await verifyApproval(directory, inputs, env);const before = await registryPackage(candidate, fetcher);if (inputs.action === 'archive-only') assert(before.version, 'Archive-only requires an existing identical npm version');+ if (inputs.action === 'publish-test' && before.tags.test) assert(compareReleaseVersions(candidate.version, before.tags.test) >= 0, 'A newer npm test version already exists; use snapshot recovery for an identical published version');const record = { schemaVersion: 1, version: candidate.version, tgzSHA256: candidate.tgzSHA256, action: inputs.action,previousLatest: before.tags.latest ?? null, status: before.version ? 'already-published-identical' : 'publish-started' };await writeJSON(path.join(directory, 'npm-publication.json'), record);@@ -180,6 +259,7 @@ export async function publishNpm(directory, inputs, { fetcher = fetch, run = runexport async function archiveRelease(directory, inputs, config, { run = runFile, fetcher = fetch, env = process.env } = {}) {await writeJSON(path.join(directory, 'release-attempt.json'), { action: inputs.action, tgzSHA256: inputs.expectedSHA256, stage: 'verifying-release', runId: env.GITHUB_RUN_ID });const candidate = await verifyDownloaded(directory, inputs.expectedSHA256);+ const approval = await verifyApproval(directory, inputs, env);const platforms = await platformReports(directory, candidate);const record = await json(path.join(directory, 'install-record.json')), plan = storagePlan(record, config);assert.equal(candidate.tgzSHA256, inputs.expectedSHA256);@@ -187,7 +267,9 @@ export async function archiveRelease(directory, inputs, config, { run = runFile,const npm = await json(path.join(directory, 'npm-publication.json'));assert.equal(npm.tgzSHA256, candidate.tgzSHA256);assert.equal(registry.tags.latest ?? null, npm.previousLatest, 'npm latest changed unexpectedly; stop and investigate before promoting a guide');- if (inputs.action === 'publish-test') assert.equal(registry.tags.test, candidate.version, 'The test channel changed; use archive-only or a separately approved channel recovery');+ if (inputs.action === 'publish-test' && registry.tags.test !== candidate.version) {+ assert(registry.tags.test && compareReleaseVersions(registry.tags.test, candidate.version) > 0, 'npm test tag is missing or unexpectedly older; explicit channel recovery is required');+ }const prefix = path.posix.dirname(plan.versionKey), work = await mkdtemp(path.join(os.tmpdir(), 'motion-snapshot-'));const aws = async (operation, rest) => JSON.parse(await run('aws', ['--endpoint-url', plan.endpoint, '--region', 'auto', 's3api', operation, '--bucket', plan.bucket, ...rest]) || '{}');try {@@ -197,13 +279,13 @@ export async function archiveRelease(directory, inputs, config, { run = runFile,catch (error) { if (/NoSuchKey|\(404\)|Not Found/.test(error.message)) return null; throw error; }};const prior = await get(`${prefix}/release-record.json`);- let release = { schemaVersion: 1, packageName: candidate.packageName, version: candidate.version, sourceCommit: candidate.sourceCommit,+ let release = { schemaVersion: 2, packageName: candidate.packageName, version: candidate.version, sourceCommit: candidate.sourceCommit,tgzSHA256: candidate.tgzSHA256, integrity: candidate.integrity, candidateRun: candidate.workflow,- acceptanceRecordSHA256: inputs.acceptanceSHA256, approvedBy: env.GITHUB_ACTOR, publicationRun: env.GITHUB_RUN_ID,+ approval, publicationRun: env.GITHUB_RUN_ID,platformVerification: platforms, status: 'registry-verified', publishedAt: new Date().toISOString() };if (prior) {const existing = JSON.parse(prior);- for (const key of ['packageName', 'version', 'sourceCommit', 'tgzSHA256', 'integrity', 'acceptanceRecordSHA256']) assert.equal(existing[key], release[key], 'Existing release record differs: ' + key);+ for (const key of ['packageName', 'version', 'sourceCommit', 'tgzSHA256', 'integrity']) assert.equal(existing[key], release[key], 'Existing release record differs: ' + key);release = existing;}await writeJSON(path.join(directory, 'release-record.json'), release);@@ -220,19 +302,31 @@ export async function archiveRelease(directory, inputs, config, { run = runFile,const response = await fetcher(new URL('/' + object.key, plan.publicOrigin), { redirect: 'error', signal: AbortSignal.timeout(30_000), headers: { 'cache-control': 'no-cache' } });assert(response.ok, 'Snapshot public readback failed'); assert(Buffer.from(await response.arrayBuffer()).equals(object.bytes), 'Snapshot public bytes differ');}- await publishGuide(directory, config, { run, fetcher, promote: inputs.action === 'publish-test' });- await writeJSON(path.join(directory, 'release-attempt.json'), { action: inputs.action, version: candidate.version, stage: inputs.action === 'publish-test' ? 'test-entry-verified' : 'archive-only-verified', runId: env.GITHUB_RUN_ID });+ const promote = inputs.action === 'publish-test' && registry.tags.test === candidate.version;+ const publication = await publishGuide(directory, config, { run, fetcher, promote });+ await writeJSON(path.join(directory, 'release-attempt.json'), { action: inputs.action, version: candidate.version,+ stage: inputs.action === 'archive-only' ? 'archive-only-verified' : !promote || publication.phase === 'superseded' ? 'archived-superseded' : 'test-entry-verified', runId: env.GITHUB_RUN_ID });return release;} finally { await rm(work, { recursive: true, force: true }); }}if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {const [command, directory, extra, final] = process.argv.slice(2);- if (command === 'source') await validateSource(directory, process.env.MOTION_SOURCE_SHA, process.env.MOTION_VERSION);+ if (command === 'source') {+ const commit = await resolveSource(directory, process.env.MOTION_SOURCE_SHA, process.env.MOTION_VERSION);+ const { appendFile } = await import('node:fs/promises');+ await appendFile(process.env.GITHUB_OUTPUT, `source_sha=${commit}\n`);+ }else if (command === 'seal') await sealCandidate(directory, extra, final);else {const inputs = releaseInputs();- if (command === 'download') await downloadCandidate(inputs.candidateRun, directory, inputs.expectedSHA256);+ if (command === 'download') {+ const candidate = await downloadCandidate(inputs.candidateRun, directory, inputs.expectedSHA256, fetch, inputs.artifactId);+ const { appendFile } = await import('node:fs/promises');+ await appendFile(process.env.GITHUB_OUTPUT, `tgz_sha256=${candidate.tgzSHA256}\n`);+ }+ else if (command === 'environment') await checkPublicationEnvironment();+ else if (command === 'approval') await recordApproval(directory, inputs);else if (command === 'rescan') {const c = await verifyDownloaded(directory, inputs.expectedSHA256);await validateSource(extra, c.sourceCommit, c.version);diff --git a/.github/scripts/publish-install-guide.mjs b/.github/scripts/publish-install-guide.mjsindex 0cf3d19d..266b26f2 100644--- a/.github/scripts/publish-install-guide.mjs+++ b/.github/scripts/publish-install-guide.mjs@@ -5,6 +5,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 { compareReleaseVersions } from '../../scripts/release-version.mjs';export function storagePlan(record, { endpoint, bucket, publicOrigin }) {const api = new URL(endpoint), origin = new URL(publicOrigin);@@ -53,6 +54,14 @@ export async function publishGuide(directory, config, { run = runFile, fetcher =if (previous) {assert(previous.etag, 'Existing guide requires an ETag for conditional promotion');await writeFile(path.join(directory, 'previous-install.md'), previous.bytes);+ const version = previous.bytes.toString('utf8').match(/^# Install OpenMotion (\S+)\s*$/m)?.[1];+ assert(version, 'Existing default guide has no recognizable version; inspect it before promotion');+ if (compareReleaseVersions(version, record.version) > 0) {+ const publication = { ...record, ...plan, phase: 'superseded', promoted: false, currentVersion: version };+ await writeJSON(path.join(directory, 'publication.json'), publication);+ return publication;+ }+ if (version === record.version) assert(previous.bytes.equals(expected), 'Same-version default guide has different bytes');}const publication = { ...record, ...plan, previousSHA256: previous ? createHash('sha256').update(previous.bytes).digest('hex') : null,previousETag: previous?.etag ?? null, phase: 'before-fixed-promotion' };diff --git a/.github/workflows/motion-candidate.yml b/.github/workflows/motion-candidate.ymldeleted file mode 100644index 9a47afdc..00000000--- a/.github/workflows/motion-candidate.yml+++ /dev/null@@ -1,87 +0,0 @@-name: Motion candidate build--on:- workflow_dispatch:- inputs:- source_sha:- description: 'Reviewed full 40-character SHA integrated into feature/motion'- type: string- required: true- version:- description: 'New immutable version, e.g. 0.6.4-test.7'- type: string- required: true--permissions:- contents: read--jobs:- candidate:- if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main'- runs-on: ubuntu-24.04- timeout-minutes: 45- env:- MOTION_SOURCE_SHA: ${{ inputs.source_sha }}- MOTION_VERSION: ${{ inputs.version }}- OPENMOTION_TELEMETRY: '0'- HYPERFRAMES_BROWSER_PATH: /usr/bin/chromium- HYPERFRAMES_FFMPEG_PATH: /usr/bin/ffmpeg- HYPERFRAMES_FFPROBE_PATH: /usr/bin/ffprobe- steps:- - uses: actions/[email protected]- with:- path: control- ref: ${{ github.sha }}- fetch-depth: 0- persist-credentials: false- - uses: actions/setup-node@v6- with:- node-version: '26.11.1'- - name: Validate the immutable integration source- run: |- git -C control fetch origin feature/motion:refs/remotes/origin/feature/motion- node control/.github/scripts/motion-release.mjs source control- - uses: actions/[email protected]- with:- path: source- ref: ${{ inputs.source_sha }}- persist-credentials: false- - name: Scan tracked source before dependency installation- run: |- node control/.github/scripts/motion-scan.mjs install "$RUNNER_TEMP/scanner"- node control/.github/scripts/motion-scan.mjs source source "$RUNNER_TEMP/source-scan.json" "$RUNNER_TEMP/scanner/gitleaks"- - name: Install rendering test tools- run: sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends zip unzip chromium ffmpeg fonts-noto-core- - name: Check the selected source- working-directory: source- run: |- npm ci --no-audit --no-fund- npm run check- npm run typecheck:studio- npm run build:studio- npm run build:tracking- node --experimental-strip-types --test tests/tracking.test.ts tests/install.test.ts tests/npm-installer.test.ts tests/npm-package.test.ts tests/test-package.test.ts tests/source-install.test.ts tests/bootstrap.test.ts tests/mcp-registry.test.ts tests/mcp-runtime.test.ts tests/mcp-upgrade.test.ts tests/preview.test.ts tests/phase1.test.ts tests/preview-handoff.test.ts tests/adapters.test.ts tests/package.test.ts tests/recreate-measure.test.ts tests/workflow.test.ts tests/catalog.test.ts tests/prism-templates.test.ts tests/extension-boundary.test.ts tests/connections.test.ts tests/install-guide.test.ts- npm run test:studio -- --maxWorkers=2- npm run package:phase1- archive="$PWD/dist/motion-$(node -p "require('./package.json').version")-phase1.zip"- node tests/phase1-package.mjs "$archive" "$RUNNER_TEMP/phase1-e2e"- - name: Build the final prod application tgz once and scan both archives- run: |- node source/scripts/package-npm.mjs "$RUNNER_TEMP/build" "$MOTION_VERSION" --template-env=prod- 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: Retain the immutable candidate- uses: actions/[email protected]- with:- name: motion-candidate-${{ github.run_id }}-${{ github.run_attempt }}- path: ${{ runner.temp }}/candidate/- retention-days: 30- if-no-files-found: error- - name: Record candidate identity and acceptance boundary- run: |- node --input-type=module <<'JS'- import { readFileSync, appendFileSync } from 'node:fs';- const c = JSON.parse(readFileSync(process.env.RUNNER_TEMP + '/candidate/candidate.json'));- appendFileSync(process.env.GITHUB_STEP_SUMMARY, `Version: ${c.version}\n\nSource: ${c.sourceCommit}\n\nTGZ SHA256: ${c.tgzSHA256}\n\nArtifact: motion-candidate-${c.workflow.runId}-${c.workflow.attempt}\n\nCandidate only. Native host, real Agent creation and human playback acceptance remain required. Nothing was published.\n`);- JSdiff --git a/.github/workflows/motion-publication-recovery.yml b/.github/workflows/motion-publication-recovery.ymlnew file mode 100644index 00000000..eba6ef89--- /dev/null+++ b/.github/workflows/motion-publication-recovery.yml@@ -0,0 +1,25 @@+name: Motion snapshot recovery++on:+ workflow_dispatch:+ inputs:+ candidate_run_id:+ description: 'Original Motion test release run; package must already exist identically on npm'+ type: string+ required: true++permissions:+ contents: read+ actions: read++jobs:+ recover:+ if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main'+ permissions:+ contents: read+ actions: read+ id-token: write+ uses: ./.github/workflows/motion-publish-test.yml+ with:+ candidate_run_id: ${{ inputs.candidate_run_id }}+ secrets: inheritdiff --git a/.github/workflows/motion-publish-test.yml b/.github/workflows/motion-publish-test.ymlindex 9737abb9..8a2d9948 100644--- a/.github/workflows/motion-publish-test.yml+++ b/.github/workflows/motion-publish-test.yml@@ -1,52 +1,120 @@-name: Motion test publication+name: Motion test release+run-name: Motion test release · ${{ inputs.version || format('snapshot recovery for run {0}', inputs.candidate_run_id) }}on:workflow_dispatch:inputs:- candidate_run_id:- description: 'Successful Motion candidate build run ID'+ version:+ description: 'New test version, e.g. 0.6.4-test.7; build first, publish only after independent acceptance approval'type: stringrequired: true- tgz_sha256:- description: 'Accepted candidate tgz SHA256'+ source_sha:+ description: 'Optional reviewed full SHA already integrated into feature/motion; empty freezes its current head'type: string- required: true- acceptance_sha256:- description: 'SHA256 of the completed internal acceptance record; no internal URL or private content'+ required: false+ default: ''+ workflow_call:+ inputs:+ candidate_run_id:+ description: 'Existing candidate run for snapshot-only recovery; never publishes npm or advances a guide'type: stringrequired: true- action:- description: 'Publish to npm test and promote guide, or only backfill immutable snapshots'- type: choice- options: [publish-test, archive-only]- default: archive-only- approved:- description: 'I approve this exact version/hash after reviewing its acceptance record'- type: boolean- default: falsepermissions:contents: readactions: read-concurrency:- group: motion-test-publication- cancel-in-progress: false-env:- MOTION_CANDIDATE_RUN: ${{ inputs.candidate_run_id }}- MOTION_EXPECTED_SHA256: ${{ inputs.tgz_sha256 }}- MOTION_ACCEPTANCE_SHA256: ${{ inputs.acceptance_sha256 }}- MOTION_RELEASE_ACTION: ${{ inputs.action }}- MOTION_APPROVED: ${{ inputs.approved }}+ MOTION_CANDIDATE_RUN: ${{ inputs.candidate_run_id || github.run_id }}+ MOTION_RELEASE_ACTION: ${{ inputs.candidate_run_id != '' && 'archive-only' || 'publish-test' }}jobs:+ candidate:+ name: Build immutable candidate+ if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main' && inputs.candidate_run_id == ''+ runs-on: ubuntu-24.04+ timeout-minutes: 45+ outputs:+ artifact_id: ${{ steps.artifact.outputs.artifact-id }}+ env:+ MOTION_SOURCE_SHA: ${{ inputs.source_sha }}+ MOTION_VERSION: ${{ inputs.version }}+ OPENMOTION_TELEMETRY: '0'+ HYPERFRAMES_BROWSER_PATH: /usr/bin/chromium+ HYPERFRAMES_FFMPEG_PATH: /usr/bin/ffmpeg+ HYPERFRAMES_FFPROBE_PATH: /usr/bin/ffprobe+ steps:+ - uses: actions/[email protected]+ with:+ path: control+ ref: ${{ github.sha }}+ fetch-depth: 0+ persist-credentials: false+ - uses: actions/setup-node@v6+ with:+ node-version: '26.11.1'+ - name: Resolve and freeze the integrated source+ id: source+ run: |+ git -C control fetch origin feature/motion:refs/remotes/origin/feature/motion+ node control/.github/scripts/motion-release.mjs source control+ - uses: actions/[email protected]+ with:+ path: source+ ref: ${{ steps.source.outputs.source_sha }}+ persist-credentials: false+ - name: Scan tracked source before dependency installation+ run: |+ node control/.github/scripts/motion-scan.mjs install "$RUNNER_TEMP/scanner"+ node control/.github/scripts/motion-scan.mjs source source "$RUNNER_TEMP/source-scan.json" "$RUNNER_TEMP/scanner/gitleaks"+ - name: Install rendering test tools+ run: sudo apt-get update -qq && sudo apt-get install -y -qq --no-install-recommends zip unzip chromium ffmpeg fonts-noto-core+ - name: Check the selected source+ working-directory: source+ run: |+ npm ci --no-audit --no-fund+ npm run check+ npm run typecheck:studio+ npm run build:studio+ npm run build:tracking+ node --experimental-strip-types --test tests/tracking.test.ts tests/install.test.ts tests/npm-installer.test.ts tests/npm-package.test.ts tests/test-package.test.ts tests/source-install.test.ts tests/bootstrap.test.ts tests/mcp-registry.test.ts tests/mcp-runtime.test.ts tests/mcp-upgrade.test.ts tests/preview.test.ts tests/phase1.test.ts tests/preview-handoff.test.ts tests/adapters.test.ts tests/package.test.ts tests/recreate-measure.test.ts tests/workflow.test.ts tests/catalog.test.ts tests/prism-templates.test.ts tests/extension-boundary.test.ts tests/connections.test.ts tests/install-guide.test.ts+ npm run test:studio -- --maxWorkers=2+ npm run package:phase1+ archive="$PWD/dist/motion-$(node -p "require('./package.json').version")-phase1.zip"+ node tests/phase1-package.mjs "$archive" "$RUNNER_TEMP/phase1-e2e"+ - name: Build the final prod application tgz once and scan both archives+ env:+ MOTION_SOURCE_SHA: ${{ steps.source.outputs.source_sha }}+ run: |+ node source/scripts/package-npm.mjs "$RUNNER_TEMP/build" "$MOTION_VERSION" --template-env=prod+ 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: Retain the immutable candidate+ id: artifact+ uses: actions/[email protected]+ with:+ name: motion-candidate-${{ github.run_id }}-${{ github.run_attempt }}+ path: ${{ runner.temp }}/candidate/+ retention-days: 30+ if-no-files-found: error+ - name: Show download, isolated install and acceptance instructions+ run: |+ node --input-type=module <<'JS'+ import { readFileSync, appendFileSync } from 'node:fs';+ const c = JSON.parse(readFileSync(process.env.RUNNER_TEMP + '/candidate/candidate.json'));+ 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.workflow.runId}-${c.workflow.attempt}](${run}#artifacts) and extract it.\n\nApply the isolated host/profile, application home, project data and Skills paths from docs/npm-installation.md, then use this local package (select your actual host):\n\n\`npx --yes --package "./${c.tgz}" openmotion setup --host HOST\`\n\nRepeat the same package and explicit home for prepare. Never accept through the unpublished registry version.\n\nComplete the generated acceptance.md internally, including install, templates, real Agent creation, edit/export and human audio/video playback. The independent reviewer then opens Review deployments, checks this exact candidate and enters only PASS in the approval comment. Do not paste internal links or test material. Reject if acceptance failed. Nothing has been published yet.\n`);+ JS+verify:- if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main'+ needs: candidate+ if: ${{ always() && !cancelled() && github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main' && (needs.candidate.result == 'success' || (inputs.candidate_run_id != '' && needs.candidate.result == 'skipped')) }}runs-on: ubuntu-24.04timeout-minutes: 15outputs:artifact_id: ${{ steps.artifact.outputs.artifact-id }}+ tgz_sha256: ${{ steps.download.outputs.tgz_sha256 }}steps:- uses: actions/[email protected]with:@@ -56,14 +124,21 @@ jobs:- uses: actions/setup-node@v6with:node-version: '26.11.1'- - name: Verify originating run, artifact digest, version and source; rescan+ - name: Verify successful candidate producer and download its immutable artifact+ id: download+ env:+ GH_TOKEN: ${{ github.token }}+ MOTION_CANDIDATE_ARTIFACT_ID: ${{ needs.candidate.outputs.artifact_id }}+ run: node .github/scripts/motion-release.mjs download "$RUNNER_TEMP/candidate"+ - name: Recheck source, archives and protected publication configurationenv:GH_TOKEN: ${{ github.token }}+ MOTION_EXPECTED_SHA256: ${{ steps.download.outputs.tgz_sha256 }}run: |- node .github/scripts/motion-release.mjs download "$RUNNER_TEMP/candidate"git fetch origin feature/motion:refs/remotes/origin/feature/motionnode .github/scripts/motion-scan.mjs install "$RUNNER_TEMP/scanner"node .github/scripts/motion-release.mjs rescan "$RUNNER_TEMP/candidate" "$PWD" "$RUNNER_TEMP/scanner/gitleaks"+ node .github/scripts/motion-release.mjs environment "$RUNNER_TEMP/candidate"- uses: actions/[email protected]id: artifactwith:@@ -71,10 +146,26 @@ jobs:path: ${{ runner.temp }}/candidate/retention-days: 30if-no-files-found: error+ - name: Show the existing candidate for snapshot recovery approval+ if: inputs.candidate_run_id != ''+ run: |+ node --input-type=module <<'JS'+ import { readFileSync, appendFileSync } from 'node:fs';+ const c = JSON.parse(readFileSync(process.env.RUNNER_TEMP + '/candidate/candidate.json'));+ appendFileSync(process.env.GITHUB_STEP_SUMMARY, `## Snapshot recovery requires independent approval\n\nVersion: ${c.version}\n\nSource: ${c.sourceCommit}\n\nTGZ SHA256: ${c.tgzSHA256}\n\nOriginal candidate: https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${c.workflow.runId}\n\nReview the retained identity and existing npm publication, then approve with PASS or reject. Recovery never publishes npm or changes the default guide.\n`);+ JSnpm:+ if: ${{ always() && !cancelled() && needs.verify.result == 'success' }}+ env:+ MOTION_EXPECTED_SHA256: ${{ needs.verify.outputs.tgz_sha256 }}needs: verify- environment: motion-test-publish+ concurrency:+ group: motion-npm-test+ cancel-in-progress: false+ environment:+ name: motion-test-publish+ url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifactsruns-on: ubuntu-24.04timeout-minutes: 15outputs:@@ -98,6 +189,10 @@ jobs:github-token: ${{ github.token }}run-id: ${{ github.run_id }}path: ${{ runner.temp }}/candidate+ - name: Record the independent acceptance approval+ env:+ GH_TOKEN: ${{ github.token }}+ run: node .github/scripts/motion-release.mjs approval "$RUNNER_TEMP/candidate"- name: Publish the accepted bytes with npm trusted publishing, or verify an identical existing versionrun: node .github/scripts/motion-release.mjs npm "$RUNNER_TEMP/candidate"- name: Retain npm publication state even after a partial failure@@ -106,11 +201,16 @@ jobs:uses: actions/[email protected]with:name: npm-publication-${{ github.run_id }}-${{ github.run_attempt }}- path: ${{ runner.temp }}/candidate/npm-publication.json+ path: |+ ${{ runner.temp }}/candidate/npm-publication.json+ ${{ runner.temp }}/candidate/approval.jsonretention-days: 30if-no-files-found: warnregistry-mac:+ if: ${{ always() && !cancelled() && needs.verify.result == 'success' && needs.npm.result == 'success' }}+ env:+ MOTION_EXPECTED_SHA256: ${{ needs.verify.outputs.tgz_sha256 }}needs: [verify, npm]runs-on: macos-26timeout-minutes: 40@@ -145,6 +245,9 @@ jobs:if-no-files-found: warnregistry-windows:+ if: ${{ always() && !cancelled() && needs.verify.result == 'success' && needs.npm.result == 'success' }}+ env:+ MOTION_EXPECTED_SHA256: ${{ needs.verify.outputs.tgz_sha256 }}needs: [verify, npm]runs-on: windows-2025timeout-minutes: 40@@ -179,8 +282,14 @@ jobs:if-no-files-found: warnsnapshot:+ if: ${{ always() && !cancelled() && needs.verify.result == 'success' && needs.npm.result == 'success' && needs.registry-mac.result == 'success' && needs.registry-windows.result == 'success' }}+ concurrency:+ group: motion-install-guide-test+ cancel-in-progress: false+ env:+ MOTION_EXPECTED_SHA256: ${{ needs.verify.outputs.tgz_sha256 }}+ MOTION_INSTALL_PUBLIC_ORIGIN: ${{ vars.CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN }}needs: [verify, npm, registry-mac, registry-windows]- environment: motion-test-publishruns-on: ubuntu-24.04timeout-minutes: 15steps:@@ -237,3 +346,13 @@ jobs:${{ runner.temp }}/candidate/previous-install.mdretention-days: 30if-no-files-found: warn+ - name: Show the exact-version result and default guide status+ if: success()+ run: |+ node --input-type=module <<'JS'+ import { readFileSync, appendFileSync } from 'node:fs';+ const c = JSON.parse(readFileSync(process.env.RUNNER_TEMP + '/candidate/candidate.json'));+ const a = JSON.parse(readFileSync(process.env.RUNNER_TEMP + '/candidate/release-attempt.json'));+ const origin = process.env.MOTION_INSTALL_PUBLIC_ORIGIN;+ appendFileSync(process.env.GITHUB_STEP_SUMMARY, `## Test publication result\n\nVersion: ${c.version}\n\nSource: ${c.sourceCommit}\n\nResult: ${a.stage}\n\n[Exact-version installation guide](${origin}/open-motion/dev/${c.version}/install.md)\n\n[Default test guide](${origin}/open-motion/dev/install.md)\n\nThe default is advanced only after registry/native checks and public readback; a superseded candidate keeps its version snapshot without moving the default. No stable release occurred.\n`);+ JSdiff --git a/AGENTS.md b/AGENTS.mdindex 5faf7a4c..d0c7f9ec 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -45,6 +45,6 @@ Phase one exposes eleven motion_ Tools (nine project tools plus catalog fetch an## Candidate and publication controls-Follow [the release workflow manual](docs/release-workflows.md). Public candidates must use an exact reviewed source SHA integrated into `feature/motion`, a new test version and prod template defaults. Scan tracked source plus the outer npm tgz and inner application; preserve the positive distribution list and licenses. Keep candidate, native registry installation, real Agent creation and human acceptance evidence separate.+Follow [the release workflow manual](docs/release-workflows.md): one daily build/accept/approve entry and a separate snapshot-only recovery entry. Keep full acceptance evidence private; independent reviewers authorize the frozen candidate through the protected npm job, without manually copying hashes. Public candidates must use an exact reviewed source SHA integrated into `feature/motion`, a new test version and prod template defaults. Scan tracked source plus the outer npm tgz and inner application; preserve the positive distribution list and licenses. Keep candidate, native registry installation, real Agent creation and human acceptance evidence separate.Publication uses the accepted candidate bytes, never a rebuild. Only the separately authorized manual test publication workflow may use npm OIDC or R2 credentials; validate candidate provenance and hashes first, archive immutable version records, and update the moving guide last. Archive-only work must not move tags or default entries. Never overwrite published versions, put private DEV data/internal acceptance material into public artifacts, or infer merge/publication authorization from green CI. Main registration, environment protection, npm trust, main cutover and repository rename remain separate operations.diff --git a/CLAUDE.md b/CLAUDE.mdindex ca8d776d..0ee61cd6 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -4,6 +4,6 @@ Read and follow [AGENTS.md](AGENTS.md) before working in this repository. It is## Candidate and publication controls-Follow [the release workflow manual](docs/release-workflows.md). Public candidates must use an exact reviewed source SHA integrated into `feature/motion`, a new test version and prod template defaults. Scan tracked source plus the outer npm tgz and inner application; preserve the positive distribution list and licenses. Keep candidate, native registry installation, real Agent creation and human acceptance evidence separate.+Follow [the release workflow manual](docs/release-workflows.md): one daily build/accept/approve entry and a separate snapshot-only recovery entry. Keep full acceptance evidence private; independent reviewers authorize the frozen candidate through the protected npm job, without manually copying hashes. Public candidates must use an exact reviewed source SHA integrated into `feature/motion`, a new test version and prod template defaults. Scan tracked source plus the outer npm tgz and inner application; preserve the positive distribution list and licenses. Keep candidate, native registry installation, real Agent creation and human acceptance evidence separate.Publication uses the accepted candidate bytes, never a rebuild. Only the separately authorized manual test publication workflow may use npm OIDC or R2 credentials; validate candidate provenance and hashes first, archive immutable version records, and update the moving guide last. Archive-only work must not move tags or default entries. Never overwrite published versions, put private DEV data/internal acceptance material into public artifacts, or infer merge/publication authorization from green CI. Main registration, environment protection, npm trust, main cutover and repository rename remain separate operations.diff --git a/docs/product/architecture.md b/docs/product/architecture.mdindex a736478b..8e611193 100644--- a/docs/product/architecture.md+++ b/docs/product/architecture.md@@ -187,7 +187,7 @@ Explicit test/stable prod builds produce publishable artifact metadata with test## 演进约束-The application npm format is the default; complete platform ZIPs are backups. Ordinary PR CI scans tracked source and both npm archive layers without publication credentials. Two manual controls implement candidate build and test publication: a fixed integrated source SHA produces one immutable prod candidate; publication verifies its originating workflow, hashes and acceptance-record digest, publishes the same tgz to npm test, runs anonymous native registry checks on separate Mac/Windows runners, and archives version snapshots before conditionally advancing the default guide. Snapshot-only recovery does not move the default. Private DEV template artifacts remain outside these public workflows. Stable publication is a separate authorized process. Trusted default-branch registration, a protected publication environment and npm OIDC setup remain administrator prerequisites, not enabled by this feature PR. Build, native installation, real Agent creation and human playback remain separate evidence. See [release workflows](../release-workflows.md) and [package checks](../test-packages.md).+The application npm format is the default; complete platform ZIPs are backups. Ordinary PR CI scans tracked source and both npm archive layers without publication credentials. One manual test-release entry resolves a fixed integrated source SHA, builds one immutable prod candidate and generated acceptance checklist, then pauses at a protected independent approval. Source/artifact/hash identity flows automatically between successful jobs; the approval receipt records run-scoped GitHub review history while full acceptance evidence stays private. After approval, the same tgz is published to npm test, checked anonymously on separate Mac/Windows runners and archived before conditionally advancing the default guide. Candidate production may complete while the overall release is still awaiting approval; origin validation checks the successful producer job and exact artifact attempt rather than requiring a finished release run. Builds can continue during acceptance; job-level publication serialization, version checks and ETag writes prevent late older candidates from rolling the moving entry backward. Snapshot-only recovery does not move the default. Private DEV template artifacts remain outside these public workflows. Stable publication is a separate authorized process. Trusted default-branch registration, a protected publication environment and npm OIDC setup remain administrator prerequisites, not enabled by this feature PR. Build, native installation, real Agent creation and human playback remain separate 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. Stable version construction and URL contracts exist; a stable candidate/publication workflow is not implemented.diff --git a/docs/release-guide.md b/docs/release-guide.mdindex dfee5d0d..6f7c3baa 100644--- a/docs/release-guide.md+++ b/docs/release-guide.md@@ -62,7 +62,7 @@ Each defect needs exact package/source/OS/host/environment/catalog identity, proOrdinary npm/prod CI builds generate a **candidate-only** guide and retain it as an Actions artifact for 14 days. The publisher rejects candidate previews. DEV/private packages cannot produce a public guide.-Maintainers now use the two separate manual entries described in [candidate build and test publication](release-workflows.md). The candidate entry has no publication credentials; the test publication entry accepts the candidate run/hash and completed acceptance-record digest, verifies the same bytes, performs anonymous native registry installation and archives snapshots before updating the moving test guide. The former CI guide-only upload route is removed so it cannot bypass these gates. Ordinary PR CI remains read-only.+Maintainers use the single [build, accept and approve entry](release-workflows.md): enter a test version, download its frozen candidate and generated acceptance checklist, then independently approve the protected npm job. Candidate identity and hashes are passed automatically; the reviewer keeps completed evidence internally and enters only PASS in the public approval comment. The same accepted bytes receive anonymous native registry checks and immutable snapshots before the moving test guide can advance. Snapshot-only recovery is a separate maintenance entry. The former CI guide-only upload route is removed so it cannot bypass these gates. Ordinary PR CI remains read-only.These manual entries support test versions only. Stable package construction and the stable URL contract exist, but stable candidate/publication/channel promotion still require a separate implementation and authorization. Partial retries retain the actual successful producer artifact IDs; automatic npm provenance is disabled for prebuilt candidates while OIDC authentication remains enabled. See the workflow manual for the source/hash evidence and recovery limits.diff --git a/docs/release-workflows.md b/docs/release-workflows.mdindex 04fa354c..0cf5f7fc 100644--- a/docs/release-workflows.md+++ b/docs/release-workflows.md@@ -1,105 +1,106 @@-# Manual candidate and test publication workflows+# Motion test release: build, accept, approve-These workflows implement controlled delivery of the complete `@openmotion/app` npm application. They do not run on a push, PR merge, tag or schedule. This feature PR does not enable them on the default branch, configure npm trust, publish anything, change `main` or rename the repository.+The daily entry is **Actions → Motion test release → Run workflow**. It builds a complete `@openmotion/app` candidate, pauses at one protected environment approval, then publishes those same bytes. It never runs on pushes, PR merges, tags or a schedule. This implementation does not register workflows on `main`, configure repository/npm permissions, publish a package or switch the product main branch.-| Capability | Test version | Stable version |-| --- | --- | --- |-| Package builder | Supports `X.Y.Z-test.N[.N]` | Supports `X.Y.Z` |-| Manual candidate and publication workflows | Implemented here; require administrator enablement | Not implemented |-| npm channel | `test` | Planned: verify under `stage`, then separately authorize `latest` |-| Hosted guide paths | Test moving/versioned paths | Stable moving/versioned paths supported by the storage helper; no stable publication job |+| Operator step | Automated work |+| --- | --- |+| Enter a new version and run | Freeze the current `feature/motion` SHA, check/build/scan once, retain the candidate and show download/install instructions |+| Download and accept the candidate | Retain the exact package identity and generate `acceptance.md`; no publication yet |+| Independently approve with `PASS` | Publish the accepted tgz to npm `test`, perform native registry checks, archive version snapshots and update the default guide last |-Both public channels use prod template defaults. A test software version does not select private DEV templates. Stable acceptance rules exist in [the acceptance guide](release-guide.md); they are not an automated stable release pipeline.+Public test software uses **prod templates**. A URL containing `dev` selects the test software channel, not private DEV template data. Stable version construction and URL contracts exist, but a stable release workflow is not implemented.-## Administrator setup before first use+## First-time administrator setup-The current default `main` contains the legacy project. GitHub requires a manual workflow to be registered on the default branch before showing its Run workflow entry. Register the reviewed release controls on `main` through a separately authorized PR; do not copy the Motion application or force-push its history. Both entries must run with **Use workflow from: main**. Feature-branch invocations fail closed.+The default `main` currently contains the legacy project. GitHub must register these reviewed control files on the default branch through a separately authorized PR before the manual entries are available. This registration does not copy the Motion application onto `main` or rewrite its history. Always select **Use workflow from: main**.-The minimal registration includes:+Register these files together:-- `.github/workflows/motion-candidate.yml` and `motion-publish-test.yml`.+- `.github/workflows/motion-publish-test.yml` and `motion-publication-recovery.yml`; remove an older `motion-candidate.yml` registration if one exists.- `.github/scripts/motion-release.mjs`, `motion-scan.mjs`, `motion-registry-smoke.mjs`, `publish-install-guide.mjs` and `.github/gitleaks.toml`.-- `scripts/runtime-assets.mjs`, `release-version.mjs`, `install-guide.mjs` and `docs/install.md`.+- `scripts/runtime-assets.mjs`, `release-version.mjs`, `install-guide.mjs`, `docs/install.md` and `docs/templates/release-record.md`.-Protect changes to these trusted files and `main`. Create the **`motion-test-publish` GitHub Environment**, restrict deployment branches to `main`, require an independent reviewer and prevent self-review. Referencing an environment in YAML does not configure those protections: GitHub can create an unprotected environment automatically. Verify the rejection/approval behavior before enabling publication.+Protect changes to the trusted control files and `main`. Configure the **`motion-test-publish` GitHub Environment** with required independent reviewers, **prevent self-review**, **disable administrator bypass**, and allow exactly the `main` **branch** (no tag or wildcard policy). The workflow checks these actual settings before it can request approval and again inside the protected npm job. A missing or unprotected environment fails closed; naming an environment in YAML alone does not configure it. Test both rejection and approval before enabling real publication.-In npm package settings for `@openmotion/app`, configure a GitHub trusted publisher for owner `nexu-io`, repository `html-anything`, workflow `motion-publish-test.yml`, environment `motion-test-publish`, allowing **publish**. The workflow uses GitHub-hosted runners and Node 26.11.1/npm 11.20.0 with `id-token: write`; it does not require a stored npm token. Do not grant tag-management actions for this workflow. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).+For `@openmotion/app`, configure npm trusted publishing for owner `nexu-io`, repository `html-anything`, workflow **`motion-publish-test.yml`**, environment **`motion-test-publish`**, allowing publish. The workflow uses GitHub-hosted runners, Node 26.11.1/npm 11.20.0 and `id-token: write`; no stored npm token is needed. Do not grant tag-management actions. The recovery caller is not an npm trusted publisher and never calls npm publish. See [npm trusted publishing](https://docs.npmjs.com/trusted-publishers/).-Keep the existing R2 settings; only the final snapshot step receives the credentials:+Reuse the existing R2 settings. Only the final snapshot step receives the storage credentials:-| Setting | Value or role |+| Setting | Role || --- | --- || Secrets `CLOUDFLARE_R2_RELEASES_AK`, `CLOUDFLARE_R2_RELEASES_SK` | Bucket-scoped S3 write credentials || Variable `CLOUDFLARE_R2_RELEASES_BUCKET` | `open-design-releases` |-| Variable `CLOUDFLARE_R2_RELEASES_URL` | The approved R2 S3 HTTPS origin |+| Variable `CLOUDFLARE_R2_RELEASES_URL` | Approved R2 S3 HTTPS origin || Variable `CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN` | `https://releases.open-design.ai` |-Protect publication control changes as well as the environment. The application source is checked out separately at its selected SHA. Neither that source nor the downloaded application executes in a credentialed job. Native installation runs in separate jobs without npm/R2 credentials or OIDC permission.+## 1. Build-## 1. Build a candidate without publication+Open **Motion test release → Run workflow**, select `main` and fill in **version**, for example `0.6.4-test.7`. Use a new `MAJOR.MINOR.PATCH-test.N[.N]`; never change bytes under an existing published version.-After review and integration into `feature/motion`, open **Actions → Motion candidate build → Run workflow**. Select `main` for the workflow and supply:+Normally leave **source_sha** empty. The build fetches `feature/motion`, resolves its current full SHA once, records it and checks out exactly that SHA. To test a particular reviewed integrated commit, supply its full 40-character SHA. A later branch update cannot silently change this candidate. Confirm the chosen source has completed the required integration review.-| Input | Example | Requirement |-| --- | --- | --- |-| `source_sha` | A full 40-character Git SHA | Already integrated into `feature/motion`; not a mutable branch name |-| `version` | `0.6.4-test.7` | New `MAJOR.MINOR.PATCH-test.N[.N]`; never reuse a version for changed bytes |+The build scans tracked source before dependency installation, runs the technical checks/Studio regression/eleven-Tool ZIP E2E, builds the final prod npm tgz once and scans its outer and inner archives. It does not have npm OIDC or R2 credentials. Successful output is retained as `motion-candidate-<run-id>-<attempt>` for **30 days**.-The trusted workflow validates ancestry, scans tracked source before installing dependencies, runs the technical checks/Studio regressions/eleven-Tool ZIP E2E, and builds the final npm tgz **once** with prod template defaults. It scans both the outer npm package and its inner application archive, then freezes the guide and records.+The artifact contains eight files: `openmotion-app-<version>.tgz`, `release-npm.json`, `source-scan.json`, `package-scan.json`, `install.md`, `install-record.json`, `acceptance.md` and `candidate.json`. The schema-2 candidate records source/control SHA, producer run/attempt and file hashes. Its acceptance state remains `not-performed`. The generated checklist has the machine identity filled in and human results set to `NOT RUN`.-Download the `motion-candidate-<run-id>-<attempt>` Actions artifact within its **30-day retention**. Preserve it in the internal acceptance record before expiry; an expired candidate cannot be published through this entry and must be rebuilt under a new version. Artifacts in this public repository are not an internal-data channel.+The frozen `install.md` pins a registry version which is not published yet. Do not hand it out as a working npm installation link before publication.-The artifact has seven files: the complete `openmotion-app-<version>.tgz`, `release-npm.json`, `source-scan.json`, `package-scan.json`, `install.md`, `install-record.json` and `candidate.json`. The latter records source/workflow SHA, run/attempt, package SHA256, npm SHA512 integrity and every file hash. Its acceptance state is `not-performed`. The frozen guide is intended for publication **after npm succeeds**; do not distribute it as a working registry entry before publication.+## 2. Accept the downloaded package-The run summary gives the source/version/hash for reviewers. Build success is technical evidence, not an acceptance approval. Use [the acceptance checklist](release-guide.md) to install that tgz in isolated profiles, test upgrades, templates, real Agent creation and human audiovisual playback. Record PASS / FAIL / NOT RUN, supported OS/host, known issues, owner and prior usable version. Keep the accepted artifact byte-for-byte; do not rebuild it for publication.+Open the run summary and download/extract its candidate artifact. Follow the isolated profile, application home, project data and Skills recipes in [npm installation](npm-installation.md). Use the **local tgz**, replacing `HOST` with the actual selected supported host:-## 2. Publish the accepted test candidate+```sh+npx --yes --package "./openmotion-app-0.6.4-test.7.tgz" openmotion setup --host HOST+npx --yes --package "./openmotion-app-0.6.4-test.7.tgz" openmotion prepare+```-Use [the record template](templates/release-record.md). Export the completed internal acceptance record as a fixed UTF-8 file, keep it internally, and calculate its SHA256 (`shasum -a 256 acceptance.md`, or PowerShell `Get-FileHash acceptance.md -Algorithm SHA256`). This digest links public release identity to the retained private acceptance evidence; it does not itself prove that testing happened. The environment reviewer must inspect the actual record.+These short commands require the isolation options/environment from the platform recipe first. Repeat the same explicit application home on setup and prepare. Do not use the unpublished npm version or your normal daily Agent profile for candidate acceptance. Copy the one tgz into a clean consumer directory; its application is embedded and needs no source checkout or sidecar archive.-Open **Actions → Motion test publication → Run workflow**, use `main`, and supply:+Complete the generated **`acceptance.md` privately**: record PASS / FAIL / NOT RUN, supported OS/host, template/catalog identity, existing-data preservation, real Agent creation/edit/export, normal-speed human audio/video playback, known issues and recovery. [The acceptance guide](release-guide.md) defines the checks. Build success cannot fill the human results. Keep that completed evidence against the generated candidate identity; do not edit or re-upload the frozen public candidate artifact. No run ID, tgz hash or private-record hash needs to be typed into a second release form.-| Input | Meaning |-| --- | --- |-| `candidate_run_id` | Successful trusted candidate build run ID; the current successful attempt is selected |-| `tgz_sha256` | Exact accepted SHA256 from that candidate |-| `acceptance_sha256` | Digest of the completed, retained internal acceptance record; no private URLs or logs |-| `action` | `publish-test` to publish/promote; default `archive-only` only fills snapshots for an already published identical version |-| `approved` | Explicitly check after reviewing this exact identity; defaults to false |+## 3. Approve once-An independent environment reviewer approves the protected jobs. A rerun or workflow invocation is publication authorization and must be treated accordingly. Do not run the workflow merely to check its configuration.+The npm job waits at **Review deployments → motion-test-publish**. An independent configured reviewer inspects this run's exact version/source/hash and the internally retained acceptance record. If required checks failed or remain incomplete, reject. If accepted, enter only **`PASS`** in the approval comment and approve. The comment is a public, non-sensitive authorization signal; never paste internal URLs, logs, credentials or user material there.-The pipeline then:+The protected job rechecks the environment and reads GitHub's review history. It requires an independent approved review with that exact comment. The receipt records actual reviewer logins, the observed time and a review-history digest, not the triggering operator as the approver. GitHub's history is run-scoped and has no per-review timestamp/attempt binding: the receipt says so, and the environment gate enforces approval for the job execution. The receipt does not prove that the private tests happened or cryptographically attest the private acceptance document. Keep the completed internal record.-1. Verifies the originating repository, manual workflow/main ref, successful run/attempt, GitHub artifact digest and all candidate hashes; rechecks integrated source ancestry and rescans source plus both archives using the trusted control policy.-2. In the protected npm job, publishes **only the accepted tgz bytes** with `--tag test --ignore-scripts --provenance=false`. An existing identical version resumes without another publish; a different integrity fails. `archive-only` requires an existing identical version and never changes npm tags.-3. On separate macOS 26 arm64 and Windows Server 2025 x64 runners, downloads the exact registry version anonymously using empty npm configs and a fresh cache, verifies SHA256/SHA512, installs a pinned Codex CLI into a temporary prefix, runs isolated setup/repeat setup, prepares Chromium/FFmpeg/ffprobe, and checks MCP Tools/resources and installed Skill files. This is native technical acceptance; Windows Server results do not replace Windows desktop/real model/human playback acceptance. No model credentials are provided.-4. Requires both platform reports, confirms exact registry identity and test tag, rejects an unexpected `latest` change, then writes immutable R2 snapshots and checks the **canonical public bytes**. Only after all of these succeed does `publish-test` conditionally advance the default test guide using its prior ETag. `archive-only` never reads or writes the default guide.+After approval the workflow automatically:-The workflow does not move `latest`, publish a stable version, create a GitHub Release, announce a release or update installed clients. Keep the package pinned by exact version in every guide. Node/Agent and checked native downloads remain prerequisites as documented in [installation](npm-installation.md).+1. Publishes only the accepted tgz with `--tag test --ignore-scripts --provenance=false`, or verifies an already published identical version. It rejects an older test version than the current npm test channel and never overwrites different bytes.+2. On separate macOS arm64 and Windows x64 runners without publication credentials, anonymously downloads the exact registry version, verifies its hashes, prepares Chromium/FFmpeg/ffprobe, runs isolated setup/repeat setup and checks the eleven Tools/resources and five Skills. These are native technical checks, not real-model or human playback acceptance.+3. Requires both platform reports, archives immutable R2 snapshots and checks canonical public bytes. Only then conditionally advances the default test guide. R2 needs no second approval: it consumes the retained approval from the successful npm job plus both native reports. The snapshot job executes trusted `main` controls and never executes the candidate application.+4. Shows the exact version, publication phase, versioned installation guide and default guide in the run summary.-OIDC still authenticates the publisher. Automatic npm provenance is explicitly disabled: it would describe the publication workflow's `main` SHA, while the accepted application was built from a different selected source SHA. `candidate.json`, the embedded manifest, source/lock hashes and the immutable release record provide the actual application identity and candidate build reference. These records are not a signed build-provenance attestation. Supporting such an attestation requires a separate implementation that binds the real candidate build and its inputs; do not substitute the workflow SHA or rewrite GitHub's source context.+OIDC authenticates the publisher. Automatic npm provenance remains disabled because this trusted control workflow's `main` SHA differs from the selected application source SHA. Candidate/manifest/lock/hash records provide traceability, not a signed build attestation.-## Immutable snapshots and moving entries+## Versions and records| Channel | Moving guide, updated last | Immutable guide || --- | --- | --- |-| Test software with prod templates | `/open-motion/dev/install.md` | `/open-motion/dev/<version>/install.md` |-| Stable software with prod templates | `/open-motion/install.md` | `/open-motion/<version>/install.md` |+| Test software, prod templates | `/open-motion/dev/install.md` | `/open-motion/dev/<version>/install.md` |+| Stable software, prod templates | `/open-motion/install.md` | `/open-motion/<version>/install.md` |++This workflow does not publish stable versions or move npm `latest`. The storage helper supports stable paths without providing a stable publication job. Existing legacy `/versions/<version>/install.md` objects remain immutable.++Each test version also archives the exact tgz, manifests, blank generated acceptance checklist, scans, candidate identity, both platform reports and the schema-2 release record. The release record contains package/source identity and the run-scoped approval receipt. Completed private acceptance material is never uploaded. A previous immutable release record is preserved during snapshot recovery, while the recovery attempt retains its own fresh approval receipt.++Builds and approval waits do not hold a workflow-wide release lock, so another version can build. npm writes and default-guide writes have separate job-level concurrency groups. GitHub concurrency is not a durable FIFO: it retains one running and one newest pending job, so do not enqueue a batch of releases for automatic publication; a displaced run keeps its candidate and can be reviewed/rerun deliberately. Approve one release at a time. A candidate superseded after npm publication can retain version snapshots without moving the default. Default-guide version comparison plus ETag conditional writes prevent a late older completion from rolling a newer entry back; unrecognized or conflicting same-version guide bytes require inspection.++Actions artifacts and attempt records expire after **30 days**. R2 snapshots follow the separately managed bucket lifecycle. Approval does not extend artifact retention. Expired/deleted artifacts fail closed; keep internal evidence before expiry and build a new version when necessary.-The stable path contract is supported by the storage helper; **this PR adds no stable publication workflow**. Existing `/versions/<version>/install.md` bytes remain immutable and are not overwritten. `dev` in a URL means test software, not DEV template data. Public candidate/publish workflows offer no DEV package option. Use the separate local/private DEV instructions for internal templates; environment variables cannot turn network authorization into access.+## Failure and snapshot recovery-Each test version directory additionally archives the exact tgz, manifest, scan reports, `install-record.json`, `candidate.json`, both registry reports and `release-record.json`. No sidecar application download is needed to install the complete npm tgz. The public release record includes source/hash/integrity, candidate workflow identity, acceptance-record digest, approving actor, publication run, platform evidence hashes and timestamp. Never put internal Feishu links, acceptance material or user projects in it.+- Before approval: a scan/build/configuration failure or rejection publishes nothing. Cancel/reject an unwanted candidate. Fix code under a new version when bytes change.+- After approval: npm may already be public if a native or R2 stage fails. The default guide remains unchanged until its checks pass. Inspect retained npm state and release-attempt/publication files; do not rebuild or blindly republish.+- Use **Re-run failed jobs** for a partial failure. Consumers use successful producer artifact IDs rather than guessing their own attempt. A retry of the protected npm job requires approval again; a snapshot-only retry continues under its retained successful approval. **Re-run all jobs rebuilds the candidate** and requires renewed acceptance; do not use it to resume already-published changed bytes.+- **Motion snapshot recovery** is a separate maintenance entry. Select `main`, enter the original daily release run ID and independently approve its existing candidate. It skips the build, requires an already published identical npm version, repeats native checks and fills missing immutable snapshots. It never publishes npm, moves npm tags or accesses the moving guide. If the latest candidate-producing attempt is failed, ambiguous, expired or incompatible, it stops rather than guessing another artifact.+- Version writes use conditional create and byte comparison. Same bytes resume; different immutable bytes stop. A public readback error blocks promotion. A failure after `fixed-write-attempted` may mean the moving write completed: inspect storage and its canonical URL before retrying.+- An unexpected npm `latest` change stops promotion. This workflow does not silently repair tags. Channel rollback is a separate reviewed operation and does not downgrade installed clients or restore their data.-Actions retains each npm publication state and R2 attempt/prior default instructions for 30 days. R2 version snapshots persist under the bucket's separately managed lifecycle; do not apply an expiry policy without an agreed retention decision. The original candidate artifact must still exist for a publication retry.+Source/package scans are not a scan of every historical Git object or business classification of all binary assets; reviewers still check content, dependencies, licenses and telemetry boundaries. The historical `0.6.4-test.6` predates these candidate records: do not invent a trusted run for it or republish it to fill this format.-## Failure, retry and recovery+## Validation before activation-- A failed source/package scan blocks the candidate or publication before credentials are used. Gitleaks 8.30.1 is checksum-pinned; source-controlled ignore files and inline allow markers cannot bypass the trusted policy. Reports expose rule/path/line, never matched secrets. Targeted rules also reject private files, internal links and personal paths. Narrow exceptions cover the already public DEV routing hostname, synthetic redaction fixtures and the exact approved public analytics ingestion identifier. Scans cover the selected source tree and final package, **not all historical Git objects** or business classification of every binary asset; reviewers still inspect content, dependencies and licenses.-- npm success followed by registry/platform/R2 failure leaves the default guide unchanged. Inspect `npm-publication.json`, the failed job and `release-attempt.json`/`publication.json`. The npm version may already be public; do not rebuild, overwrite or blindly republish it. Rerun with the same candidate/hash/acceptance digest after fixing infrastructure. If bytes change, start a new version.-- GitHub's **Re-run failed jobs** and **Re-run all jobs** are supported. Verify, npm and each native platform expose their actual immutable upload ID as a job output. A downstream retry downloads those retained producer IDs within the same workflow run instead of guessing names from its own attempt number. Mac and Windows have separate outputs, so a failed Mac check can rerun while retaining the successful Windows report. Each attempt still creates new artifacts; previous attempts and the original candidate are not overwritten. Expired/deleted producer artifacts fail the download rather than falling back to another package.-- Snapshot writes use conditional create and byte comparison. Identical existing objects resume; any different version object stops the run. A CDN readback failure stops promotion. A failure after `fixed-write-attempted` may mean the default write completed: inspect storage and canonical URL before recovery.-- `archive-only` is for an identical existing npm version and missing immutable snapshots. It does not restore a missing npm `test` tag or roll back a moving guide. Those are separate reviewed channel/recovery actions. An unexpected `latest` change requires investigation; this workflow does not silently remove or rewrite it.-- Reverting a guide or npm tag does not downgrade clients or restore project data. Use an accepted compatible reinstall or retained backup according to [recovery](release-guide.md#recovery-and-feedback). If no compatible prior version exists, state that.+Run the repository's release/scanner/guide tests and actionlint. Their no-publication rehearsal uses temporary candidate files and simulated GitHub/npm/R2 responses to test the whole transition and failures. It does **not** exercise hosted approval policy, npm OIDC, real registry installation or CDN routing.-The currently published `0.6.4-test.6` predates these candidate records. Its historical evidence remains in the acceptance guide; do not fabricate a new trusted candidate run or republish it merely to fill the new format.+After separately authorized default-branch/environment/npm setup, first run a new candidate and reject its deployment to verify that no publication occurs. A positive hosted rehearsal that proceeds beyond approval is a real publication and requires explicit release authorization. Ordinary PR CI remains credential-free. This implementation PR alone enables none of those administrative actions.diff --git a/docs/templates/release-record.md b/docs/templates/release-record.mdindex 5003ea58..d816d927 100644--- a/docs/templates/release-record.md+++ b/docs/templates/release-record.md@@ -1,14 +1,16 @@# Motion candidate acceptance record-Keep the completed record and attachments internally. Only its SHA256 goes into the public publication workflow. Do not attach user material, credentials, internal URLs or this completed record to public artifacts.+The candidate artifact includes this checklist as `acceptance.md` with its package/source/hash identity already filled. Keep the completed copy and attachments internally. Do not attach user material, credentials, internal URLs or the completed record to public artifacts. No manual file hash is required by the release form.-## Frozen identity+## Generated frozen identity-- Package / exact version:-- Source full SHA / integration PR / review:-- Candidate workflow SHA / run ID / attempt / artifact expiry:-- TGZ filename / size / SHA256 / npm SHA512 integrity:-- Embedded application / manifest / npm lock / native lock hashes:+<!-- CANDIDATE_IDENTITY -->++The release builder replaces this marker. Do not change its generated identity; fill only the tester context and results below. In a source checkout, download the generated checklist from the actual candidate instead.++## Tester context++- Integration PR / source review / artifact expiry:- Template environment / Resource / locale / catalog publication version:- Supported OS / CPU / Node / npm / host versions:- Acceptance owner / independent reviewer / release operator:@@ -36,7 +38,8 @@ Use PASS / FAIL / NOT RUN and link retained evidence. CI success alone cannot fi- Public source/package scans, dependency/license review and telemetry state:- Approved exact version and TGZ SHA256:- Reviewer / date / explicit release authorization:-- Frozen record filename / SHA256 (hash the final file and retain those same bytes):+- Internal retained record revision / filename (keep this private):+- Independent reviewer confirms this exact candidate in Review deployments with the comment `PASS`, or rejects it. Never approve a failed or incomplete required check.## Publication follow-up@@ -46,4 +49,4 @@ Use PASS / FAIL / NOT RUN and link retained evidence. CI success alone cannot fi- Default entry / previous entry / final publication phase:- Failure, recovery or user feedback:-Append follow-up as a separate record linked to the frozen acceptance digest; do not edit the already-hashed approval file in place. Formal publication additionally requires the stable-package checks in the acceptance guide.+Retain the completed acceptance revision; append publication follow-up separately against the same candidate identity. The public release record contains the run-scoped GitHub review receipt, not the private evidence or its digest. That receipt proves an approval was observed, not that every test was performed. Formal publication additionally requires the stable-package checks in the acceptance guide.diff --git a/scripts/release-version.mjs b/scripts/release-version.mjsindex 22022198..e487f0bc 100644--- a/scripts/release-version.mjs+++ b/scripts/release-version.mjs@@ -3,3 +3,18 @@ import assert from 'node:assert/strict';export function checkReleaseVersion(version) {assert.match(version, /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-test\.[1-9]\d*(?:\.[1-9]\d*)*)?$/, 'Use MAJOR.MINOR.PATCH or MAJOR.MINOR.PATCH-test.N[.N]');}++export function compareReleaseVersions(left, right) {+ checkReleaseVersion(left); checkReleaseVersion(right);+ const parts = value => {+ const [core, test] = value.split('-test.');+ return [...core.split('.').map(BigInt), test === undefined ? 1n : 0n, ...(test?.split('.').map(BigInt) || [])];+ };+ const a = parts(left), b = parts(right);+ for (let i = 0; i < Math.max(a.length, b.length); i++) {+ if (a[i] === undefined) return -1;+ if (b[i] === undefined) return 1;+ if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;+ }+ return 0;+}diff --git a/tests/install-guide.test.ts b/tests/install-guide.test.tsindex 54ad5b99..52905052 100644--- a/tests/install-guide.test.ts+++ b/tests/install-guide.test.ts@@ -28,7 +28,8 @@ async function fixture(t: any, candidate = false) {const directory = path.join(root, 'guide'), record = await generateInstallGuide(tgz, directory, candidate);return { directory, record };}-function storage(directory: string, record: any, previous = 'previous accepted instructions') {+const previousGuide = '# Install OpenMotion 0.6.3-test.1\n';+function storage(directory: string, record: any, previous = previousGuide) {const plan = storagePlan(record, config), objects = new Map<string, Buffer>(), writes: any[] = [];objects.set(plan.fixedKey, Buffer.from(previous));const run = async (command: string, args: string[]) => {@@ -74,7 +75,7 @@ test('publication verifies the immutable URL before conditional fixed promotionassert(store.writes[0].args.includes('--if-none-match'));assert(store.writes[1].args.includes('--if-match') && store.writes[1].args.includes('"previous-etag"'));assert(store.writes[1].args.includes('public, max-age=60, must-revalidate'));- assert.equal(await readFile(path.join(directory, 'previous-install.md'), 'utf8'), 'previous accepted instructions');+ assert.equal(await readFile(path.join(directory, 'previous-install.md'), 'utf8'), previousGuide);assert.equal(result.phase, 'verified'); assert(result.previousSHA256);});@@ -84,7 +85,7 @@ test('an immutable version mismatch or failed public version verification leavesawait assert.rejects(publishGuide(directory, config, store), /immutable/); assert.equal(store.writes.length, 0);store.objects.delete(store.plan.versionKey);await assert.rejects(publishGuide(directory, config, { ...store, fetcher: async () => new Response('wrong edge bytes') }), /bytes differ/);- assert.equal(store.objects.get(store.plan.fixedKey)!.toString(), 'previous accepted instructions');+ assert.equal(store.objects.get(store.plan.fixedKey)!.toString(), previousGuide);});test('short version URLs preserve the bytes of an existing immutable legacy URL', async t => {@@ -105,7 +106,7 @@ test('a post-promotion public failure records the partial state and preserves reawait assert.rejects(publishGuide(directory, config, { ...store, fetcher: async (url: URL) => url.pathname.slice(1) === store.plan.versionKey ? store.fetcher(url) : new Response('stale edge bytes') }), /bytes differ/);const state = JSON.parse(await readFile(path.join(directory, 'publication.json'), 'utf8'));assert.equal(state.phase, 'fixed-written-public-unverified');- assert.equal(await readFile(path.join(directory, 'previous-install.md'), 'utf8'), 'previous accepted instructions');+ assert.equal(await readFile(path.join(directory, 'previous-install.md'), 'utf8'), previousGuide);});test('candidate previews, changed guide bytes and unsafe storage destinations cannot publish', async t => {@@ -125,7 +126,26 @@ test('archive-only guide publication never accesses the moving default', async t} });assert.equal(result.promoted, false); assert.equal(result.phase, 'version-verified');assert.deepEqual(store.writes.map(x => x.key), [store.plan.versionKey]);- assert.equal(store.objects.get(store.plan.fixedKey)!.toString(), 'previous accepted instructions');+ assert.equal(store.objects.get(store.plan.fixedKey)!.toString(), previousGuide);+});++test('late completion archives its exact version without rolling a newer default back', async t => {+ const { directory, record } = await fixture(t), newer = '# Install OpenMotion 0.6.4-test.10\n';+ const store = storage(directory, record, newer);+ const result = await publishGuide(directory, config, store);+ assert.equal(result.phase, 'superseded'); assert.equal(result.promoted, false);+ assert.deepEqual(store.writes.map(x => x.key), [store.plan.versionKey]);+ assert.equal(store.objects.get(store.plan.fixedKey)!.toString(), newer);+});++test('unrecognized or conflicting same-version defaults require inspection instead of replacement', async t => {+ const { directory, record } = await fixture(t);+ for (const previous of ['unrecognized instructions', `# Install OpenMotion ${record.version}\nchanged`]) {+ const store = storage(directory, record, previous);+ await assert.rejects(publishGuide(directory, config, store), /recognizable version|Same-version/);+ assert.equal(store.objects.get(store.plan.fixedKey)!.toString(), previous);+ assert(!store.writes.some(x => x.key === store.plan.fixedKey));+ }});test('PR CI has no publication credentials; publication requires the separate manual protected workflow', async () => {@@ -133,6 +153,7 @@ test('PR CI has no publication credentials; publication requires the separate maconst workflow = await readFile(new URL('../.github/workflows/motion-publish-test.yml', import.meta.url), 'utf8');assert(!ci.includes('secrets.') && !ci.includes('publish-install-guide:'));assert(workflow.includes('workflow_dispatch:') && !workflow.includes('pull_request:') && !workflow.includes('push:'));- assert(workflow.includes('environment: motion-test-publish') && workflow.includes('default: false'));+ assert.equal([...workflow.matchAll(/^ environment:/gm)].length, 1, 'Only the npm job requests independent approval');+ assert(workflow.includes('name: motion-test-publish'));assert(!workflow.split(' snapshot:\n')[0].includes('secrets.'));});diff --git a/tests/release-fixture.mjs b/tests/release-fixture.mjsindex f7035d48..468bb2b8 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 } from '../.github/scripts/motion-release.mjs';+import { sealCandidate, repository, candidateWorkflow, approvalReceipt, publicationEnvironment } from '../.github/scripts/motion-release.mjs';export async function candidateFixture(t) {const work = await mkdtemp(path.join(os.tmpdir(), 'motion-release-test-'));@@ -31,11 +31,15 @@ export async function candidateFixture(t) {const candidate = await sealCandidate(build, directory, root, env);const provenance = { head_sha: env.GITHUB_SHA, runId: 123, attempt: 1 };await writeJSON(path.join(directory, 'provenance.json'), provenance);- const inputs = { action: 'publish-test', expectedSHA256: candidate.tgzSHA256, acceptanceSHA256: 'c'.repeat(64), candidateRun: '123' };+ const inputs = { action: 'publish-test', expectedSHA256: candidate.tgzSHA256, candidateRun: '123' };+ const publicationEnv = { GITHUB_RUN_ID: '800', GITHUB_SHA: env.GITHUB_SHA, GITHUB_WORKFLOW_REF: env.GITHUB_WORKFLOW_REF };+ const reviews = [{ state: 'approved', comment: 'PASS', environments: [{ name: publicationEnvironment }], user: { login: 'reviewer' } }];+ const approval = approvalReceipt(candidate, reviews, { id: 800, actor: { login: 'operator' } }, inputs.action);+ await writeJSON(path.join(directory, 'approval.json'), approval);for (const platform of ['darwin-arm64', 'win32-x64']) await writeJSON(path.join(directory, `registry-${platform}.json`), {status: 'passed', platform, version, sourceCommit: commit, tgzSHA256: candidate.tgzSHA256,registryColdInstall: 'passed', nativePreparation: 'passed', repeatSetup: 'passed', resources: 'passed', mcpTools: 11, skills: 5,});await writeJSON(path.join(directory, 'npm-publication.json'), { tgzSHA256: candidate.tgzSHA256, previousLatest: '0.5.0' });- return { work, root, build, directory, candidate, inputs, provenance, app, pkg, manifest };+ return { work, root, build, directory, candidate, inputs, provenance, app, pkg, manifest, approval, env: publicationEnv };}diff --git a/tests/release-workflows.test.mjs b/tests/release-workflows.test.mjsindex 9675bb5e..433ec73c 100644--- a/tests/release-workflows.test.mjs+++ b/tests/release-workflows.test.mjs@@ -4,34 +4,78 @@ import { readFile, writeFile } from 'node:fs/promises';import path from 'node:path';import { createHash } from 'node:crypto';import { candidateFixture } from './release-fixture.mjs';-import { releaseInputs, validateSource, validateRun, verifyDownloaded, downloadCandidate, publishNpm, archiveRelease, repository, candidateWorkflow } from '../.github/scripts/motion-release.mjs';+import { releaseInputs, resolveSource, validateSource, validateRun, verifyDownloaded, downloadCandidate, publishNpm, archiveRelease, repository, candidateWorkflow, recoveryWorkflow, publicationEnvironment, candidateJobName, validatePublicationEnvironment, approvalReceipt, recordApproval } from '../.github/scripts/motion-release.mjs';+import { compareReleaseVersions } from '../scripts/release-version.mjs';import { consumerEnvironment } from '../.github/scripts/motion-registry-smoke.mjs';import { runFile } from '../scripts/runtime-assets.mjs';const config = { endpoint: 'https://example.r2.cloudflarestorage.com', bucket: 'example-releases', publicOrigin: 'https://download.example.invalid' };const valid = { GITHUB_REPOSITORY: repository, GITHUB_EVENT_NAME: 'workflow_dispatch', GITHUB_REF: 'refs/heads/main',- MOTION_RELEASE_ACTION: 'publish-test', MOTION_APPROVED: 'true', MOTION_EXPECTED_SHA256: 'a'.repeat(64), MOTION_ACCEPTANCE_SHA256: 'b'.repeat(64), MOTION_CANDIDATE_RUN: '123' };+ GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/main`, MOTION_RELEASE_ACTION: 'publish-test', MOTION_EXPECTED_SHA256: 'a'.repeat(64), MOTION_CANDIDATE_RUN: '123' };const origin = { id: 123, run_attempt: 1, event: 'workflow_dispatch', head_branch: 'main', head_repository: { full_name: repository }, status: 'completed', conclusion: 'success', path: candidateWorkflow, head_sha: 'b'.repeat(40) };const artifact = { id: 456, name: 'motion-candidate-123-1', workflow_run: { id: 123 }, expired: false, size_in_bytes: 100, digest: 'sha256:' + 'a'.repeat(64) };+const producer = { name: candidateJobName, status: 'completed', conclusion: 'success', run_id: 123, head_sha: origin.head_sha };+const protectedEnvironment = { name: publicationEnvironment, can_admins_bypass: false,+ protection_rules: [{ type: 'required_reviewers', prevent_self_review: true, reviewers: [{ type: 'User', reviewer: { login: 'reviewer' } }] }],+ deployment_branch_policy: { custom_branch_policies: true, protected_branches: false } };+const branchPolicies = { branch_policies: [{ name: 'main', type: 'branch' }] };-test('publication and source selection fail closed on missing approval, mutable refs, wrong repository or non-test versions', async () => {+test('manual entry and source selection reject untrusted callers, mutable refs and non-test versions', async () => {assert.equal(releaseInputs(valid).action, 'publish-test');- for (const [key, value] of Object.entries({ GITHUB_REPOSITORY: 'fork/repo', GITHUB_EVENT_NAME: 'push', GITHUB_REF: 'refs/heads/feature/motion', MOTION_APPROVED: 'false', MOTION_EXPECTED_SHA256: '', MOTION_ACCEPTANCE_SHA256: '', MOTION_CANDIDATE_RUN: '../123', MOTION_RELEASE_ACTION: 'stable' })) assert.throws(() => releaseInputs({ ...valid, [key]: value }));+ for (const [key, value] of Object.entries({ GITHUB_REPOSITORY: 'fork/repo', GITHUB_EVENT_NAME: 'push', GITHUB_REF: 'refs/heads/feature/motion', GITHUB_WORKFLOW_REF: `${repository}/evil.yml@refs/heads/main`, MOTION_EXPECTED_SHA256: 'bad', MOTION_CANDIDATE_RUN: '../123', MOTION_RELEASE_ACTION: 'stable' })) assert.throws(() => releaseInputs({ ...valid, [key]: value }));+ const recovery = { ...valid, GITHUB_WORKFLOW_REF: `${repository}/${recoveryWorkflow}@refs/heads/main` };+ assert.throws(() => releaseInputs(recovery), /Recovery/);+ assert.equal(releaseInputs({ ...recovery, MOTION_RELEASE_ACTION: 'archive-only' }).action, 'archive-only');let called = false;await validateSource('.', 'a'.repeat(40), '0.6.4-test.7', async (_, args) => { called = true; assert(args.includes('refs/remotes/origin/feature/motion')); }); assert(called);for (const [sha, version] of [['main', '0.6.4-test.7'], ['a'.repeat(40), '0.6.4'], ['a'.repeat(40), '0.6.4-test.0']]) await assert.rejects(validateSource('.', sha, version, async () => { throw Error('must not run'); }));await assert.rejects(validateSource('.', 'a'.repeat(40), '0.6.4-test.7', async () => { throw Error('not integrated'); }), /not integrated/);+ const resolved = await resolveSource('.', '', '0.6.4-test.7', async (_, args) => args[0] === 'rev-parse' ? 'a'.repeat(40) + '\n' : '');+ assert.equal(resolved, 'a'.repeat(40));});-test('only successful trusted candidate runs and their exact attempts are accepted', () => {- validateRun(origin, artifact);- for (const patch of [{ event: 'pull_request' }, { head_branch: 'feature/motion' }, { conclusion: 'failure' }, { path: '.github/workflows/other.yml' }, { head_repository: { full_name: 'fork/repo' } }]) assert.throws(() => validateRun({ ...origin, ...patch }, artifact));- for (const patch of [{ expired: true }, { name: 'motion-candidate-123-2' }, { digest: null }, { workflow_run: { id: 999 } }]) assert.throws(() => validateRun(origin, { ...artifact, ...patch }));+test('an in-progress release requires its successful exact candidate producer, including partial retries', () => {+ validateRun(origin, artifact, producer, 1);+ validateRun({ ...origin, status: 'in_progress', conclusion: null }, artifact, producer, 1);+ validateRun({ ...origin, run_attempt: 2, conclusion: 'failure' }, artifact, producer, 1);+ for (const patch of [{ event: 'pull_request' }, { head_branch: 'feature/motion' }, { path: '.github/workflows/other.yml' }, { head_repository: { full_name: 'fork/repo' } }]) assert.throws(() => validateRun({ ...origin, ...patch }, artifact, producer, 1));+ for (const patch of [{ expired: true }, { name: 'motion-candidate-123-2' }, { digest: null }, { workflow_run: { id: 999 } }]) assert.throws(() => validateRun(origin, { ...artifact, ...patch }, producer, 1));+ for (const patch of [{ status: 'in_progress' }, { conclusion: 'failure' }, { name: 'another job' }, { head_sha: 'f'.repeat(40) }, { run_id: 999 }]) assert.throws(() => validateRun(origin, artifact, { ...producer, ...patch }, 1));+ assert.throws(() => validateRun(origin, artifact, producer, 2));+});++test('missing, bypassable or wrongly scoped environment protections block publication', () => {+ validatePublicationEnvironment(protectedEnvironment, branchPolicies);+ for (const patch of [{ protection_rules: [] }, { can_admins_bypass: true }, { deployment_branch_policy: null }, { protection_rules: [{ ...protectedEnvironment.protection_rules[0], prevent_self_review: false }] }]) assert.throws(() => validatePublicationEnvironment({ ...protectedEnvironment, ...patch }, branchPolicies));+ assert.throws(() => validatePublicationEnvironment(protectedEnvironment, { branch_policies: [{ name: '*', type: 'branch' }] }));+});++test('approval records identify actual independent reviewers without publishing private comments', async t => {+ const f = await candidateFixture(t), approved = { state: 'approved', comment: 'PASS', environments: [{ name: publicationEnvironment }], user: { login: 'reviewer' } };+ const run = { ...origin, id: 800, actor: { login: 'operator' }, triggering_actor: { login: 'rerunner' } };+ assert.equal(approvalReceipt(f.candidate, [approved], run, 'publish-test').reviewers[0], 'reviewer');+ for (const patch of [{ state: 'rejected' }, { comment: '' }, { comment: 'internal private material' }, { environments: [{ name: 'other' }] }, { user: { login: 'operator' } }, { user: { login: 'rerunner' } }]) assert.throws(() => approvalReceipt(f.candidate, [{ ...approved, ...patch }], run, 'publish-test'));+ const fetcher = async url => {+ const value = String(url);+ if (value.endsWith('/environments/' + publicationEnvironment)) return Response.json(protectedEnvironment);+ if (value.includes('deployment-branch-policies')) return Response.json(branchPolicies);+ if (value.endsWith('/approvals')) return Response.json([approved]);+ return Response.json(run);+ };+ await recordApproval(f.directory, f.inputs, fetcher, f.env);+ const record = JSON.parse(await readFile(path.join(f.directory, 'approval.json')));+ assert.equal(record.publicationRun, 800); assert.equal(record.tgzSHA256, f.candidate.tgzSHA256);+ assert(!JSON.stringify(record).includes('comment'));+ await assert.rejects(recordApproval(f.directory, f.inputs, async url => String(url).endsWith('/approvals') ? Response.json([]) : fetcher(url), f.env), /independent/);});test('the sealed candidate detects tgz, guide, identity and provenance tampering', async t => {const { directory, candidate } = await candidateFixture(t);assert.equal((await verifyDownloaded(directory, candidate.tgzSHA256)).version, candidate.version);+ const checklist = await readFile(path.join(directory, 'acceptance.md'), 'utf8');+ assert(checklist.includes(candidate.tgzSHA256) && checklist.includes(candidate.sourceCommit));+ assert(!checklist.includes('<!-- CANDIDATE_IDENTITY -->'));+ assert(checklist.includes('NOT RUN'), 'Generated identity must not fabricate human acceptance');await assert.rejects(verifyDownloaded(directory, '0'.repeat(64)));const file = path.join(directory, 'install.md'), original = await readFile(file);await writeFile(file, 'changed'); await assert.rejects(verifyDownloaded(directory, candidate.tgzSHA256), /Candidate file changed/);@@ -47,11 +91,14 @@ test('artifact download verifies GitHub ZIP digest and does not forward the credconst value = String(url);if (value.endsWith('/actions/runs/123')) return Response.json(origin);if (value.includes('/artifacts?')) return Response.json({ artifacts: [{ ...artifact, digest, size_in_bytes: bytes.length }] });+ if (value.includes('/attempts/1/jobs')) return Response.json({ jobs: [producer] });if (value.endsWith('/456/zip')) return new Response(null, { status: 302, headers: { location: 'https://signed.example.invalid/candidate' } });assert.equal(value, 'https://signed.example.invalid/candidate'); assert.equal(options.headers, undefined);return new Response(bytes);};assert.equal((await downloadCandidate('123', path.join(f.work, 'download'), f.candidate.tgzSHA256, fetcher)).tgzSHA256, f.candidate.tgzSHA256);+ const retryFetcher = (url, options) => String(url).endsWith('/actions/runs/123') ? Response.json({ ...origin, run_attempt: 2, conclusion: 'failure' }) : fetcher(url, options);+ assert.equal((await downloadCandidate('123', path.join(f.work, 'retry'), undefined, retryFetcher, '456')).tgzSHA256, f.candidate.tgzSHA256, 'A partial retry derives the hash from its exact retained producer artifact');await assert.rejects(downloadCandidate('123', path.join(f.work, 'corrupt'), f.candidate.tgzSHA256, async (url, options) => String(url).includes('signed.') ? new Response('tampered ZIP') : fetcher(url, options)));});@@ -63,11 +110,30 @@ test('npm publishes only new exact bytes; identical retry and archive-only neverconst f = await candidateFixture(t); let calls = 0;assert.notEqual(f.candidate.sourceCommit, f.candidate.workflow.sha, 'Application and workflow source identities are independent');const run = async (command, args) => { calls++; assert.equal(command, 'npm'); assert(args.includes('--ignore-scripts') && args.includes('test')); assert(args.includes('--provenance=false'), 'Do not attest the publication main SHA as the prebuilt application source'); assert.equal(args[1], path.join(f.directory, f.candidate.tgz)); };- await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate, false) }); assert.equal(calls, 1);- await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate) });- await publishNpm(f.directory, { ...f.inputs, action: 'archive-only' }, { run, fetcher: registry(f.candidate) }); assert.equal(calls, 1);- await assert.rejects(publishNpm(f.directory, { ...f.inputs, action: 'archive-only' }, { run, fetcher: registry(f.candidate, false) }), /existing identical/);- await assert.rejects(publishNpm(f.directory, f.inputs, { run, fetcher: registry({ ...f.candidate, integrity: 'different' }) }), /different bytes/); assert.equal(calls, 1);+ await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate, false), env: f.env }); assert.equal(calls, 1);+ await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate), env: f.env });+ await assert.rejects(publishNpm(f.directory, f.inputs, { run, fetcher: registry({ ...f.candidate, integrity: 'different' }), env: f.env }), /different bytes/); assert.equal(calls, 1);+ await writeFile(path.join(f.directory, 'approval.json'), JSON.stringify({ ...f.approval, action: 'archive-only' }));+ await publishNpm(f.directory, { ...f.inputs, action: 'archive-only' }, { run, fetcher: registry(f.candidate), env: f.env }); assert.equal(calls, 1);+ await assert.rejects(publishNpm(f.directory, { ...f.inputs, action: 'archive-only' }, { run, fetcher: registry(f.candidate, false), env: f.env }), /existing identical/);+});++test('a stale candidate or approval from another run cannot publish or move npm test backward', async t => {+ const f = await candidateFixture(t); let calls = 0;+ const run = async () => { calls++; };+ await assert.rejects(publishNpm(f.directory, f.inputs, { run, env: f.env, fetcher: registry(f.candidate, false, '0.6.4-test.100') }), /newer npm test/);+ await assert.rejects(publishNpm(f.directory, f.inputs, { run, env: { GITHUB_RUN_ID: '801' }, fetcher: registry(f.candidate, false) }), /another publication run/);+ await writeFile(path.join(f.directory, 'approval.json'), JSON.stringify({ ...f.approval, tgzSHA256: '0'.repeat(64) }));+ await assert.rejects(publishNpm(f.directory, f.inputs, { run, env: f.env, fetcher: registry(f.candidate, false) }));+ assert.equal(calls, 0);+});++test('test version ordering handles numeric suffixes, stable versions and unsafe numeric widths', () => {+ for (const [a, b] of [['0.6.4-test.10', '0.6.4-test.9'], ['0.6.4', '0.6.4-test.99'], ['0.6.5-test.1', '0.6.4'], ['0.6.4-test.1.2', '0.6.4-test.1'], ['0.6.4-test.9007199254740993', '0.6.4-test.9007199254740992']]) {+ assert.equal(compareReleaseVersions(a, b), 1); assert.equal(compareReleaseVersions(b, a), -1);+ }+ assert.equal(compareReleaseVersions('0.6.4-test.1', '0.6.4-test.1'), 0);+ assert.throws(() => compareReleaseVersions('latest', '0.6.4'));});test('partial publication retries use the retained producer artifact IDs across attempts', async () => {@@ -80,6 +146,9 @@ test('partial publication retries use the retained producer artifact IDs acrossassert(jobs[id].includes('artifact_id: ${{ steps.artifact.outputs.artifact-id }}'), 'Expose the actual uploaded artifact ID');assert(jobs[id].includes(' id: artifact\n'));}+ for (const id of ['npm', 'registry-mac', 'registry-windows', 'snapshot']) {+ assert(jobs[id].includes('if: ${{ always() && !cancelled() && needs.verify.result'), 'A skipped recovery build must not silently skip downstream jobs: ' + id);+ }const downloads = id => [...jobs[id].matchAll(/artifact-ids: \$\{\{ needs\.([\w-]+)\.outputs\.artifact_id \}\}/g)].map(m => m[1]);assert.deepEqual(downloads('npm'), ['verify']);assert.deepEqual(downloads('registry-mac'), ['verify']);@@ -107,8 +176,25 @@ test('partial publication retries use the retained producer artifact IDs across}});+test('the daily entry builds before one approval; recovery can only reuse an existing candidate', async () => {+ const workflow = await readFile(new URL('../.github/workflows/motion-publish-test.yml', import.meta.url), 'utf8');+ const recovery = await readFile(new URL('../.github/workflows/motion-publication-recovery.yml', import.meta.url), 'utf8');+ const header = workflow.split('\njobs:\n')[0];+ assert(header.includes('version:') && header.includes('source_sha:'));+ for (const manualField of ['tgz_sha256:', 'acceptance_sha256:', 'approved:', 'action:']) assert(!header.includes(manualField));+ assert(!header.includes('concurrency:'), 'Acceptance waits cannot hold a repository-wide build lock');+ assert(workflow.includes('name: ' + candidateJobName));+ assert(workflow.includes('ref: ${{ steps.source.outputs.source_sha }}'), 'Checkout the already frozen commit');+ assert.equal([...workflow.matchAll(/^ environment:/gm)].length, 1);+ assert(workflow.includes('motion-release.mjs environment') && workflow.includes('motion-release.mjs approval'));+ assert(workflow.includes('MOTION_EXPECTED_SHA256: ${{ needs.verify.outputs.tgz_sha256 }}'));+ assert(!recovery.includes('publish-test\n') && !recovery.includes('version:') && !recovery.includes('source_sha:'));+ assert(recovery.includes('uses: ./.github/workflows/motion-publish-test.yml'));+ assert(workflow.includes("inputs.candidate_run_id != '' && 'archive-only' || 'publish-test'"));+});+function storage(candidate) {- const objects = new Map([['open-motion/dev/install.md', Buffer.from('previous entry')]]), writes = [], reads = [];+ const objects = new Map([['open-motion/dev/install.md', Buffer.from('# Install OpenMotion 0.6.4-test.1\n')]]), writes = [], reads = [];let failKey;const run = async (command, args) => {assert.equal(command, 'aws'); const op = args[args.indexOf('s3api') + 1], key = args[args.indexOf('--key') + 1];@@ -119,17 +205,17 @@ function storage(candidate) {objects.set(key, await readFile(args[args.indexOf('--body') + 1])); writes.push(key); return '{}';};const fetcher = async url => String(url).includes('registry.npmjs.org') ? registry(candidate)() : new Response(objects.get(new URL(url).pathname.slice(1)) || '', { status: objects.has(new URL(url).pathname.slice(1)) ? 200 : 404 });- return { objects, writes, reads, run, fetcher, fail: key => { failKey = key; } };+ return { objects, writes, reads, run, fetcher, env: { GITHUB_RUN_ID: '800' }, fail: key => { failKey = key; } };}test('interrupted archive resumes identical snapshots, verifies the exact public URLs, and updates the moving guide last', async t => {const f = await candidateFixture(t), store = storage(f.candidate), prefix = `open-motion/dev/${f.candidate.version}`;store.fail(prefix + '/install-record.json');await assert.rejects(archiveRelease(f.directory, f.inputs, config, store), /interruption/);- assert.equal(store.objects.get('open-motion/dev/install.md').toString(), 'previous entry');+ assert.equal(store.objects.get('open-motion/dev/install.md').toString(), '# Install OpenMotion 0.6.4-test.1\n');store.fail(null); await archiveRelease(f.directory, f.inputs, config, store);assert.equal(store.writes.at(-1), 'open-motion/dev/install.md');- assert.equal(await readFile(path.join(f.directory, 'previous-install.md'), 'utf8'), 'previous entry');+ assert.equal(await readFile(path.join(f.directory, 'previous-install.md'), 'utf8'), '# Install OpenMotion 0.6.4-test.1\n');const before = store.writes.length; await archiveRelease(f.directory, f.inputs, config, store); assert.equal(store.writes.length, before);store.objects.set(prefix + '/release-npm.json', Buffer.from('different snapshot'));await assert.rejects(archiveRelease(f.directory, f.inputs, config, store), /Immutable snapshot/);@@ -137,12 +223,31 @@ test('interrupted archive resumes identical snapshots, verifies the exact publictest('archive-only never reads or writes the moving entry, and failed platform acceptance blocks all storage calls', async t => {const f = await candidateFixture(t), store = storage(f.candidate);+ await writeFile(path.join(f.directory, 'approval.json'), JSON.stringify({ ...f.approval, action: 'archive-only' }));await archiveRelease(f.directory, { ...f.inputs, action: 'archive-only' }, config, store);assert(!store.reads.includes('open-motion/dev/install.md') && !store.writes.includes('open-motion/dev/install.md'));await writeFile(path.join(f.directory, 'registry-win32-x64.json'), JSON.stringify({ status: 'failed' }));const before = store.reads.length; await assert.rejects(archiveRelease(f.directory, f.inputs, config, store)); assert.equal(store.reads.length, before);});+test('a superseded npm candidate still keeps immutable snapshots and never advances the moving guide', async t => {+ const f = await candidateFixture(t), store = storage(f.candidate);+ await archiveRelease(f.directory, f.inputs, config, { ...store, fetcher: url => String(url).includes('registry.npmjs.org') ? registry(f.candidate, true, '0.6.4-test.100')() : store.fetcher(url) });+ assert(store.objects.has(`open-motion/dev/${f.candidate.version}/install.md`));+ assert(!store.reads.includes('open-motion/dev/install.md') && !store.writes.includes('open-motion/dev/install.md'));+ const attempt = JSON.parse(await readFile(path.join(f.directory, 'release-attempt.json')));+ assert.equal(attempt.stage, 'archived-superseded');+});++test('a missing or regressed npm test tag cannot be misreported as a newer superseding release', async t => {+ const f = await candidateFixture(t), store = storage(f.candidate);+ for (const tag of [undefined, '0.6.4-test.1']) {+ await assert.rejects(archiveRelease(f.directory, f.inputs, config, { ...store,+ fetcher: () => Response.json({ versions: { [f.candidate.version]: { dist: { integrity: f.candidate.integrity } } }, 'dist-tags': { test: tag, latest: '0.5.0' } }) }), /explicit channel recovery/);+ }+ assert.equal(store.writes.length, 0);+});+test('an unexpected npm latest change stops promotion and consumer processes cannot inherit publication credentials', async t => {const f = await candidateFixture(t), store = storage(f.candidate);await assert.rejects(archiveRelease(f.directory, f.inputs, config, { ...store, fetcher: registry(f.candidate, true, f.candidate.version, f.candidate.version) }), /latest changed/);@@ -152,3 +257,34 @@ test('an unexpected npm latest change stops promotion and consumer processes canassert(!env.BROWSER_USE_ACCESS_PIPE_PATH && !env.CODEX_APP_TOOLS_PIPE_PATH && !env.NODE_OPTIONS);assert.equal(env.npm_config_registry, 'https://registry.npmjs.org/');});++test('no-publication rehearsal carries one candidate through approval, npm and storage using simulated services only', async t => {+ const f = await candidateFixture(t), store = storage(f.candidate);+ const run = { ...origin, id: 800, actor: { login: 'operator' } };+ const reviews = [{ state: 'approved', comment: 'PASS', environments: [{ name: publicationEnvironment }], user: { login: 'reviewer' } }];+ const github = async url => {+ if (String(url).endsWith('/environments/' + publicationEnvironment)) return Response.json(protectedEnvironment);+ if (String(url).includes('deployment-branch-policies')) return Response.json(branchPolicies);+ if (String(url).endsWith('/approvals')) return Response.json(reviews);+ return Response.json(run);+ };+ await writeFile(path.join(f.directory, 'approval.json'), '{}');+ let npmWrites = 0, published = false;+ const npm = { env: f.env, fetcher: () => registry(f.candidate, published)(), run: async (command, args) => {+ assert.equal(command, 'npm'); assert.equal(args[1], path.join(f.directory, f.candidate.tgz));+ npmWrites++; published = true;+ } };+ await assert.rejects(publishNpm(f.directory, f.inputs, npm));+ assert.equal(npmWrites, 0, 'No approval means no registry write');+ await recordApproval(f.directory, f.inputs, github, f.env);+ await publishNpm(f.directory, f.inputs, npm);+ await archiveRelease(f.directory, f.inputs, config, store);+ assert.equal(npmWrites, 1);+ const release = JSON.parse(store.objects.get(`open-motion/dev/${f.candidate.version}/release-record.json`));+ assert.equal(release.schemaVersion, 2); assert.deepEqual(release.approval.reviewers, ['reviewer']);+ assert.equal(release.tgzSHA256, f.candidate.tgzSHA256);+ assert.equal(store.writes.at(-1), 'open-motion/dev/install.md');+ await publishNpm(f.directory, f.inputs, npm);+ await archiveRelease(f.directory, f.inputs, config, store);+ assert.equal(npmWrites, 1, 'Retry never repacks or republishes the accepted bytes');+});