Skip to content

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.

feat: add controlled Motion candidate and test release workflows

罗高3dbb455ba6dc
diff --git a/.github/gitleaks.toml b/.github/gitleaks.toml
new file mode 100644
index 00000000..12bc986f
--- /dev/null
+++ b/.github/gitleaks.toml
@@ -0,0 +1,8 @@
+title = "Motion release credentials policy"
+[extend]
+useDefault = true
+
+[[allowlists]]
+description = "Existing public, write-only OpenMotion analytics identifier; not a management credential"
+regexTarget = "secret"
+regexes = ['''^phc_u5dHWkwdqN626opkbbjDKk7xNzxR2UsJbdQqx3DncbjU$''']
diff --git a/.github/scripts/motion-registry-smoke.mjs b/.github/scripts/motion-registry-smoke.mjs
new file mode 100644
index 00000000..bcba762f
--- /dev/null
+++ b/.github/scripts/motion-registry-smoke.mjs
@@ -0,0 +1,89 @@
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { spawn } from 'node:child_process';
+import { createInterface } from 'node:readline';
+import { access, mkdir, mkdtemp, readFile, readdir, writeFile } from 'node:fs/promises';
+import os from 'node:os';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { runFile, sha256, writeJSON } from '../../scripts/runtime-assets.mjs';
+
+export function consumerEnvironment(work, source = process.env) {
+ const env = { ...source };
+ for (const key of Object.keys(env)) if (/TOKEN|SECRET|PASSWORD|CREDENTIAL|COOKIE|(?:^|_)KEY$|^GITHUB_|^ACTIONS_|^AWS_|^npm_config_/i.test(key)) delete env[key];
+ for (const key of ['HYPERFRAMES_FFMPEG_PATH', 'HYPERFRAMES_FFPROBE_PATH', 'HYPERFRAMES_BROWSER_PATH', 'FFMPEG_PATH', 'FFPROBE_PATH', 'MOTION_BROWSER_PATH', 'MOTION_TEMPLATES_CONFIG_URL', 'MOTION_TEMPLATES_ENV', 'MOTION_DATA_DIR']) delete env[key];
+ return { ...env, CODEX_HOME: path.join(work, 'codex'), npm_config_cache: path.join(work, 'npm-cache'),
+ npm_config_userconfig: path.join(work, 'user.npmrc'), npm_config_globalconfig: path.join(work, 'global.npmrc'),
+ npm_config_registry: 'https://registry.npmjs.org/', npm_config_ignore_scripts: 'true',
+ OPENMOTION_TELEMETRY: '0', HYPERFRAMES_NO_TELEMETRY: '1' };
+}
+
+async function discover(transport, env, version, tools) {
+ const child = spawn(transport.command, transport.args, { env, stdio: ['pipe', 'pipe', 'pipe'], windowsHide: true });
+ const waiting = new Map(); let sequence = 0;
+ const fail = error => { for (const p of waiting.values()) { clearTimeout(p.timer); p.reject(error); } waiting.clear(); };
+ child.on('error', fail); child.on('exit', code => fail(new Error('MCP exited: ' + code)));
+ child.stderr.resume();
+ createInterface({ input: child.stdout }).on('line', line => {
+ try { const result = JSON.parse(line), p = waiting.get(result.id); if (p) { waiting.delete(result.id); clearTimeout(p.timer); result.error ? p.reject(new Error('MCP error')) : p.resolve(result.result); } }
+ catch { fail(new Error('Invalid MCP JSON')); }
+ });
+ const rpc = (method, params) => new Promise((resolve, reject) => {
+ const id = ++sequence, timer = setTimeout(() => { waiting.delete(id); reject(new Error('MCP timed out: ' + method)); }, 120_000);
+ waiting.set(id, { resolve, reject, timer }); child.stdin.write(JSON.stringify({ jsonrpc: '2.0', id, method, params }) + '\n');
+ });
+ try {
+ const hello = await rpc('initialize', { protocolVersion: '2025-11-25', capabilities: {}, clientInfo: { name: 'motion-registry-acceptance', version: '1' } });
+ assert.equal(hello.serverInfo.version, version);
+ child.stdin.write(JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized' }) + '\n');
+ assert.deepEqual((await rpc('tools/list', {})).tools.map(t => t.name), tools);
+ await rpc('resources/read', { uri: 'motion://workflow/production/start' });
+ await rpc('resources/read', { uri: 'motion://engine/SKILL.md' });
+ } finally { child.stdin.end(); child.kill(); fail(new Error('MCP session closed')); }
+}
+
+export async function registrySmoke(directory) {
+ const c = JSON.parse(await readFile(path.join(directory, 'candidate.json')));
+ const platform = process.platform + '-' + process.arch;
+ assert(['darwin-arm64', 'win32-x64'].includes(platform), 'Use a supported native runner');
+ const work = await mkdtemp(path.join(os.tmpdir(), 'om-registry-')), env = consumerEnvironment(work);
+ for (const file of ['user.npmrc', 'global.npmrc']) await writeFile(path.join(work, file), '');
+ const project = path.join(work, 'project'), host = path.join(work, 'host');
+ await mkdir(project); await mkdir(env.CODEX_HOME);
+ await writeFile(path.join(env.CODEX_HOME, 'config.toml'), '[mcp_servers.unrelated]\ncommand = "keep-this-server"\n');
+ const npm = path.join(path.dirname(process.execPath), process.platform === 'win32' ? 'node_modules/npm/bin/npm-cli.js' : '../lib/node_modules/npm/bin/npm-cli.js');
+ const cli = args => runFile(process.execPath, [npm, ...args], { cwd: project, env, timeout: 20 * 60_000 });
+ let metadata;
+ for (let attempt = 0; attempt < 30; attempt++) {
+ const response = await fetch('https://registry.npmjs.org/@openmotion%2fapp/' + c.version, { signal: AbortSignal.timeout(30_000) });
+ if (response.ok) { metadata = await response.json(); break; }
+ assert.equal(response.status, 404, 'Registry lookup failed');
+ await new Promise(resolve => setTimeout(resolve, 10_000));
+ }
+ assert(metadata, 'Registry version did not become visible'); assert.equal(metadata.dist.integrity, c.integrity);
+ const [packed] = JSON.parse(await cli(['pack', `${c.packageName}@${c.version}`, '--ignore-scripts', '--json', '--pack-destination', work]));
+ assert.equal(path.basename(packed.filename), packed.filename);
+ const tgz = path.join(work, packed.filename), bytes = await readFile(tgz);
+ assert.equal(await sha256(tgz), c.tgzSHA256); assert.equal('sha512-' + createHash('sha512').update(bytes).digest('base64'), c.integrity);
+ await cli(['install', '--prefix', host, '--no-save', '--ignore-scripts', '--no-audit', '--no-fund', '@openai/[email protected]']);
+ const codex = path.join(host, 'node_modules/@openai/codex/bin/codex.js');
+ const home = path.join(work, 'app'), data = path.join(work, 'data'), skills = path.join(project, '.agents/skills');
+ const command = ['exec', '--yes', '--package', tgz, '--', 'openmotion'];
+ const setup = [...command, 'setup', '--host', 'codex', '--home', home, '--data-dir', data, '--skills-dir', skills, '--codex', codex];
+ const first = JSON.parse(await cli(setup)), second = JSON.parse(await cli(setup));
+ assert.equal(first.appRoot, second.appRoot); assert.equal((await readdir(path.join(home, 'apps'))).length, 1);
+ assert.match(await readFile(path.join(env.CODEX_HOME, 'config.toml'), 'utf8'), /keep-this-server/);
+ const manifest = JSON.parse(await readFile(path.join(directory, 'release-npm.json')));
+ for (const skill of manifest.skills) await access(path.join(skills, 'openmotion/skills', skill, 'SKILL.md'));
+ await cli([...command, 'prepare', '--home', home]);
+ const installed = JSON.parse(await runFile(process.execPath, [codex, 'mcp', 'get', 'openmotion', '--json'], { cwd: project, env }));
+ assert.equal(installed.transport.command, process.execPath); assert.deepEqual(installed.transport.args, [first.launcher]);
+ await discover(installed.transport, env, c.version, manifest.mcp.tools);
+ const report = { status: 'passed', platform, version: c.version, sourceCommit: c.sourceCommit, tgzSHA256: c.tgzSHA256,
+ node: process.version, codex: '0.166.0', registryColdInstall: 'passed', repeatSetup: 'passed', unrelatedSettings: 'preserved',
+ nativePreparation: 'passed', mcpTools: manifest.mcp.tools.length, skills: manifest.skills.length, resources: 'passed',
+ realModelTurn: 'not-run', humanPlayback: 'not-run', windowsDesktopAcceptance: 'not-run' };
+ await writeJSON(path.join(directory, `registry-${platform}.json`), report); return report;
+}
+
+if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) await registrySmoke(path.resolve(process.argv[2]));
diff --git a/.github/scripts/motion-release.mjs b/.github/scripts/motion-release.mjs
new file mode 100644
index 00000000..d71e2651
--- /dev/null
+++ b/.github/scripts/motion-release.mjs
@@ -0,0 +1,252 @@
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { execFile } from 'node:child_process';
+import { promisify } from 'node:util';
+import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
+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 { 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';
+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');
+
+export function releaseInputs(env = process.env) {
+ assert.equal(env.GITHUB_REPOSITORY, repository, 'Wrong repository');
+ 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');
+ 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 };
+}
+
+export async function validateSource(control, commit, version, run = runFile) {
+ assert.match(commit || '', /^[a-f0-9]{40}$/, 'Use a full immutable source SHA');
+ checkReleaseVersion(version); assert(version.includes('-test.'), 'This workflow builds test versions only');
+ await run('git', ['merge-base', '--is-ancestor', commit, 'refs/remotes/origin/feature/motion'], { cwd: control });
+}
+
+export async function sealCandidate(build, output, source, env = process.env) {
+ const manifest = await json(path.join(build, 'release-npm.json'));
+ assert.equal(manifest.commit, (await runFile('git', ['rev-parse', 'HEAD'], { cwd: source })).trim());
+ assert.equal(manifest.commit, env.MOTION_SOURCE_SHA); assert.equal(manifest.version, env.MOTION_VERSION);
+ assert(manifest.version.includes('-test.') && manifest.templateEnvironment === 'prod');
+ assert.match(env.GITHUB_SHA || '', /^[a-f0-9]{40}$/);
+ assert.equal(env.GITHUB_WORKFLOW_REF, `${repository}/${candidateWorkflow}@refs/heads/main`);
+ assert(/^[1-9]\d*$/.test(env.GITHUB_RUN_ID || '') && /^[1-9]\d*$/.test(env.GITHUB_RUN_ATTEMPT || ''));
+ const filename = manifest.installer.url.replace(/^\.\//, '');
+ assert.equal(filename, `openmotion-app-${manifest.version}.tgz`);
+ await mkdir(output, { recursive: true });
+ for (const name of [filename, 'release-npm.json', 'source-scan.json', 'package-scan.json']) await cp(path.join(build, name), path.join(output, name));
+ 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 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,
+ 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) },
+ createdAt: new Date().toISOString(), acceptance: 'not-performed' };
+ await writeJSON(path.join(output, 'candidate.json'), candidate);
+ return candidate;
+}
+
+export function validateRun(run, artifact) {
+ 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.path.split('@')[0], candidateWorkflow, 'Candidate must come from the registered workflow');
+ assert.equal(artifact.name, `motion-candidate-${run.id}-${run.run_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');
+}
+
+async function github(route, fetcher = fetch) {
+ const response = await fetcher(`https://api.github.com/repos/${repository}${route}`, { redirect: 'error', signal: AbortSignal.timeout(30_000),
+ headers: { Accept: 'application/vnd.github+json', Authorization: `Bearer ${process.env.GH_TOKEN || process.env.GITHUB_TOKEN}`, 'X-GitHub-Api-Version': '2022-11-28' } });
+ assert(response.ok, 'GitHub metadata request failed: HTTP ' + response.status);
+ return response.json();
+}
+
+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');
+ 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'];
+ 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);
+ assert.equal(integrity(await readFile(path.join(directory, candidate.tgz))), candidate.integrity);
+ const guide = await json(path.join(directory, 'install-record.json'));
+ assert.equal(guide.commit, candidate.sourceCommit); assert.equal(guide.version, candidate.version); assert.equal(guide.packageName, candidate.packageName);
+ assert.equal(guide.tgzSHA256, expectedSHA256); assert.equal(guide.channel, 'test'); assert.equal(guide.templateEnvironment, 'prod');
+ assert.equal(guide.guideSHA256, candidate.files['install.md']); assert.equal(guide.candidate, false);
+ const manifest = await json(path.join(directory, 'release-npm.json'));
+ assert.equal(manifest.commit, candidate.sourceCommit); assert.equal(manifest.version, candidate.version);
+ assert.equal(manifest.installer.sha256, expectedSHA256);
+ for (const name of ['source-scan.json', 'package-scan.json']) assert.equal((await json(path.join(directory, name))).status, 'passed');
+ return candidate;
+}
+
+export async function verifyDownloaded(directory, expectedSHA256) {
+ const provenance = await json(path.join(directory, 'provenance.json'));
+ return verifyCandidate(directory, expectedSHA256, { head_sha: provenance.head_sha, id: provenance.runId, run_attempt: provenance.attempt });
+}
+
+export async function platformReports(directory, candidate) {
+ const reports = [];
+ for (const platform of ['darwin-arm64', 'win32-x64']) {
+ const name = `registry-${platform}.json`, report = await json(path.join(directory, name));
+ assert.equal(report.status, 'passed'); assert.equal(report.platform, platform);
+ assert.equal(report.version, candidate.version); assert.equal(report.tgzSHA256, candidate.tgzSHA256);
+ assert.equal(report.sourceCommit, candidate.sourceCommit);
+ assert.equal(report.registryColdInstall, 'passed'); assert.equal(report.nativePreparation, 'passed');
+ assert.equal(report.repeatSetup, 'passed'); assert.equal(report.resources, 'passed');
+ assert.equal(report.mcpTools, 11); assert.equal(report.skills, 5);
+ reports.push({ platform, reportSHA256: await sha256(path.join(directory, name)) });
+ }
+ return reports;
+}
+
+export async function downloadCandidate(runId, directory, expectedSHA256, fetcher = fetch) {
+ 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 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);
+ // Signed artifact URLs are fetched without forwarding the GitHub credential.
+ const response = await fetcher(url, { redirect: 'error', signal: AbortSignal.timeout(60_000) }); assert(response.ok);
+ const bytes = Buffer.from(await response.arrayBuffer()); assert(bytes.length < 150 * 1024 * 1024);
+ assert.equal('sha256-' + createHash('sha256').update(bytes).digest('hex'), artifact.digest.replace(':', '-'));
+ const work = await mkdtemp(path.join(os.tmpdir(), 'motion-artifact-'));
+ try {
+ const archive = path.join(work, 'candidate.zip'); await writeFile(archive, bytes);
+ const entries = (await runFile('unzip', ['-Z1', archive])).trim().split('\n');
+ assert(entries.length === 7 && new Set(entries).size === 7, '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 });
+ return candidate;
+ } finally { await rm(work, { recursive: true, force: true }); }
+}
+
+export async function registryPackage(candidate, fetcher = fetch) {
+ const response = await fetcher('https://registry.npmjs.org/@openmotion%2fapp', { signal: AbortSignal.timeout(30_000) });
+ if (response.status === 404) return { version: null, tags: {} };
+ assert(response.ok, 'Registry metadata request failed'); const data = await response.json();
+ const version = data.versions?.[candidate.version];
+ if (version) assert.equal(version.dist.integrity, candidate.integrity, 'Published npm version has different bytes; never overwrite it');
+ return { version: version || null, tags: data['dist-tags'] || {} };
+}
+
+export async function publishNpm(directory, inputs, { fetcher = fetch, run = runFile } = {}) {
+ const candidate = await verifyDownloaded(directory, inputs.expectedSHA256);
+ const before = await registryPackage(candidate, fetcher);
+ if (inputs.action === 'archive-only') assert(before.version, 'Archive-only requires an existing identical npm 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);
+ if (!before.version) {
+ await run('npm', ['publish', path.join(directory, candidate.tgz), '--access', 'public', '--tag', 'test', '--ignore-scripts', '--registry=https://registry.npmjs.org/']);
+ record.status = 'published-awaiting-registry'; await writeJSON(path.join(directory, 'npm-publication.json'), record);
+ }
+ return record;
+}
+
+export 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 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);
+ const registry = await registryPackage(candidate, fetcher); assert(registry.version, 'Exact npm version is not public');
+ 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');
+ 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 {
+ const get = async key => {
+ const file = path.join(work, 'object');
+ try { await aws('get-object', ['--key', key, file]); return await readFile(file); }
+ 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,
+ tgzSHA256: candidate.tgzSHA256, integrity: candidate.integrity, candidateRun: candidate.workflow,
+ acceptanceRecordSHA256: inputs.acceptanceSHA256, approvedBy: env.GITHUB_ACTOR, 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);
+ release = existing;
+ }
+ await writeJSON(path.join(directory, 'release-record.json'), release);
+ const names = [...Object.keys(candidate.files), 'candidate.json', 'registry-darwin-arm64.json', 'registry-win32-x64.json', 'release-record.json'];
+ const objects = [];
+ for (const name of names) {
+ const file = path.join(directory, name), bytes = await readFile(file), key = `${prefix}/${name}`, existing = await get(key);
+ if (existing) assert(existing.equals(bytes), 'Immutable snapshot already has different bytes: ' + name);
+ objects.push({ file, bytes, key, existing });
+ }
+ await writeJSON(path.join(directory, 'release-attempt.json'), { action: inputs.action, version: candidate.version, stage: 'archive-started', runId: env.GITHUB_RUN_ID });
+ for (const object of objects) {
+ if (!object.existing) await aws('put-object', ['--key', object.key, '--body', object.file, '--if-none-match', '*', '--content-type', object.key.endsWith('.md') ? 'text/markdown; charset=utf-8' : object.key.endsWith('.json') ? 'application/json' : 'application/octet-stream', '--cache-control', 'public, max-age=31536000, immutable']);
+ 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 });
+ 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);
+ else if (command === 'seal') await sealCandidate(directory, extra, final);
+ else {
+ const inputs = releaseInputs();
+ if (command === 'download') await downloadCandidate(inputs.candidateRun, directory, inputs.expectedSHA256);
+ else if (command === 'rescan') {
+ const c = await verifyDownloaded(directory, inputs.expectedSHA256);
+ await validateSource(extra, c.sourceCommit, c.version);
+ const work = await mkdtemp(path.join(os.tmpdir(), 'motion-source-verify-'));
+ try {
+ await runFile('git', ['worktree', 'add', '--detach', work, c.sourceCommit], { cwd: extra });
+ await writeJSON(path.join(directory, 'publication-source-scan.json'), await scanSource(work, final));
+ await writeJSON(path.join(directory, 'publication-package-scan.json'), await scanPackage(path.join(directory, c.tgz), final));
+ } finally { await runFile('git', ['worktree', 'remove', '--force', work], { cwd: extra }).catch(() => {}); }
+ } else if (command === 'verify') await verifyDownloaded(directory, inputs.expectedSHA256);
+ else if (command === 'npm') await publishNpm(directory, inputs);
+ else if (command === 'archive') {
+ for (const name of ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY']) assert(process.env[name], 'Missing R2 credential: ' + name);
+ await archiveRelease(directory, inputs, { endpoint: process.env.MOTION_R2_ENDPOINT, bucket: process.env.MOTION_R2_BUCKET, publicOrigin: process.env.MOTION_INSTALL_PUBLIC_ORIGIN });
+ }
+ else throw new Error('Unknown release command');
+ }
+}
diff --git a/.github/scripts/motion-scan.mjs b/.github/scripts/motion-scan.mjs
new file mode 100644
index 00000000..53103b0f
--- /dev/null
+++ b/.github/scripts/motion-scan.mjs
@@ -0,0 +1,150 @@
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { createReadStream } from 'node:fs';
+import { createGunzip } from 'node:zlib';
+import { cp, lstat, mkdir, mkdtemp, readFile, readdir, rm, writeFile, chmod } from 'node:fs/promises';
+import os from 'node:os';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { download, runFile, sha256, writeJSON } from '../../scripts/runtime-assets.mjs';
+
+const root = fileURLToPath(new URL('../../', import.meta.url));
+export const scannerVersion = '8.30.1';
+const scannerHashes = {
+ 'linux_x64': '551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb',
+ 'darwin_arm64': 'b40ab0ae55c505963e365f271a8d3846efbc170aa17f2607f13df610a9aeb6a5',
+};
+
+export async function installScanner(directory) {
+ const target = `${process.platform}_${process.arch}`;
+ assert(scannerHashes[target], 'Use the supported Linux x64 or Mac arm64 scanner runner');
+ await mkdir(directory, { recursive: true });
+ const archive = path.join(directory, 'gitleaks.tar.gz');
+ await download({ url: `https://github.com/gitleaks/gitleaks/releases/download/v${scannerVersion}/gitleaks_${scannerVersion}_${target}.tar.gz`, sha256: scannerHashes[target] }, archive);
+ await runFile('tar', ['-xzf', archive, '-C', directory, 'gitleaks']);
+ const binary = path.join(directory, 'gitleaks'); await chmod(binary, 0o755);
+ return binary;
+}
+
+export function archivePaths(listing) {
+ const names = listing.trim().split('\n');
+ assert(names.length && names.length < 20_000, 'Archive has too many entries');
+ for (const name of names) {
+ assert(name && !/[\\\x00-\x1f]/.test(name) && !path.posix.isAbsolute(name) && !/^[a-z]:/i.test(name)
+ && !name.split('/').includes('..'), 'Unsafe archive entry');
+ }
+ return names;
+}
+
+export async function unpackChecked(archive, directory, run = runFile) {
+ assert((await lstat(archive)).size < 150 * 1024 * 1024, 'Archive exceeds release size limit');
+ let expanded = 0;
+ for await (const chunk of createReadStream(archive).pipe(createGunzip())) {
+ expanded += chunk.length; assert(expanded < 350 * 1024 * 1024, 'Expanded archive exceeds release size limit');
+ }
+ archivePaths(await run('tar', ['-tzf', archive]));
+ const details = (await run('tar', ['-tvzf', archive])).trim().split('\n');
+ assert(details.every(line => /^[-d]/.test(line)), 'Archive links and special files are forbidden');
+ await mkdir(directory, { recursive: true });
+ await run('tar', ['-xzf', archive, '-C', directory]);
+}
+
+export function privacyFindings(name, text, kind = 'source') {
+ const findings = [], add = rule => findings.push({ path: name, rule });
+ // Public DEV routing and synthetic redaction fixtures are intentional, not credentials or employee paths.
+ if (name === 'prism-templates.ts' || name === './prism-templates.ts') text = text.replace(/https:\/\/r\.powerformer\.net/g, 'https://dev.example.invalid');
+ if (kind === 'source') {
+ const fixtures = {
+ 'studio/src/components/feedback/projectProvenance.test.ts': /\/Users\/me\/x/g,
+ 'studio/src/player/store/previewQualitySlice.test.ts': /\/Users\/a\/film\.mp3/g,
+ 'studio/src/telemetry/breadcrumbs.test.ts': /\/Users\/someone\/(?:private\/path\.html|project\.ts)/g,
+ };
+ if (fixtures[name]) text = text.replace(fixtures[name], '/synthetic/redaction-fixture');
+ }
+ if (/(?:^|\/)(?:outputs|research|node_modules|\.artifacts|\.motion-data(?:-dev)?)(?:\/|$)/.test(name)
+ || /(?:^|\/)(?:\.npmrc|\.DS_Store|id_rsa|id_ed25519)$/.test(name)
+ || /\.(?:log|pem|key|p12|pfx)$/.test(name)) add('private-file');
+ if (/(?:^|\/)\.env(?:\.|$)/.test(name) && !(kind === 'source' && /(?:^|\/)\.env\.(?:example|development)$/.test(name))) add('environment-file');
+ if (/https?:\/\/[^\s"'<>)]*(?:powerformer\.(?:net|com)|feishu\.(?:cn|com)|larksuite\.com)/i.test(text)) add('internal-link');
+ if (/\/(?:Users|home)\/[a-zA-Z0-9_.-]+\/|[a-z]:\\Users\\[^\\\s]+\\|\/var\/folders\//i.test(text)) add('personal-path');
+ return findings;
+}
+
+async function scanTree(directory, kind, binary) {
+ const findings = []; let files = 0, bytes = 0;
+ const visit = async (dir, prefix = '') => {
+ for (const entry of await readdir(dir, { withFileTypes: true })) {
+ const name = prefix + entry.name, filename = path.join(dir, entry.name);
+ assert(!entry.isSymbolicLink(), 'Release scan does not follow links');
+ if (entry.isDirectory()) await visit(filename, name + '/');
+ else {
+ assert(entry.isFile(), 'Special file in release');
+ const data = await readFile(filename); files++; bytes += data.length;
+ assert(bytes < 350 * 1024 * 1024 && files < 20_000, 'Expanded release exceeds scan limit');
+ findings.push(...privacyFindings(name, data.includes(0) ? '' : data.toString('utf8'), kind));
+ }
+ }
+ };
+ await visit(directory);
+ const work = await mkdtemp(path.join(os.tmpdir(), 'motion-secrets-'));
+ try {
+ const report = path.join(work, 'secrets.json'), ignore = path.join(work, 'empty.ignore'); await writeFile(ignore, '');
+ const env = { ...process.env }; delete env.GITLEAKS_CONFIG; delete env.GITLEAKS_CONFIG_TOML;
+ let failure;
+ try { await runFile(binary, ['dir', directory, '--no-banner', '--redact', '--ignore-gitleaks-allow', '--gitleaks-ignore-path', ignore,
+ '--config', path.join(root, '.github/gitleaks.toml'), '--report-format', 'json', '--report-path', report], { cwd: work, env }); }
+ catch (error) { failure = error; }
+ let secrets;
+ try { secrets = JSON.parse(await readFile(report, 'utf8')); }
+ catch { throw new Error('Credential scanner did not produce a valid report'); }
+ for (const hit of secrets) findings.push({ path: path.relative(directory, hit.File), rule: hit.RuleID, line: hit.StartLine });
+ assert(!failure || secrets.length, 'Credential scanner failed before completing');
+ // Never expose matched values or the scanner's raw stdout/report.
+ if (findings.length) throw new Error('Release content rejected: ' + JSON.stringify(findings));
+ return { status: 'passed', kind, files, bytes, scanner: `gitleaks-${scannerVersion}`,
+ policySHA256: createHash('sha256').update(await readFile(path.join(root, '.github/gitleaks.toml'))).update(await readFile(fileURLToPath(import.meta.url))).digest('hex') };
+ } finally { await rm(work, { recursive: true, force: true }); }
+}
+
+export async function scanSource(source, binary) {
+ const names = (await runFile('git', ['ls-files', '-z'], { cwd: source })).split('\0').filter(Boolean);
+ const work = await mkdtemp(path.join(os.tmpdir(), 'motion-source-scan-'));
+ try {
+ for (const name of names) {
+ assert(!name.split('/').includes('..') && !path.isAbsolute(name), 'Unsafe tracked path');
+ const file = path.join(source, name); assert((await lstat(file)).isFile(), 'Tracked links are forbidden');
+ await mkdir(path.dirname(path.join(work, name)), { recursive: true }); await cp(file, path.join(work, name));
+ }
+ return await scanTree(work, 'source', binary);
+ } finally { await rm(work, { recursive: true, force: true }); }
+}
+
+export async function scanPackage(tgz, binary) {
+ const work = await mkdtemp(path.join(os.tmpdir(), 'motion-package-scan-'));
+ try {
+ await unpackChecked(tgz, path.join(work, 'outer'));
+ const outer = path.join(work, 'outer/package');
+ const pkg = JSON.parse(await readFile(path.join(outer, 'package.json')));
+ assert.equal(pkg.name, '@openmotion/app'); assert.equal(pkg.private, false);
+ const manifest = JSON.parse(await readFile(path.join(outer, 'payload/release-npm.json')));
+ assert.equal(manifest.format, 'npm'); assert.equal(manifest.templateEnvironment, 'prod'); assert.equal(manifest.version, pkg.version);
+ const appName = manifest.application.url.replace(/^\.\//, ''); assert.equal(path.basename(appName), appName);
+ const appArchive = path.join(outer, 'payload', appName); assert.equal(await sha256(appArchive), manifest.application.sha256);
+ await unpackChecked(appArchive, path.join(work, 'application'));
+ assert.equal(await sha256(path.join(work, 'application/package-lock.json')), manifest.locks.npm);
+ assert.equal(await sha256(path.join(work, 'application/scripts/runtime-lock.json')), manifest.locks.native);
+ const applicationPkg = JSON.parse(await readFile(path.join(work, 'application/package.json'))); assert.equal(applicationPkg.version, pkg.version);
+ const reports = await Promise.all([scanTree(path.join(work, 'outer'), 'package', binary), scanTree(path.join(work, 'application'), 'package', binary)]);
+ return { status: 'passed', version: pkg.version, tgzSHA256: await sha256(tgz), applicationSHA256: manifest.application.sha256, reports };
+ } finally { await rm(work, { recursive: true, force: true }); }
+}
+
+if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
+ const [command, input, output, binary] = process.argv.slice(2);
+ if (command === 'install') console.log(await installScanner(path.resolve(input)));
+ else {
+ assert(['source', 'package'].includes(command) && input && output && binary, 'Usage: motion-scan.mjs source|package <input> <report> <gitleaks>');
+ await writeJSON(output, await (command === 'source' ? scanSource(path.resolve(input), binary) : scanPackage(path.resolve(input), binary)));
+ console.log('Release content scan passed');
+ }
+}
diff --git a/.github/scripts/publish-install-guide.mjs b/.github/scripts/publish-install-guide.mjs
index fa761a42..0cf3d19d 100644
--- a/.github/scripts/publish-install-guide.mjs
+++ b/.github/scripts/publish-install-guide.mjs
@@ -18,7 +18,7 @@ export function storagePlan(record, { endpoint, bucket, publicOrigin }) {
return { endpoint: api.origin, bucket, publicOrigin: origin.origin, versionKey: `${prefix}/${record.version}/install.md`, legacyVersionKey: `${prefix}/versions/${record.version}/install.md`, fixedKey: `${prefix}/install.md` };
}
-export async function publishGuide(directory, config, { run = runFile, fetcher = fetch } = {}) {
+export async function publishGuide(directory, config, { run = runFile, fetcher = fetch, promote = true } = {}) {
const file = path.join(directory, 'install.md'), record = JSON.parse(await readFile(path.join(directory, 'install-record.json'), 'utf8'));
assert.equal(record.candidate, false, 'Build previews cannot be published');
assert.equal(await sha256(file), record.guideSHA256, 'Generated guide changed after validation');
@@ -44,6 +44,11 @@ export async function publishGuide(directory, config, { run = runFile, fetcher =
if (existing) assert(existing.bytes.equals(expected), 'An immutable version already has different installation instructions');
else await put(plan.versionKey, ['--if-none-match', '*'], 'public, max-age=31536000, immutable');
await verifyPublic(plan.versionKey);
+ if (!promote) {
+ const publication = { ...record, ...plan, phase: 'version-verified', promoted: false };
+ await writeJSON(path.join(directory, 'publication.json'), publication);
+ return publication;
+ }
const previous = await get(plan.fixedKey, path.join(work, 'previous.md'));
if (previous) {
assert(previous.etag, 'Existing guide requires an ETag for conditional promotion');
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index dc2c86a3..a1428106 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -22,18 +22,6 @@ on:
description: 'Publication is disabled during migration; leave unchecked'
type: boolean
default: false
- install_guide_package:
- description: 'Already-published npm package; must match packages/npm/package.json'
- type: string
- default: '@openmotion/app'
- install_guide_version:
- description: 'Exact accepted npm version; non-empty selects guide validation instead of rebuilding the application'
- type: string
- default: ''
- upload_install_guide:
- description: 'Upload the verified guide using the configured repository R2 credentials'
- type: boolean
- default: false
permissions:
contents: read
@@ -44,7 +32,6 @@ concurrency:
jobs:
standalone:
- if: github.event_name != 'workflow_dispatch' || inputs.install_guide_version == ''
runs-on: ubuntu-24.04
timeout-minutes: 40
defaults:
@@ -70,14 +57,17 @@ jobs:
env:
PACKAGE_FORMAT: ${{ inputs.format || 'npm' }}
PUBLISH: ${{ inputs.publish || false }}
- UPLOAD_GUIDE: ${{ inputs.upload_install_guide || false }}
run: |
if [ "$PUBLISH" = true ]; then echo 'Motion publishing is disabled during migration.' >&2; exit 1; fi
- if [ "${UPLOAD_GUIDE:-false}" = true ]; then echo 'An exact install_guide_version is required for guide upload.' >&2; exit 1; fi
case "$PACKAGE_FORMAT" in
npm|full) ;;
*) echo 'Unknown package format' >&2; exit 1 ;;
esac
+ - name: Scan tracked source and test release controls without publication credentials
+ run: |
+ node .github/scripts/motion-scan.mjs install "$RUNNER_TEMP/scanner"
+ node .github/scripts/motion-scan.mjs source . "$RUNNER_TEMP/source-scan.json" "$RUNNER_TEMP/scanner/gitleaks"
+ node --test tests/release-workflows.test.mjs tests/release-scan.test.mjs
- name: Install locked Motion dependencies
run: npm ci --no-audit --no-fund
- name: Check and build Studio
@@ -116,6 +106,7 @@ jobs:
version=$(node scripts/test-package.mjs version "$GITHUB_RUN_NUMBER" "${GITHUB_RUN_ATTEMPT:-1}")
candidate=$(node --input-type=module -e 'import fs from "node:fs"; const m=JSON.parse(fs.readFileSync(process.argv[1]));process.stdout.write(m.installer.url.replace(/^\.\//,""));' "dist/$version/release-npm.json")
node --experimental-strip-types scripts/install-guide.mjs "dist/$version/$candidate" .artifacts/install-guide --candidate
+ node .github/scripts/motion-scan.mjs package "dist/$version/$candidate" "$RUNNER_TEMP/package-scan.json" "$RUNNER_TEMP/scanner/gitleaks"
- name: Retain candidate installation guide for review
if: (inputs.format || 'npm') == 'npm' && (inputs.template_environment || 'prod') == 'prod'
uses: actions/[email protected]
@@ -130,107 +121,3 @@ jobs:
- name: Record validation scope
run: |
echo 'Motion artifacts were built and checked; the candidate guide is a review artifact only. No npm, R2 or Release publication occurred.' >> "$GITHUB_STEP_SUMMARY"
-
- install-guide-validation:
- if: github.event_name == 'workflow_dispatch' && inputs.install_guide_version != ''
- runs-on: ubuntu-24.04
- timeout-minutes: 10
- env:
- GUIDE_PACKAGE: ${{ inputs.install_guide_package }}
- GUIDE_VERSION: ${{ inputs.install_guide_version }}
- GUIDE_DIRECTORY: .artifacts/install-guide-validated
- outputs:
- channel: ${{ steps.identity.outputs.channel }}
- steps:
- - uses: actions/[email protected]
- with:
- ref: ${{ github.sha }}
- - uses: actions/setup-node@v6
- with:
- node-version: '26.11.1'
- - name: Validate exact package selection
- id: identity
- run: |
- node --experimental-strip-types --input-type=module <<'JS'
- import { appendFileSync } from 'node:fs';
- import { validateGuideSpec } from './scripts/install-guide.mjs';
- const channel = validateGuideSpec(process.env.GUIDE_PACKAGE, process.env.GUIDE_VERSION);
- appendFileSync(process.env.GITHUB_OUTPUT, `channel=${channel}\n`);
- JS
- - name: Fetch the actual published package without running its scripts
- run: |
- mkdir -p "$RUNNER_TEMP/motion-guide-package"
- npm pack "$GUIDE_PACKAGE@$GUIDE_VERSION" --ignore-scripts --json --pack-destination "$RUNNER_TEMP/motion-guide-package" > "$RUNNER_TEMP/motion-guide-package/pack.json"
- candidate=$(node --input-type=module -e 'import fs from "node:fs";import path from "node:path";const [p]=JSON.parse(fs.readFileSync(process.argv[1]));if(path.basename(p.filename)!==p.filename)throw Error("Unsafe npm filename");process.stdout.write(p.filename);' "$RUNNER_TEMP/motion-guide-package/pack.json")
- node --experimental-strip-types scripts/install-guide.mjs "$RUNNER_TEMP/motion-guide-package/$candidate" "$GUIDE_DIRECTORY"
- node --input-type=module <<'JS'
- import { readFileSync } from 'node:fs';
- import assert from 'node:assert/strict';
- const record=JSON.parse(readFileSync(process.env.GUIDE_DIRECTORY+'/install-record.json'));
- assert.equal(record.packageName,process.env.GUIDE_PACKAGE);
- assert.equal(record.version,process.env.GUIDE_VERSION);
- JS
- - name: Retain verified guide and immutable package identity
- uses: actions/[email protected]
- with:
- name: motion-install-guide-validated-${{ github.run_id }}-${{ github.run_attempt }}
- path: |
- ${{ env.GUIDE_DIRECTORY }}/install.md
- ${{ env.GUIDE_DIRECTORY }}/install-record.json
- include-hidden-files: true
- retention-days: 14
- if-no-files-found: error
-
- publish-install-guide:
- needs: install-guide-validation
- if: github.event_name == 'workflow_dispatch' && inputs.upload_install_guide == true
- runs-on: ubuntu-24.04
- timeout-minutes: 10
- concurrency:
- group: motion-install-guide-${{ needs.install-guide-validation.outputs.channel }}
- cancel-in-progress: false
- steps:
- - uses: actions/[email protected]
- with:
- ref: ${{ github.sha }}
- - uses: actions/setup-node@v6
- with:
- node-version: '26.11.1'
- - uses: actions/[email protected]
- with:
- name: motion-install-guide-validated-${{ github.run_id }}-${{ github.run_attempt }}
- path: ${{ runner.temp }}/motion-install-guide
- - name: Confirm the accepted channel still selects this exact version
- env:
- GUIDE_PACKAGE: ${{ inputs.install_guide_package }}
- GUIDE_VERSION: ${{ inputs.install_guide_version }}
- GUIDE_CHANNEL: ${{ needs.install-guide-validation.outputs.channel }}
- run: |
- expected=$(node -p "require('./packages/npm/package.json').name")
- if [ "$GUIDE_PACKAGE" != "$expected" ]; then echo 'The guide package must match packages/npm/package.json.' >&2; exit 1; fi
- tag=test
- if [ "$GUIDE_CHANNEL" = stable ]; then tag=latest; fi
- actual=$(npm view "$GUIDE_PACKAGE@$tag" version)
- if [ "$actual" != "$GUIDE_VERSION" ]; then echo 'The accepted npm channel does not select this exact version.' >&2; exit 1; fi
- - name: Upload versioned guide, then conditionally update and verify the fixed URL
- id: upload
- env:
- AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_RELEASES_AK }}
- AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_RELEASES_SK }}
- AWS_EC2_METADATA_DISABLED: 'true'
- AWS_MAX_ATTEMPTS: '3'
- AWS_PAGER: ''
- MOTION_R2_ENDPOINT: ${{ vars.CLOUDFLARE_R2_RELEASES_URL }}
- MOTION_R2_BUCKET: ${{ vars.CLOUDFLARE_R2_RELEASES_BUCKET }}
- MOTION_INSTALL_PUBLIC_ORIGIN: ${{ vars.CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN }}
- run: |
- aws --version
- node .github/scripts/publish-install-guide.mjs "$RUNNER_TEMP/motion-install-guide"
- - name: Retain publication state and prior instructions for recovery
- if: always()
- uses: actions/[email protected]
- with:
- name: motion-install-guide-publication-${{ github.run_id }}-${{ github.run_attempt }}
- path: ${{ runner.temp }}/motion-install-guide/
- retention-days: 30
- if-no-files-found: warn
diff --git a/.github/workflows/motion-candidate.yml b/.github/workflows/motion-candidate.yml
new file mode 100644
index 00000000..9a47afdc
--- /dev/null
+++ b/.github/workflows/motion-candidate.yml
@@ -0,0 +1,87 @@
+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`);
+ JS
diff --git a/.github/workflows/motion-publish-test.yml b/.github/workflows/motion-publish-test.yml
new file mode 100644
index 00000000..41664edb
--- /dev/null
+++ b/.github/workflows/motion-publish-test.yml
@@ -0,0 +1,187 @@
+name: Motion test publication
+
+on:
+ workflow_dispatch:
+ inputs:
+ candidate_run_id:
+ description: 'Successful Motion candidate build run ID'
+ type: string
+ required: true
+ tgz_sha256:
+ description: 'Accepted candidate tgz SHA256'
+ type: string
+ required: true
+ acceptance_sha256:
+ description: 'SHA256 of the completed internal acceptance record; no internal URL or private content'
+ type: string
+ required: 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: false
+
+permissions:
+ contents: read
+ actions: 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 }}
+
+jobs:
+ verify:
+ if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main'
+ runs-on: ubuntu-24.04
+ timeout-minutes: 15
+ steps:
+ - uses: actions/[email protected]
+ with:
+ ref: ${{ github.sha }}
+ fetch-depth: 0
+ persist-credentials: false
+ - uses: actions/setup-node@v6
+ with:
+ node-version: '26.11.1'
+ - name: Verify originating run, artifact digest, version and source; rescan
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ node .github/scripts/motion-release.mjs download "$RUNNER_TEMP/candidate"
+ git fetch origin feature/motion:refs/remotes/origin/feature/motion
+ node .github/scripts/motion-scan.mjs install "$RUNNER_TEMP/scanner"
+ node .github/scripts/motion-release.mjs rescan "$RUNNER_TEMP/candidate" "$PWD" "$RUNNER_TEMP/scanner/gitleaks"
+ - uses: actions/[email protected]
+ with:
+ name: verified-candidate-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate/
+ retention-days: 30
+ if-no-files-found: error
+
+ npm:
+ needs: verify
+ environment: motion-test-publish
+ runs-on: ubuntu-24.04
+ timeout-minutes: 15
+ permissions:
+ contents: read
+ id-token: write
+ steps:
+ - uses: actions/[email protected]
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
+ - uses: actions/setup-node@v6
+ with:
+ node-version: '26.11.1'
+ registry-url: 'https://registry.npmjs.org'
+ - uses: actions/[email protected]
+ with:
+ name: verified-candidate-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate
+ - name: Publish the accepted bytes with npm trusted publishing, or verify an identical existing version
+ run: node .github/scripts/motion-release.mjs npm "$RUNNER_TEMP/candidate"
+ - name: Retain npm publication state even after a partial failure
+ if: always()
+ uses: actions/[email protected]
+ with:
+ name: npm-publication-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate/npm-publication.json
+ retention-days: 30
+ if-no-files-found: warn
+
+ registry-install:
+ needs: npm
+ runs-on: ${{ matrix.runner }}
+ timeout-minutes: 40
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ - runner: macos-26
+ platform: darwin-arm64
+ - runner: windows-2025
+ platform: win32-x64
+ steps:
+ - uses: actions/[email protected]
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
+ - uses: actions/setup-node@v6
+ with:
+ node-version: '26.11.1'
+ - uses: actions/[email protected]
+ with:
+ name: verified-candidate-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate
+ - name: Anonymous exact-version cold installation and native MCP discovery
+ shell: bash
+ run: |
+ node .github/scripts/motion-release.mjs verify "$RUNNER_TEMP/candidate"
+ node .github/scripts/motion-registry-smoke.mjs "$RUNNER_TEMP/candidate"
+ - uses: actions/[email protected]
+ with:
+ name: registry-${{ matrix.platform }}-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate/registry-${{ matrix.platform }}.json
+ retention-days: 30
+ if-no-files-found: error
+
+ snapshot:
+ needs: registry-install
+ environment: motion-test-publish
+ runs-on: ubuntu-24.04
+ timeout-minutes: 15
+ steps:
+ - uses: actions/[email protected]
+ with:
+ ref: ${{ github.sha }}
+ persist-credentials: false
+ - uses: actions/setup-node@v6
+ with:
+ node-version: '26.11.1'
+ - uses: actions/[email protected]
+ with:
+ name: verified-candidate-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate
+ - uses: actions/[email protected]
+ with:
+ pattern: registry-*-${{ github.run_id }}-${{ github.run_attempt }}
+ merge-multiple: true
+ path: ${{ runner.temp }}/candidate
+ - uses: actions/[email protected]
+ with:
+ name: npm-publication-${{ github.run_id }}-${{ github.run_attempt }}
+ path: ${{ runner.temp }}/candidate
+ - name: Archive exact-version snapshots, verify canonical public bytes, then promote the default guide last
+ env:
+ AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_RELEASES_AK }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_RELEASES_SK }}
+ AWS_EC2_METADATA_DISABLED: 'true'
+ AWS_PAGER: ''
+ MOTION_R2_ENDPOINT: ${{ vars.CLOUDFLARE_R2_RELEASES_URL }}
+ MOTION_R2_BUCKET: ${{ vars.CLOUDFLARE_R2_RELEASES_BUCKET }}
+ MOTION_INSTALL_PUBLIC_ORIGIN: ${{ vars.CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN }}
+ run: node .github/scripts/motion-release.mjs archive "$RUNNER_TEMP/candidate"
+ - name: Retain the attempt, immutable release identity and previous default guide
+ if: always()
+ uses: actions/[email protected]
+ with:
+ name: release-record-${{ github.run_id }}-${{ github.run_attempt }}
+ path: |
+ ${{ runner.temp }}/candidate/release-record.json
+ ${{ runner.temp }}/candidate/release-attempt.json
+ ${{ runner.temp }}/candidate/publication.json
+ ${{ runner.temp }}/candidate/previous-install.md
+ retention-days: 30
+ if-no-files-found: warn
diff --git a/AGENTS.md b/AGENTS.md
index e855f3e6..8618bcd9 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -42,3 +42,9 @@ Phase one exposes eleven motion_ Tools (nine project tools plus catalog fetch an
## Template production and reuse
`motion-template-to-video` implements the default template route and reuses shared context/edit and managed-project revision protection. Unchanged requests can deliver the template's existing preview; edited content or missing previews use the appropriate render/verification path. `motion-video-to-template` separately produces a portable reusable template from a video; it does not replace ordinary video recreation. Visual acceptance belongs to the user. Repository work does not invoke production Skills.
+
+## 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.
+
+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.md
index 8ae6ef90..ca8d776d 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1,3 +1,9 @@
# Claude Code
Read and follow [AGENTS.md](AGENTS.md) before working in this repository. It is the shared source of instructions for all Agents.
+
+## 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.
+
+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/README.md b/docs/README.md
index a3370427..d1367088 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -21,6 +21,7 @@
- [npm-installation.md](npm-installation.md)
- [Agent installation guide source template](install.md)
- [test and stable acceptance](release-guide.md)
+- [Manual candidate build, test publication and immutable snapshots](release-workflows.md)
- [product/architecture.md](product/architecture.md)
- [product/media-generation-design.md](product/media-generation-design.md)
- [project-workspace.md](project-workspace.md)
diff --git a/docs/npm-installation.md b/docs/npm-installation.md
index 94b3b889..3fcbd77d 100644
--- a/docs/npm-installation.md
+++ b/docs/npm-installation.md
@@ -109,3 +109,5 @@ For defects, include exact package/app version, source SHA, OS/CPU, Node/Agent v
## Shared Agent installation entry
The hosted [installation guide template](install.md) provides the short Agent entry. Ordinary CI retains a candidate preview; the controlled guide mode fetches an already published exact npm version before any R2 upload. Repository R2 configuration, channel acceptance and an executable manual workflow entry are required before upload. See [hosted instruction publication](release-guide.md#hosted-installation-instructions).
+
+Maintainers: see [manual candidate and test publication workflows](release-workflows.md) for fixed source/version selection, immutable snapshots, registry verification and recovery. A candidate artifact is not a published npm version.
diff --git a/docs/product/architecture.md b/docs/product/architecture.md
index 83e5973d..49a1fb08 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
## 演进约束
-本地测试包按 mac-arm64 / win-x64 准备固定公开原生依赖。The application npm format is the default; complete platform ZIPs are backups. Native installation, Agent creation and human playback need separate evidence. Projects remain outside the package; ordinary CI builds and validates, and retains candidate installation-guide previews. A separate manual guide mode can verify a published npm version and, through an explicit default-off upload option using repository R2 configuration, upload versioned/fixed instructions to R2. Package-name validation reads the source package metadata; no separate package variable or GitHub Environment is required. It does not publish npm or Release assets. The guide path, repository configuration and current default-branch dispatch limitation are documented in the release guide. See [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. 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).
已确认方向是继续支持多 Agent 接入、可编辑工程与一个工作区内的发现/制作闭环。
diff --git a/docs/release-guide.md b/docs/release-guide.md
index fc71fdc2..3cb7c150 100644
--- a/docs/release-guide.md
+++ b/docs/release-guide.md
@@ -62,24 +62,10 @@ Each defect needs exact package/source/OS/host/environment/catalog identity, pro
Ordinary 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.
-The existing `Motion standalone checks` workflow has a separate manual guide mode:
+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.
-1. Use `@openmotion/app` (the default `install_guide_package`) and an exact `install_guide_version` already published to npm. Leave `upload_install_guide=false` to fetch the registry package with lifecycle scripts disabled, render its guide and retain the result without R2 credentials.
-2. Before promoting an entry, complete registry/package acceptance and select that version through npm `test` or `latest`. A guide publication does not publish npm or move its tags.
-3. An explicitly authorized run with `upload_install_guide=true` uses the repository R2 configuration. It checks the package name against `packages/npm/package.json` and the current npm channel, creates immutable version instructions, verifies the public bytes, saves the prior fixed instructions and conditionally updates the fixed entry. The canonical public URLs must return matching bytes; a cache-busting URL does not prove the fixed entry is current.
-4. Test software uses `open-motion/dev/install.md`; stable uses `open-motion/install.md`. Exact-version instructions use `open-motion/dev/<exact-version>/install.md` and `open-motion/<exact-version>/install.md`, respectively. The unversioned entry can advance after acceptance; exact-version bytes are immutable and pin the same npm version. Previously published `/versions/<exact-version>/install.md` URLs remain available as legacy links. The `dev` path denotes the software test channel, not a switch to DEV template data.
+The short test/stable version URL contract and historical `/versions/` URLs remain as documented in that manual. Test software uses prod template defaults; private DEV template testing stays separate.
The configured destination bucket is `open-design-releases` and the public origin is `https://releases.open-design.ai`. After stable publication, the website can give the Agent a short prompt: "Read `https://releases.open-design.ai/open-motion/install.md`, install OpenMotion MCP and Skills for my current supported Agent host, preserve existing projects/settings, and report installation and preparation results." Use `https://releases.open-design.ai/open-motion/dev/install.md` for the test software channel. The test guide now pins `@openmotion/[email protected]`, with an immutable copy at `open-motion/dev/0.6.4-test.6/install.md`; both canonical public URLs were verified byte-for-byte against guide SHA256 `4b6f6b25c782c23d5529d225c6c0506d524b245a242f54d84fbf8d4dd61f4f05` after the [upload run](https://github.com/nexu-io/html-anything/actions/runs/42633147999). The short test.6 URL was added by [run 42638072025](https://github.com/nexu-io/html-anything/actions/runs/42638072025), with the same verified bytes as the retained legacy `/versions/0.6.4-test.6/install.md` URL. The older test.5 and test.4 immutable instructions remain unchanged; test.4 records the historical `@open-design/motion` name. Their existence does not imply those old npm versions were published. The stable entry is untouched and currently returns HTTP 404. Guide publication and npm publication remain separate operations.
-The upload remains a manual, default-off operation using the configured repository Secrets and Variables below. Package identity comes directly from `packages/npm/package.json`; no extra package-name variable or GitHub Environment is required. PR builds and guide validation do not reference publication secrets. No R2 resource or credential is created by this PR.
-
-| GitHub setting | Purpose |
-| --- | --- |
-| Secrets `CLOUDFLARE_R2_RELEASES_AK` / `CLOUDFLARE_R2_RELEASES_SK` | Bucket-scoped S3 credentials, mapped to the AWS CLI credential environment |
-| Variable `CLOUDFLARE_R2_RELEASES_URL` | R2 S3 HTTPS origin, mapped to `MOTION_R2_ENDPOINT` |
-| Variable `CLOUDFLARE_R2_RELEASES_BUCKET` | Approved destination bucket, mapped to `MOTION_R2_BUCKET` |
-| Variable `CLOUDFLARE_R2_RELEASES_PUBLIC_ORIGIN` | Public HTTPS origin, mapped to `MOTION_INSTALL_PUBLIC_ORIGIN`; routing must already work |
-
-The publisher uses the runner's AWS CLI with conditional writes and short fixed-entry caching. Publication records and prior public instructions are retained for 30 days. If readback fails, the run fails; inspect `publication.json` and the previous bytes before a separately authorized recovery. A network failure during `fixed-write-attempted` may mean the write completed: check storage rather than assuming nothing changed. Restore only the intended guide/channel; this does not downgrade installed clients or migrate projects.
-
-The repository default branch currently contains the legacy project and lacks the Motion manual-dispatch trigger. Do not assume a Run workflow button is available from this feature PR. Registering a trusted dispatch entry/default-branch workflow remains a separate administrator task; this PR does not change main.
+The new entries require separate trusted default-branch registration, a reviewed GitHub publication environment and npm trusted-publisher setup before use. Those administrative steps are not performed by this feature PR. Existing R2 credentials are reused only in the final snapshot job. No workflow was dispatched or package published as part of implementing these controls. See [setup, records and recovery](release-workflows.md).
diff --git a/docs/release-workflows.md b/docs/release-workflows.md
new file mode 100644
index 00000000..6e22e455
--- /dev/null
+++ b/docs/release-workflows.md
@@ -0,0 +1,93 @@
+# Manual candidate and test publication workflows
+
+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.
+
+## Administrator setup before first use
+
+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 minimal registration includes:
+
+- `.github/workflows/motion-candidate.yml` and `motion-publish-test.yml`.
+- `.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`.
+
+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.
+
+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/).
+
+Keep the existing R2 settings; only the final snapshot step receives the credentials:
+
+| Setting | Value or 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_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 a candidate without publication
+
+After review and integration into `feature/motion`, open **Actions → Motion candidate build → Run workflow**. Select `main` for the workflow and supply:
+
+| 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 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.
+
+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 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.
+
+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.
+
+## 2. Publish the accepted test candidate
+
+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.
+
+Open **Actions → Motion test publication → Run workflow**, use `main`, and supply:
+
+| 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 |
+
+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 pipeline then:
+
+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`. 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.
+
+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).
+
+## Immutable snapshots and moving entries
+
+| 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` |
+
+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.
+
+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.
+
+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.
+
+## Failure, retry and recovery
+
+- 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.
+- 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.
+
+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.
diff --git a/docs/templates/release-record.md b/docs/templates/release-record.md
new file mode 100644
index 00000000..5003ea58
--- /dev/null
+++ b/docs/templates/release-record.md
@@ -0,0 +1,49 @@
+# 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.
+
+## 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:
+- Template environment / Resource / locale / catalog publication version:
+- Supported OS / CPU / Node / npm / host versions:
+- Acceptance owner / independent reviewer / release operator:
+- Prior accepted compatible version or backup (or none):
+
+## Acceptance matrix
+
+Use PASS / FAIL / NOT RUN and link retained evidence. CI success alone cannot fill this table.
+
+| Check | macOS arm64 | Windows x64 | Evidence / accepted limitation |
+| --- | --- | --- | --- |
+| Exact candidate tgz fresh install in an isolated host/profile | NOT RUN | NOT RUN | |
+| Prepare Chromium, FFmpeg and ffprobe; repeat setup/cache reuse | NOT RUN | NOT RUN | |
+| Preserve existing projects/material and unrelated host settings | NOT RUN | NOT RUN | |
+| MCP Tools/resources and Skills discovery in the actual host | NOT RUN | NOT RUN | |
+| Template list/detail/clone; actual environment and catalog identity | NOT RUN | NOT RUN | |
+| Real Agent creation/adaptation, preview, edit, save and reopen | NOT RUN | NOT RUN | |
+| MP4 export with required audio, decoded technical verification | NOT RUN | NOT RUN | |
+| Normal-speed human visual/audio playback | NOT RUN | NOT RUN | |
+| Upgrade from prior usable version and compatible recovery | NOT RUN | NOT RUN | |
+
+## Release decision
+
+- Blockers / accepted non-blocking issues / owner / workaround:
+- 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):
+
+## Publication follow-up
+
+- Publication run / npm exact version / registry hash and integrity:
+- Native registry cold-install report per platform:
+- Immutable R2 version / release-record / guide URL and verified hash:
+- 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.
diff --git a/packages/npm/package.json b/packages/npm/package.json
index 01c388c8..433eb26a 100644
--- a/packages/npm/package.json
+++ b/packages/npm/package.json
@@ -1,5 +1,6 @@
{
"name": "@openmotion/app",
+ "repository": { "type": "git", "url": "git+https://github.com/nexu-io/html-anything.git" },
"version": "0.6.3-local.1",
"private": true,
"description": "OpenMotion application, MCP and Skills installer for local Agent hosts",
diff --git a/scripts/distribution.ts b/scripts/distribution.ts
index 5b80d96d..67af9d3e 100644
--- a/scripts/distribution.ts
+++ b/scripts/distribution.ts
@@ -11,7 +11,7 @@ export const distributionDocuments = [
'docs/product/architecture.md', 'docs/product/media-generation-design.md', 'tracking/README.md', 'tracking/INTEGRATION.md', 'tracking/posthog-geoip.hog',
'docs/agent-adapters.md', 'docs/browser-runtime.md', 'docs/design-system.md', 'docs/editor-fork.md',
'docs/hyperframes.md', 'docs/mcp-phase1-tools.md', 'docs/model-gateway.md', 'docs/motion-director.md',
- 'docs/motion-extension-scope.md', 'docs/npm-installation.md', 'docs/install.md', 'docs/release-guide.md', 'docs/project-workspace.md',
+ 'docs/motion-extension-scope.md', 'docs/npm-installation.md', 'docs/install.md', 'docs/release-guide.md', 'docs/release-workflows.md', 'docs/templates/release-record.md', 'docs/project-workspace.md',
'docs/repository-migration.md', 'docs/session-architecture.md', 'docs/shared-editor.md',
'docs/README.zh-CN.md', 'docs/usage.md', 'docs/motion-md.md', 'docs/motion-md.zh-CN.md',
'docs/collections/README.md', 'docs/collections/README.zh-CN.md',
diff --git a/scripts/install-guide.mjs b/scripts/install-guide.mjs
index e0d0b4e6..7f072eab 100644
--- a/scripts/install-guide.mjs
+++ b/scripts/install-guide.mjs
@@ -3,7 +3,7 @@ import { mkdir, readFile } from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { runFile, sha256, writeAtomic, writeJSON } from './runtime-assets.mjs';
-import { checkReleaseVersion } from './test-package.mjs';
+import { checkReleaseVersion } from './release-version.mjs';
export function validateGuideSpec(name, version) {
assert.match(name || '', /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/, 'Require an npm package name');
diff --git a/scripts/package-npm.mjs b/scripts/package-npm.mjs
index c00497df..88ec2760 100644
--- a/scripts/package-npm.mjs
+++ b/scripts/package-npm.mjs
@@ -7,7 +7,7 @@ import { PUPPETEER_REVISIONS } from 'puppeteer-core';
import { releaseProfile } from '../shared/mcp-registry.ts';
import { distributionFiles } from './distribution.ts';
import { packageTemplateConfig } from '../shared/template-config.ts';
-import { checkReleaseVersion } from './test-package.mjs';
+import { checkReleaseVersion } from './release-version.mjs';
const root = fileURLToPath(new URL('../', import.meta.url));
export function checkReleaseLocks(pkg, lockfile, runtime) {
diff --git a/scripts/release-version.mjs b/scripts/release-version.mjs
new file mode 100644
index 00000000..22022198
--- /dev/null
+++ b/scripts/release-version.mjs
@@ -0,0 +1,5 @@
+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]');
+}
diff --git a/scripts/test-package.mjs b/scripts/test-package.mjs
index 42b3eb4c..6f76a03e 100644
--- a/scripts/test-package.mjs
+++ b/scripts/test-package.mjs
@@ -8,6 +8,8 @@ import { spawn } from 'node:child_process';
import { releaseProfile } from '../shared/mcp-registry.ts';
import { distributionFiles } from './distribution.ts';
import { packageTemplateConfig } from '../shared/template-config.ts';
+import { checkReleaseVersion } from './release-version.mjs';
+export { checkReleaseVersion } from './release-version.mjs';
export const root = fileURLToPath(new URL('../', import.meta.url));
// Git Bash tar interprets C: as a remote host; use Windows' native archive tool.
@@ -18,9 +20,6 @@ export function targetInfo(target) {
assert(info, `Unsupported target: ${target}`);
return info;
}
-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 testVersion(base, run, attempt = '1') {
assert(/^\d+\.\d+\.\d+$/.test(base), 'Source version must be MAJOR.MINOR.PATCH');
assert(/^[1-9]\d*$/.test(String(run)) && /^[1-9]\d*$/.test(String(attempt)), 'Use positive run and attempt numbers');
diff --git a/tests/install-guide.test.ts b/tests/install-guide.test.ts
index f662a853..c6dd710d 100644
--- a/tests/install-guide.test.ts
+++ b/tests/install-guide.test.ts
@@ -115,39 +115,22 @@ test('candidate previews, changed guide bytes and unsafe storage destinations ca
assert.throws(() => storagePlan(record, { ...config, bucket: '../other' }));
});
-test('CI publication stays manual and default-off, with credentials limited to its upload job', async () => {
- const workflow = await readFile(new URL('../.github/workflows/ci.yml', import.meta.url), 'utf8');
- assert(workflow.includes('upload_install_guide:') && workflow.includes("type: boolean\n default: false"));
- const publish = workflow.split(' publish-install-guide:\n')[1];
- assert(publish.includes("github.event_name == 'workflow_dispatch' && inputs.upload_install_guide == true"));
- assert(publish.includes('needs: install-guide-validation'));
- assert(!publish.includes('environment:'), 'The upload must not depend on an extra GitHub Environment');
- assert(publish.includes('Confirm the accepted channel still selects this exact version'));
- assert(!workflow.split(' publish-install-guide:\n')[0].includes('secrets.'), 'Build and guide-validation jobs must not consume publication secrets');
- assert(workflow.includes('candidate installation guide') && workflow.includes('--candidate'));
+test('archive-only guide publication never accesses the moving default', async t => {
+ const { directory, record } = await fixture(t), store = storage(directory, record);
+ const result = await publishGuide(directory, config, { ...store, promote: false, run: async (command: string, args: string[]) => {
+ assert.notEqual(args[args.indexOf('--key') + 1], store.plan.fixedKey);
+ return store.run(command, args);
+ } });
+ 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');
});
-
-test('the actual upload gate reads the source package and accepted npm tag without an extra variable', async t => {
- const directory = await mkdtemp(path.join(os.tmpdir(), 'motion-guide-ci-'));
- t.after(() => rm(directory, { recursive: true, force: true }));
- const workflow = await readFile(new URL('../.github/workflows/ci.yml', import.meta.url), 'utf8');
- const step = workflow.split(' - name: Confirm the accepted channel still selects this exact version\n')[1].split(' - name:')[0];
- const script = step.split(' run: |\n')[1].replace(/^ {10}/gm, '');
- const packageName = JSON.parse(await readFile(new URL('../packages/npm/package.json', import.meta.url), 'utf8')).name;
- assert.equal(packageName, pkg.name);
- const calls = path.join(directory, 'calls');
- await writeFile(path.join(directory, 'npm'), '#!/bin/sh\nprintf "%s\\n" "$*" >> "$MOTION_GUIDE_CALLS"\nprintf "%s\\n" "$MOTION_GUIDE_ACCEPTED_VERSION"\n', { mode: 0o755 });
- const env = { ...process.env, PATH: directory + path.delimiter + process.env.PATH,
- GUIDE_PACKAGE: packageName, GUIDE_VERSION: pkg.version, GUIDE_CHANNEL: 'test',
- MOTION_GUIDE_CALLS: calls, MOTION_GUIDE_ACCEPTED_VERSION: pkg.version };
- for (const [channel, version, tag] of [['test', pkg.version, 'test'], ['stable', '0.6.4', 'latest']]) {
- await writeFile(calls, '');
- await runFile('bash', ['-c', script], { env: { ...env, GUIDE_CHANNEL: channel, GUIDE_VERSION: version, MOTION_GUIDE_ACCEPTED_VERSION: version } });
- assert.equal((await readFile(calls, 'utf8')).trim(), `view ${packageName}@${tag} version`);
- }
- await writeFile(calls, '');
- await assert.rejects(runFile('bash', ['-c', script], { env: { ...env, GUIDE_PACKAGE: '@other/motion' } }), /must match packages/);
- assert.equal(await readFile(calls, 'utf8'), '', 'A wrong package must fail before any registry lookup');
- await assert.rejects(runFile('bash', ['-c', script], { env: { ...env, MOTION_GUIDE_ACCEPTED_VERSION: '0.6.4-test.99' } }), /does not select this exact version/);
+test('PR CI has no publication credentials; publication requires the separate manual protected workflow', async () => {
+ const ci = await readFile(new URL('../.github/workflows/ci.yml', import.meta.url), 'utf8');
+ const 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(!workflow.split(' snapshot:\n')[0].includes('secrets.'));
});
diff --git a/tests/release-fixture.mjs b/tests/release-fixture.mjs
new file mode 100644
index 00000000..f7035d48
--- /dev/null
+++ b/tests/release-fixture.mjs
@@ -0,0 +1,41 @@
+import { mkdtemp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
+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';
+
+export async function candidateFixture(t) {
+ const work = await mkdtemp(path.join(os.tmpdir(), 'motion-release-test-'));
+ t.after(() => rm(work, { recursive: true, force: true }));
+ const root = fileURLToPath(new URL('../', import.meta.url)), build = path.join(work, 'build'), directory = path.join(work, 'candidate');
+ const commit = (await runFile('git', ['rev-parse', 'HEAD'], { cwd: root })).trim(), version = '0.6.4-test.99';
+ const app = path.join(work, 'app'), pkg = path.join(work, 'package');
+ await mkdir(path.join(app, 'scripts'), { recursive: true }); await mkdir(path.join(pkg, 'payload'), { recursive: true }); await mkdir(build);
+ await writeJSON(path.join(app, 'package.json'), { version }); await writeJSON(path.join(app, 'package-lock.json'), {});
+ await writeJSON(path.join(app, 'scripts/runtime-lock.json'), {});
+ const application = path.join(pkg, 'payload', `openmotion-application-${version}.tar.gz`);
+ await runFile('tar', ['-czf', application, '-C', app, '.']);
+ const manifest = { schemaVersion: 1, version, format: 'npm', templateEnvironment: 'prod', commit,
+ application: { url: './' + path.basename(application), sha256: await sha256(application) },
+ locks: { npm: await sha256(path.join(app, 'package-lock.json')), native: await sha256(path.join(app, 'scripts/runtime-lock.json')) },
+ runtime: { targets: { mac: { platform: 'darwin', arch: 'arm64', minimumOS: '26.0' } } } };
+ await writeJSON(path.join(pkg, 'payload/release-npm.json'), manifest);
+ await writeJSON(path.join(pkg, 'package.json'), { name: '@openmotion/app', version, private: false, bin: { openmotion: 'scripts/npm-installer.mjs' } });
+ const tgz = path.join(build, `openmotion-app-${version}.tgz`);
+ await runFile('tar', ['-czf', tgz, '-C', work, 'package']);
+ await writeJSON(path.join(build, 'release-npm.json'), { ...manifest, installer: { url: './' + path.basename(tgz), sha256: await sha256(tgz) } });
+ for (const name of ['source-scan.json', 'package-scan.json']) await writeJSON(path.join(build, name), { status: 'passed' });
+ const env = { MOTION_SOURCE_SHA: commit, MOTION_VERSION: version, GITHUB_SHA: 'b'.repeat(40),
+ GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/main`, GITHUB_RUN_ID: '123', GITHUB_RUN_ATTEMPT: '1' };
+ 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' };
+ 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 };
+}
diff --git a/tests/release-scan.test.mjs b/tests/release-scan.test.mjs
new file mode 100644
index 00000000..2aba686c
--- /dev/null
+++ b/tests/release-scan.test.mjs
@@ -0,0 +1,51 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { chmod, mkdtemp, mkdir, readFile, rm, symlink, writeFile } from 'node:fs/promises';
+import os from 'node:os';
+import path from 'node:path';
+import { archivePaths, privacyFindings, scanSource, scanPackage, unpackChecked } from '../.github/scripts/motion-scan.mjs';
+import { candidateFixture } from './release-fixture.mjs';
+import { runFile, sha256, writeJSON } from '../scripts/runtime-assets.mjs';
+
+test('privacy rules reject internal URLs, employee paths and private files without printing their values', () => {
+ for (const name of ['.env', 'nested/.env.production', '.npmrc', 'outputs/log.json', 'research/info.md', 'server.key']) assert(privacyFindings(name, '').length);
+ assert.equal(privacyFindings('.env.example', 'DUMMY=example').length, 0);
+ assert(privacyFindings('.env.example', '', 'package').length);
+ const url = 'https://' + 'workspace.' + 'feishu.cn/wiki/private';
+ const text = '/' + 'Users/' + 'employee/private/file';
+ assert.deepEqual(privacyFindings('README.md', url).map(x => x.rule), ['internal-link']);
+ assert.deepEqual(privacyFindings('README.md', text).map(x => x.rule), ['personal-path']);
+ assert(!JSON.stringify(privacyFindings('README.md', url)).includes('private'));
+ for (const name of ['../escape', '/absolute', 'C:/drive', 'safe/../../outside', 'bad\\file', 'bad\tname']) assert.throws(() => archivePaths(name));
+});
+
+async function scanner(t, findings = []) {
+ const work = await mkdtemp(path.join(os.tmpdir(), 'motion-scanner-test-')); t.after(() => rm(work, { recursive: true, force: true }));
+ const binary = path.join(work, 'scanner');
+ const script = `#!/usr/bin/env node\nimport{writeFileSync}from'node:fs'; const args=process.argv.slice(2); if(!args.includes('--redact')||!args.includes('--ignore-gitleaks-allow'))process.exit(2); writeFileSync(args[args.indexOf('--report-path')+1],JSON.stringify(${JSON.stringify(findings)}));process.exit(${findings.length ? 1 : 0});\n`;
+ await writeFile(binary, script); await chmod(binary, 0o755); return { work, binary };
+}
+
+test('tracked source is scanned without ignore-file bypasses; secret errors expose only rule/path/line', async t => {
+ const { work, binary } = await scanner(t, [{ File: 'source.txt', RuleID: 'fixture-secret', StartLine: 1, Secret: 'never-print-this' }]);
+ const source = path.join(work, 'source'); await mkdir(source);
+ await runFile('git', ['init', '-q', source]); await writeFile(path.join(source, 'source.txt'), 'synthetic fixture');
+ await runFile('git', ['add', '.'], { cwd: source });
+ await assert.rejects(scanSource(source, binary), error => error.message.includes('fixture-secret') && !error.message.includes('never-print-this'));
+ await symlink('source.txt', path.join(source, 'link')); await runFile('git', ['add', 'link'], { cwd: source });
+ await assert.rejects(scanSource(source, binary), /Tracked links/);
+});
+
+test('the scanner opens the nested application, rejects hidden private content and rejects linked archive entries', async t => {
+ const f = await candidateFixture(t), { binary } = await scanner(t);
+ assert.equal((await scanPackage(path.join(f.directory, f.candidate.tgz), binary)).status, 'passed');
+ await writeFile(path.join(f.app, '.env'), 'EXAMPLE=not-a-real-secret');
+ const appArchive = path.join(f.pkg, 'payload', f.manifest.application.url.slice(2));
+ await runFile('tar', ['-czf', appArchive, '-C', f.app, '.']);
+ await writeJSON(path.join(f.pkg, 'payload/release-npm.json'), { ...f.manifest, application: { ...f.manifest.application, sha256: await sha256(appArchive) } });
+ const tgz = path.join(f.work, 'hidden.tgz'); await runFile('tar', ['-czf', tgz, '-C', f.work, 'package']);
+ await assert.rejects(scanPackage(tgz, binary), /environment-file/);
+ await symlink('package.json', path.join(f.app, 'linked')); const linked = path.join(f.work, 'linked.tar.gz');
+ await runFile('tar', ['-czf', linked, '-C', f.app, '.']);
+ await assert.rejects(unpackChecked(linked, path.join(f.work, 'extracted')), /links and special/);
+});
diff --git a/tests/release-workflows.test.mjs b/tests/release-workflows.test.mjs
new file mode 100644
index 00000000..d1b56972
--- /dev/null
+++ b/tests/release-workflows.test.mjs
@@ -0,0 +1,115 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+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 { 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' };
+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) };
+
+test('publication and source selection fail closed on missing approval, mutable refs, wrong repository or 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 }));
+ 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/);
+});
+
+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('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);
+ 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/);
+ await writeFile(file, original); await writeFile(path.join(directory, 'provenance.json'), JSON.stringify({ head_sha: 'f'.repeat(40), runId: 123, attempt: 1 }));
+ await assert.rejects(verifyDownloaded(directory, candidate.tgzSHA256));
+});
+
+test('artifact download verifies GitHub ZIP digest and does not forward the credential to the signed URL', async t => {
+ const f = await candidateFixture(t), zip = path.join(f.work, 'candidate.zip');
+ await runFile('zip', ['-j', zip, ...['candidate.json', ...Object.keys(f.candidate.files)].map(name => path.join(f.directory, name))]);
+ const bytes = await readFile(zip), digest = 'sha256:' + createHash('sha256').update(bytes).digest('hex');
+ const fetcher = async (url, options) => {
+ const 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.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);
+ 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)));
+});
+
+function registry(candidate, exists = true, tag = candidate.version, latest = '0.5.0') {
+ return () => Response.json({ versions: exists ? { [candidate.version]: { dist: { integrity: candidate.integrity } } } : {}, 'dist-tags': { test: tag, latest } });
+}
+
+test('npm publishes only new exact bytes; identical retry and archive-only never write, mismatches fail', async t => {
+ const f = await candidateFixture(t); let calls = 0;
+ const run = async (command, args) => { calls++; assert.equal(command, 'npm'); assert(args.includes('--ignore-scripts') && args.includes('test')); 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);
+});
+
+function storage(candidate) {
+ const objects = new Map([['open-motion/dev/install.md', Buffer.from('previous entry')]]), 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];
+ if (op === 'get-object') { reads.push(key); if (!objects.has(key)) throw Error('NoSuchKey'); await writeFile(args.at(-1), objects.get(key)); return JSON.stringify({ ETag: '"etag"' }); }
+ assert.equal(op, 'put-object'); if (key === failKey) throw Error('simulated upload interruption');
+ assert(args.includes('--if-none-match') || args.includes('--if-match'));
+ if (args.includes('--if-none-match')) assert(!objects.has(key));
+ 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; } };
+}
+
+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');
+ 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');
+ 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/);
+});
+
+test('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 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('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/);
+ assert.equal(store.writes.length, 0);
+ const env = consumerEnvironment('/isolated', { PATH: '/bin', NODE_AUTH_TOKEN: 'example', GITHUB_TOKEN: 'example', AWS_ACCESS_KEY_ID: 'example', ACTIONS_ID_TOKEN_REQUEST_URL: 'example', npm_config_registry: 'https://private.invalid' });
+ assert(!env.NODE_AUTH_TOKEN && !env.GITHUB_TOKEN && !env.AWS_ACCESS_KEY_ID && !env.ACTIONS_ID_TOKEN_REQUEST_URL);
+ assert.equal(env.npm_config_registry, 'https://registry.npmjs.org/');
+});