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.

fix(release): align registration with Motion branch and short versions

罗高17e9fe11319b
diff --git a/.github/scripts/motion-release.mjs b/.github/scripts/motion-release.mjs
index af4a41e7..ce070a8b 100644
--- a/.github/scripts/motion-release.mjs
+++ b/.github/scripts/motion-release.mjs
@@ -22,13 +22,17 @@ 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) {
+function manualEntry(env, workflows) {
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.equal(env.GITHUB_REF, 'refs/heads/feature/motion', 'Select feature/motion in Run workflow for Motion operations');
+ assert(workflows.some(p => env.GITHUB_WORKFLOW_REF === `${repository}/${p}@refs/heads/feature/motion`), 'Require a trusted manual entry');
+}
+
+export function releaseInputs(env = process.env) {
+ manualEntry(env, [publicationWorkflow, recoveryWorkflow]);
assert(['publish-test', 'archive-only'].includes(env.MOTION_RELEASE_ACTION), 'Unknown release action');
const workflow = env.GITHUB_WORKFLOW_REF;
- assert([publicationWorkflow, recoveryWorkflow].some(p => workflow === `${repository}/${p}@refs/heads/main`), 'Require a trusted manual entry');
if (workflow.includes(recoveryWorkflow)) assert.equal(env.MOTION_RELEASE_ACTION, 'archive-only', 'Recovery never publishes or moves a channel');
if (env.MOTION_EXPECTED_SHA256) assert.match(env.MOTION_EXPECTED_SHA256, hashPattern);
assert.equal(env.MOTION_ACCEPTED, 'true', 'Explicit operator acceptance confirmation is required');
@@ -37,13 +41,15 @@ export function releaseInputs(env = process.env) {
}
export async function resolveCandidate(control, requested, version, env = process.env, run = runFile) {
- const commit = requested || (await run('git', ['rev-parse', 'refs/remotes/origin/feature/motion'], { cwd: control })).trim();
+ manualEntry(env, [candidateWorkflow]);
+ const commit = requested || env.GITHUB_SHA;
assert.match(commit, /^[a-f0-9]{40}$/, 'Use a full immutable source SHA');
if (!version) {
- assert(/^[1-9]\d*$/.test(env.GITHUB_RUN_ATTEMPT || ''), 'A positive GitHub run attempt is required');
- // main still contains the legacy application; read the frozen Motion source instead.
+ assert(/^[1-9]\d*$/.test(env.GITHUB_RUN_NUMBER || '') && /^[1-9]\d*$/.test(env.GITHUB_RUN_ATTEMPT || ''), 'Positive GitHub run and attempt numbers are required');
const source = JSON.parse(await run('git', ['show', `${commit}:package.json`], { cwd: control }));
- version = testVersion(source.version, env.GITHUB_RUN_ID, env.GITHUB_RUN_ATTEMPT);
+ // Continue after historical test.6: candidate run #1 used the retired long format.
+ version = testVersion(source.version, String(BigInt(env.GITHUB_RUN_NUMBER) + 5n), env.GITHUB_RUN_ATTEMPT);
+ if (env.GITHUB_RUN_ATTEMPT === '1') version = version.slice(0, -2);
}
await validateSource(control, commit, version, run);
return { commit, version };
@@ -126,7 +132,7 @@ export async function recordAuthorization(directory, inputs, fetcher = fetch, en
assert.equal(authorized.action, inputs.action); assert.equal(authorized.version, inputs.version);
const candidate = await verifyDownloaded(directory, inputs.expectedSHA256, inputs.version);
const run = await github(`/actions/runs/${env.GITHUB_RUN_ID}`, fetcher);
- assert.equal(String(run.id), env.GITHUB_RUN_ID); assert.equal(run.head_branch, 'main'); assert.equal(run.event, 'workflow_dispatch');
+ assert.equal(String(run.id), env.GITHUB_RUN_ID); assert.equal(run.head_branch, 'feature/motion'); assert.equal(run.event, 'workflow_dispatch');
assert.equal(run.head_repository?.full_name, repository); assert.equal(run.head_sha, env.GITHUB_SHA);
assert.equal(run.path.split('@')[0], env.GITHUB_WORKFLOW_REF.slice(repository.length + 1).split('@')[0]);
await writeJSON(path.join(directory, 'authorization.json'), authorizationReceipt(candidate, run, inputs.action));
@@ -198,7 +204,7 @@ export async function findCandidate(version, fetcher = fetch) {
const result = await github(`/actions/artifacts?name=${encodeURIComponent(name)}&per_page=100`, fetcher);
assert(result.total_count <= 100, 'Too many matching artifacts; refusing an incomplete lookup');
const matches = result.artifacts.filter(a => a.name === name && !a.expired);
- assert.equal(matches.length, 1, 'Candidate missing, expired or ambiguous; build a new unique version');
+ assert.equal(matches.length, 1, `Expected one unexpired candidate for ${version}; found ${matches.length}. Copy the exact version from a successful Motion candidate build. Changing this publication field cannot rename a candidate; build and accept a new unique version if needed.`);
assert(Number.isSafeInteger(matches[0].workflow_run?.id) && matches[0].workflow_run.id > 0);
return matches[0];
}
@@ -250,7 +256,7 @@ export async function publishNpm(directory, inputs, { fetcher = fetch, run = run
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) {
- // OIDC authenticates this publisher; its main SHA is not the prebuilt application's source.
+ // OIDC authenticates this publisher; its workflow SHA may differ from the prebuilt application's source.
await run('npm', ['publish', path.join(directory, candidate.tgz), '--access', 'public', '--tag', 'candidate', '--ignore-scripts', '--provenance=false', '--registry=https://registry.npmjs.org/']);
record.status = 'published-awaiting-registry'; await writeJSON(path.join(directory, 'npm-publication.json'), record);
}
diff --git a/.github/workflows/motion-candidate.yml b/.github/workflows/motion-candidate.yml
index 9e0c9b2d..994d0d1f 100644
--- a/.github/workflows/motion-candidate.yml
+++ b/.github/workflows/motion-candidate.yml
@@ -5,12 +5,12 @@ on:
workflow_dispatch:
inputs:
version:
- description: 'Optional override; empty uses next Motion patch-test.<run ID>.<attempt>; build only'
+ description: 'Optional override; empty uses short next Motion patch-test.N (reruns add .attempt); build only'
type: string
required: false
default: ''
source_sha:
- description: 'Optional reviewed full SHA integrated into feature/motion; empty freezes its current head'
+ description: 'Optional reviewed full SHA integrated into feature/motion; empty freezes the selected dispatch commit'
type: string
required: false
default: ''
@@ -21,7 +21,7 @@ permissions:
jobs:
candidate:
name: Build immutable candidate
- if: github.repository == 'nexu-io/html-anything' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/motion')
+ if: github.repository == 'nexu-io/html-anything'
runs-on: ubuntu-24.04
timeout-minutes: 45
env:
@@ -32,6 +32,12 @@ jobs:
HYPERFRAMES_FFMPEG_PATH: /usr/bin/ffmpeg
HYPERFRAMES_FFPROBE_PATH: /usr/bin/ffprobe
steps:
+ - name: Require Motion integration branch
+ run: |
+ if [ "$GITHUB_REF" != 'refs/heads/feature/motion' ]; then
+ echo '::error::Select feature/motion in Run workflow for Motion operations.'
+ exit 1
+ fi
- uses: actions/[email protected]
with:
path: control
diff --git a/.github/workflows/motion-publication-recovery.yml b/.github/workflows/motion-publication-recovery.yml
index 42ae95cd..6463a0e3 100644
--- a/.github/workflows/motion-publication-recovery.yml
+++ b/.github/workflows/motion-publication-recovery.yml
@@ -18,8 +18,18 @@ permissions:
actions: read
jobs:
+ select-ref:
+ if: github.repository == 'nexu-io/html-anything'
+ runs-on: ubuntu-24.04
+ steps:
+ - name: Require Motion integration branch
+ run: |
+ if [ "$GITHUB_REF" != 'refs/heads/feature/motion' ]; then
+ echo '::error::Select feature/motion in Run workflow for Motion operations.'
+ exit 1
+ fi
recover:
- if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main'
+ needs: select-ref
permissions:
contents: read
actions: read
diff --git a/.github/workflows/motion-publish-test.yml b/.github/workflows/motion-publish-test.yml
index 9b9e26c7..fb20cfbb 100644
--- a/.github/workflows/motion-publish-test.yml
+++ b/.github/workflows/motion-publish-test.yml
@@ -40,13 +40,19 @@ env:
jobs:
verify:
- if: github.repository == 'nexu-io/html-anything' && github.ref == 'refs/heads/main'
+ if: github.repository == 'nexu-io/html-anything'
runs-on: ubuntu-24.04
timeout-minutes: 15
outputs:
artifact_id: ${{ steps.artifact.outputs.artifact-id }}
tgz_sha256: ${{ steps.download.outputs.tgz_sha256 }}
steps:
+ - name: Require Motion integration branch
+ run: |
+ if [ "$GITHUB_REF" != 'refs/heads/feature/motion' ]; then
+ echo '::error::Select feature/motion in Run workflow for Motion operations.'
+ exit 1
+ fi
- uses: actions/[email protected]
with:
ref: ${{ github.sha }}
diff --git a/AGENTS.md b/AGENTS.md
index d56d1a48..a8aad619 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -16,7 +16,7 @@ This version has breaking changes — APIs, conventions, and file structure may
## Motion release controls
- Motion application development remains on `feature/motion`. Registering manual workflows on `main` does not move the application or authorize publication.
-- Manual candidate builds may run from `feature/motion` or `main`, with an optional version override; blank versions use the frozen Motion source baseline and GitHub run ID/attempt. Publication and recovery still execute trusted controls from `main`. Application source must be integrated into `feature/motion`; arbitrary branches cannot supply candidates.
+- Candidate build, test publication and recovery execute only from `feature/motion`; `main` registers their manual entries and fails explicitly when selected for execution. Blank candidate versions use the frozen dispatch source baseline and short workflow-counter `test.N` numbering, with a historical offset and an attempt suffix on reruns; an explicit override remains available. Application source must be integrated into `feature/motion`; arbitrary branches cannot supply candidates.
- Use Node 26.11.1 for control checks: `node --test tests/release-workflows.test.mjs tests/release-scan.test.mjs tests/install-guide.test.ts`. These tests need no workspace dependency installation and simulate publication services.
- New test candidates embed DEV defaults. npm publication uses `candidate` first; only matching successful Mac/Windows native reports permit the separate promotion job to advance `test`. Stable publication, `latest` promotion and Skills platform distribution remain out of scope.
- Follow [activation and operation](docs/motion-release-activation.md). Keep completed acceptance evidence private; do not merge or publish without the task's explicit authorization.
diff --git a/docs/motion-release-activation.md b/docs/motion-release-activation.md
index a6a5be32..ff65b747 100644
--- a/docs/motion-release-activation.md
+++ b/docs/motion-release-activation.md
@@ -8,7 +8,7 @@ The three manual workflows, their runtime helpers, installation/acceptance templ
The branch-selection/automatic-numbering follow-up copies the same shared control set from Motion commit `b0dd9ddd4af148deda90d42aab0732ba0ab8fe60`. This includes the already integrated #231 shared asset helper and install-guide updates; the candidate gate also runs its native-preparation regression. Empty versions derive from that candidate's frozen Motion source, never from the legacy main package version. Source manifests are not bumped by a build. Both matching PRs must be integrated before accepting feature/motion-produced candidates for publication.
-GitHub requires a manual workflow to exist on the default branch before its Run workflow entry is available. Candidate builds now allow `feature/motion` or `main`; publication and recovery still require execution from `main`. They fetch the Motion application from a reviewed commit integrated into `feature/motion`. See [GitHub manual workflows](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow).
+GitHub requires a manual workflow to exist on the default branch before its Run workflow entry is available. All three Motion manual entries now require **Use workflow from: feature/motion**. Selecting `main` fails before checkout or release work instead of silently fetching Motion from another branch. Main still registers the entries for GitHub to display them. The candidate source defaults to the selected dispatch SHA; an explicit reviewed source SHA must be integrated into `feature/motion`. Older valid main-produced candidates remain readable. See [GitHub manual workflows](https://docs.github.com/en/actions/how-tos/manage-workflow-runs/manually-run-a-workflow).
## Activation order
@@ -21,19 +21,19 @@ These are separate actions. Preparing or merging the registration does not autho
## Daily operation
-1. **Build:** Actions → Motion candidate build → Run workflow → select `feature/motion` (`main` also works). Leave version empty to generate the next Motion source patch plus `-test.<GitHub run ID>.<attempt>`, e.g. `0.6.4-test.42812345678.1` from source `0.6.3`; an explicit new test-version override remains available. Output metadata is stamped without changing source manifests. Read the resolved version from the successful summary; normally leave `source_sha` empty to freeze the latest `feature/motion` head once. A supplied full SHA must already be integrated into that branch. The build checks/scans source and archives, and retains the exact candidate for 30 days without npm OIDC or R2 credentials.
+1. **Build:** Actions → Motion candidate build → Run workflow → select `feature/motion`. Leave version empty to generate the next Motion source patch plus short `-test.N`, e.g. `0.6.4-test.7` from source `0.6.3`. The candidate workflow run number plus 5 continues after historical `test.6`; run #2 gives `test.7`, run #3 gives `test.8`, and a rerun adds `.2`, `.3`, etc. Failed builds and manual overrides consume numbers, so gaps are normal. Keep the workflow file/counter and offset stable; full run IDs remain in candidate records. An an explicit new test-version override remains available. Output metadata is stamped without changing source manifests. Read the resolved version from the successful summary; normally leave `source_sha` empty to freeze the selected `feature/motion` dispatch commit, including while queued. A supplied full SHA must already be integrated into that branch. The build checks/scans source and archives, and retains the exact candidate for 30 days without npm OIDC or R2 credentials.
2. **Download and accept:** Download `motion-candidate-<version>` from the successful run, extract it and give its directory to the Agent: “Follow candidate-install.md, verify candidate.json and the local tgz hash, install the exact local package with an isolated host profile, application home, data and Skills directories, complete prepare, and record actual results in a private copy of acceptance.md. Mark unrun checks NOT RUN. Do not publish.” Keep actual host loading, template/edit/export checks, real Agent creation and human playback separate. New public test software defaults to DEV templates; existing prod test versions retain their original defaults. The package exposes DEV routing configuration without private catalog snapshots or credentials. DEV network access/authentication is still required.
-3. **Publish:** Only after acceptance, Actions → Motion test publication → Run workflow → select `main`. Enter the exact accepted version from the build summary and confirm `accepted`; publication never generates a new version. This is the publication authorization, with no later independent approval dialog. Candidate provenance/hashes and scans are checked again; only the accepted tgz is published under npm `candidate`, then anonymously checked on Mac/Windows. A separate npm-OIDC-only job verifies both reports, their exact identity and installed DEV defaults, advances `test`, and reads the tag back. Only then does the credential-isolated R2 job archive snapshots and advance the default guide.
+3. **Publish:** Only after acceptance, Actions → Motion test publication → Run workflow → select `feature/motion`. Enter the exact accepted version from the build summary and confirm `accepted`; publication never generates or renames a version. If only a long-numbered candidate exists, build and accept a new short version first; typing a different publication version cannot rename it. This is the publication authorization, with no later independent approval dialog. Candidate provenance/hashes and scans are checked again; only the accepted tgz is published under npm `candidate`, then anonymously checked on Mac/Windows. A separate npm-OIDC-only job verifies both reports, their exact identity and installed DEV defaults, advances `test`, and reads the tag back. Only then does the credential-isolated R2 job archive snapshots and advance the default guide.
Before npm publication, use the candidate's **local** `candidate-install.md`, not the sibling registry `install.md`. After publication, the moving test guide is `https://releases.open-design.ai/open-motion/dev/install.md`; the immutable guide is `/open-motion/dev/<version>/install.md`. Stable publication, npm `latest` promotion and Skills platform/marketplace upload are not implemented by these controls. Five Skills are bundled and installed locally; that is not platform publication.
## Risk and recovery boundaries
- Registration is a capability change: users who can dispatch the trusted publication workflow can confirm and start a public release. There is no independent approval gate at this stage. Protect workflow edits and restrict operational access; the operator confirmation records intent, not proof of private testing.
-- Candidate workflows and control changes on both allowed branches require review. The producer branch/SHA is recorded and verified against GitHub run metadata; an arbitrary branch is rejected. Builds do not publish. The publication form defaults acceptance to false and rejects missing, expired, ambiguous or untrusted candidates, changed bytes and unintegrated source. Do not rebuild a published version or guess among duplicate candidate artifacts.
+- Candidate workflows and control changes on `feature/motion` and the registration on `main` require review. The producer branch/SHA is recorded and verified against GitHub run metadata; an arbitrary branch is rejected. Builds do not publish. The publication form defaults acceptance to false and rejects missing, expired, ambiguous or untrusted candidates, changed bytes and unintegrated source. Do not rebuild a published version or guess among duplicate candidate artifacts.
- npm publication cannot be rolled back atomically with later checks. The exact candidate and `candidate` tag are public before native verification. If either native check fails, `test` and the default guide remain unchanged. R2 failure after successful native/tag checks may leave `test` on the verified new version and the default guide on the prior one; this is not an atomic npm/R2 transaction. Inspect `test-promotion.json` and retained attempt records. Never use npm dist-tag as a dry-run against the real registry. Inspect retained records before using Re-run failed jobs; those retries reuse successful producer artifact IDs and never rebuild the candidate.
-- Motion snapshot recovery writes versioned R2 snapshots for an already published identical npm package; it does not build, publish npm, move tags or access the default guide. Channel rollback and client/data recovery require separate decisions.
+- Motion snapshot recovery also selects `feature/motion` and writes versioned R2 snapshots for an already published identical npm package; it does not build, publish npm, move tags or access the default guide. Channel rollback and client/data recovery require separate decisions.
- A single publication concurrency group and version/ETag checks protect channel promotion. Operate one release at a time; GitHub does not provide a durable FIFO queue.
- Disabling/removing these workflow registrations later does not undo a published npm version, restore user projects or revoke npm trust. Those are separate operations.
-The current [implementation manual](https://github.com/nexu-io/html-anything/blob/feature/motion/docs/release-workflows.md) is maintained with the Motion source; the original #214 snapshot above records registration provenance. For later control fixes, submit paired Motion/main PRs and compare all shared workflow/helper/template/test bytes before release. The maintainer of the control change owns both updates; a Motion-only fix does not update the executable main controls. Record both PRs and exact commits in the release review. Keep the full acceptance record internal. Real hosted workflow dispatch, npm OIDC, registry-native acceptance and R2/CDN writes need a separately authorized rehearsal; passing these control tests does not establish that those external integrations are active.
+The current [implementation manual](https://github.com/nexu-io/html-anything/blob/feature/motion/docs/release-workflows.md) is maintained with the Motion source; the original #214 snapshot above records registration provenance. For later control fixes, submit paired Motion/main PRs and compare all shared workflow/helper/template/test bytes before release. The maintainer of the control change owns both updates; a main-only registration fix does not update the executable feature/motion controls. Record both PRs and exact commits in the release review. Keep the full acceptance record internal. Real hosted workflow dispatch, npm OIDC, registry-native acceptance and R2/CDN writes need a separately authorized rehearsal; passing these control tests does not establish that those external integrations are active.
diff --git a/tests/release-fixture.mjs b/tests/release-fixture.mjs
index 8a45aece..c354dccc 100644
--- a/tests/release-fixture.mjs
+++ b/tests/release-fixture.mjs
@@ -33,8 +33,8 @@ export async function candidateFixture(t, branch = 'main') {
const provenance = { head_branch: branch, head_sha: env.GITHUB_SHA, runId: 123, attempt: 1 };
await writeJSON(path.join(directory, 'provenance.json'), provenance);
const inputs = { action: 'publish-test', version, accepted: true, expectedSHA256: candidate.tgzSHA256 };
- const publicationEnv = { GITHUB_REPOSITORY: repository, GITHUB_EVENT_NAME: 'workflow_dispatch', GITHUB_REF: 'refs/heads/main',
- GITHUB_RUN_ID: '800', GITHUB_SHA: env.GITHUB_SHA, GITHUB_WORKFLOW_REF: `${repository}/${publicationWorkflow}@refs/heads/main`,
+ const publicationEnv = { GITHUB_REPOSITORY: repository, GITHUB_EVENT_NAME: 'workflow_dispatch', GITHUB_REF: 'refs/heads/feature/motion',
+ GITHUB_RUN_ID: '800', GITHUB_SHA: env.GITHUB_SHA, GITHUB_WORKFLOW_REF: `${repository}/${publicationWorkflow}@refs/heads/feature/motion`,
MOTION_VERSION: version, MOTION_ACCEPTED: 'true', MOTION_RELEASE_ACTION: 'publish-test' };
const authorization = authorizationReceipt(candidate, { id: 800, run_attempt: 1, actor: { login: 'operator' } }, inputs.action);
await writeJSON(path.join(directory, 'authorization.json'), authorization);
diff --git a/tests/release-workflows.test.mjs b/tests/release-workflows.test.mjs
index aec9ca47..0db9aa77 100644
--- a/tests/release-workflows.test.mjs
+++ b/tests/release-workflows.test.mjs
@@ -12,25 +12,29 @@ import { consumerEnvironment } from '../.github/scripts/motion-registry-smoke.mj
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',
- GITHUB_WORKFLOW_REF: `${repository}/${publicationWorkflow}@refs/heads/main`, MOTION_VERSION: '0.6.4-test.99', MOTION_ACCEPTED: 'true', MOTION_RELEASE_ACTION: 'publish-test', MOTION_EXPECTED_SHA256: 'a'.repeat(64) };
+const valid = { GITHUB_REPOSITORY: repository, GITHUB_EVENT_NAME: 'workflow_dispatch', GITHUB_REF: 'refs/heads/feature/motion',
+ GITHUB_WORKFLOW_REF: `${repository}/${publicationWorkflow}@refs/heads/feature/motion`, MOTION_VERSION: '0.6.4-test.99', MOTION_ACCEPTED: 'true', MOTION_RELEASE_ACTION: 'publish-test', MOTION_EXPECTED_SHA256: 'a'.repeat(64) };
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-0.6.4-test.99', workflow_run: { id: 123 }, expired: false, size_in_bytes: 100, digest: 'sha256:' + 'a'.repeat(64) };
test('manual entry and source selection reject untrusted callers, mutable refs and non-test versions', async () => {
assert.equal(releaseInputs(valid).action, 'publish-test');
- for (const [key, value] of Object.entries({ GITHUB_REPOSITORY: 'fork/repo', GITHUB_EVENT_NAME: 'push', GITHUB_REF: 'refs/heads/feature/motion', GITHUB_WORKFLOW_REF: `${repository}/evil.yml@refs/heads/main`, MOTION_EXPECTED_SHA256: 'bad', MOTION_ACCEPTED: 'false', MOTION_VERSION: '0.6.4', MOTION_RELEASE_ACTION: 'stable' })) assert.throws(() => releaseInputs({ ...valid, [key]: value }));
- const recovery = { ...valid, GITHUB_WORKFLOW_REF: `${repository}/${recoveryWorkflow}@refs/heads/main` };
+ for (const [key, value] of Object.entries({ GITHUB_REPOSITORY: 'fork/repo', GITHUB_EVENT_NAME: 'push', GITHUB_REF: 'refs/heads/main', GITHUB_WORKFLOW_REF: `${repository}/evil.yml@refs/heads/feature/motion`, MOTION_EXPECTED_SHA256: 'bad', MOTION_ACCEPTED: 'false', MOTION_VERSION: '0.6.4', MOTION_RELEASE_ACTION: 'stable' })) assert.throws(() => releaseInputs({ ...valid, [key]: value }));
+ const recovery = { ...valid, GITHUB_WORKFLOW_REF: `${repository}/${recoveryWorkflow}@refs/heads/feature/motion` };
assert.throws(() => releaseInputs(recovery), /Recovery/);
assert.equal(releaseInputs({ ...recovery, MOTION_RELEASE_ACTION: 'archive-only' }).action, 'archive-only');
let called = false;
await validateSource('.', 'a'.repeat(40), '0.6.4-test.7', async (_, args) => { called = true; assert(args.includes('refs/remotes/origin/feature/motion')); }); assert(called);
for (const [sha, version] of [['main', '0.6.4-test.7'], ['a'.repeat(40), '0.6.4'], ['a'.repeat(40), '0.6.4-test.0']]) await assert.rejects(validateSource('.', sha, version, async () => { throw Error('must not run'); }));
await assert.rejects(validateSource('.', 'a'.repeat(40), '0.6.4-test.7', async () => { throw Error('not integrated'); }), /not integrated/);
- const resolved = await resolveCandidate('.', '', '0.6.4-test.7', {}, async (_, args) => args[0] === 'rev-parse' ? 'a'.repeat(40) + '\n' : '');
+ const buildEnv = { ...valid, GITHUB_SHA: 'a'.repeat(40), GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/feature/motion` };
+ const resolved = await resolveCandidate('.', '', '0.6.4-test.7', buildEnv, async (_, args) => { assert.notEqual(args[0], 'rev-parse'); });
assert.deepEqual(resolved, { commit: 'a'.repeat(40), version: '0.6.4-test.7' });
- await assert.rejects(resolveCandidate('.', 'main', '', {}, async () => { throw Error('must not run'); }), /immutable/);
- for (const env of [{}, { GITHUB_RUN_ID: '42812345678', GITHUB_RUN_ATTEMPT: '0' }, { GITHUB_RUN_ID: 'bad', GITHUB_RUN_ATTEMPT: '1' }]) {
- await assert.rejects(resolveCandidate('.', 'a'.repeat(40), '', env, async () => JSON.stringify({ version: '0.6.3' })), /positive/);
+ await assert.rejects(resolveCandidate('.', 'main', '', buildEnv, async () => { throw Error('must not run'); }), /immutable/);
+ for (const env of [{}, { GITHUB_RUN_NUMBER: '2', GITHUB_RUN_ATTEMPT: '0' }, { GITHUB_RUN_NUMBER: 'bad', GITHUB_RUN_ATTEMPT: '1' }]) {
+ await assert.rejects(resolveCandidate('.', 'a'.repeat(40), '', { ...buildEnv, ...env }, async () => JSON.stringify({ version: '0.6.3' })), /Positive/);
+ }
+ for (const patch of [{ GITHUB_REF: 'refs/heads/main' }, { GITHUB_REF: 'refs/heads/codex/unreviewed' }, { GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/main` }]) {
+ await assert.rejects(resolveCandidate('.', '', '0.6.4-test.7', { ...buildEnv, ...patch }, async () => { throw Error('Must reject before git'); }));
}
});
@@ -47,14 +51,15 @@ test('candidate CLI numbers the frozen Motion source, not the legacy control che
await writeFile(path.join(directory, 'package.json'), JSON.stringify({ version: '0.1.0' }));
const output = path.join(directory, 'output'), script = fileURLToPath(new URL('../.github/scripts/motion-release.mjs', import.meta.url));
for (const [source, version, run, attempt, expected] of [
- ['', '', '42812345678', '1', '0.6.4-test.42812345678.1'],
- [commit, '', '42812345678', '2', '0.6.4-test.42812345678.2'],
- ['', '', '42812345679', '1', '0.6.4-test.42812345679.1'],
+ ['', '', '2', '1', '0.6.4-test.7'],
+ [commit, '', '2', '2', '0.6.4-test.7.2'],
+ ['', '', '3', '1', '0.6.4-test.8'],
[commit, '0.6.5-test.1', '', '', '0.6.5-test.1'],
]) {
await writeFile(output, '');
await runFile(process.execPath, [script, 'source', directory], { env: { ...process.env, GITHUB_OUTPUT: output,
- MOTION_SOURCE_SHA: source, MOTION_VERSION: version, GITHUB_RUN_ID: run, GITHUB_RUN_ATTEMPT: attempt } });
+ ...valid, GITHUB_SHA: commit, GITHUB_WORKFLOW_REF: `${repository}/${candidateWorkflow}@refs/heads/feature/motion`,
+ MOTION_SOURCE_SHA: source, MOTION_VERSION: version, GITHUB_RUN_ID: '42812345678', GITHUB_RUN_NUMBER: run, GITHUB_RUN_ATTEMPT: attempt } });
assert.equal(await readFile(output, 'utf8'), `source_sha=${commit}\nversion=${expected}\n`);
assert(compareReleaseVersions(expected, '0.6.4-test.6') > 0);
}
@@ -79,12 +84,13 @@ test('version lookup uses the exact artifact name and rejects missing, expired,
for (const artifacts of [[], [{ ...artifact, expired: true }], [artifact, { ...artifact, id: 457 }], [{ ...artifact, workflow_run: {} }]]) {
await assert.rejects(findCandidate('0.6.4-test.99', async () => Response.json({ total_count: artifacts.length, artifacts })));
}
+ await assert.rejects(findCandidate('0.6.4-test.7', async () => Response.json({ total_count: 0, artifacts: [] })), /0\.6\.4-test\.7; found 0[\s\S]*cannot rename/);
await assert.rejects(findCandidate('0.6.4-test.99', async () => Response.json({ total_count: 101, artifacts: [artifact] })), /incomplete/);
});
test('operator authorization requires explicit acceptance and records the actual manual caller without independent approval', async t => {
const f = await candidateFixture(t);
- const run = { ...origin, id: 800, path: publicationWorkflow, actor: { login: 'operator' }, triggering_actor: { login: 'rerunner' } };
+ const run = { ...origin, head_branch: 'feature/motion', id: 800, path: publicationWorkflow, actor: { login: 'operator' }, triggering_actor: { login: 'rerunner' } };
assert.equal(authorizationReceipt(f.candidate, run, 'publish-test').actor, 'rerunner');
assert.throws(() => authorizationReceipt(f.candidate, { ...run, actor: {}, triggering_actor: {} }, 'publish-test'));
const fetcher = async url => { assert(String(url).endsWith('/actions/runs/800')); return Response.json(run); };
@@ -93,7 +99,7 @@ test('operator authorization requires explicit acceptance and records the actual
assert.equal(record.publicationRun, 800); assert.equal(record.tgzSHA256, f.candidate.tgzSHA256);
assert.equal(record.actor, 'rerunner'); assert.equal(record.acceptanceConfirmed, true);
await assert.rejects(recordAuthorization(f.directory, f.inputs, fetcher, { ...f.env, MOTION_ACCEPTED: 'false' }), /acceptance/);
- for (const patch of [{ id: 801 }, { event: 'push' }, { head_branch: 'feature/motion' }, { head_sha: 'f'.repeat(40) }, { path: candidateWorkflow }, { head_repository: { full_name: 'fork/repo' } }]) {
+ for (const patch of [{ id: 801 }, { event: 'push' }, { head_branch: 'main' }, { head_sha: 'f'.repeat(40) }, { path: candidateWorkflow }, { head_repository: { full_name: 'fork/repo' } }]) {
await assert.rejects(recordAuthorization(f.directory, f.inputs, async () => Response.json({ ...run, ...patch }), f.env));
}
});
@@ -156,7 +162,7 @@ function registry(candidate, exists = true, tag = candidate.version, latest = '0
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;
assert.notEqual(f.candidate.sourceCommit, f.candidate.workflow.sha, 'Application and workflow source identities are independent');
- const run = async (command, args) => { calls++; assert.equal(command, 'npm'); assert(args.includes('--ignore-scripts') && args.includes('candidate')); assert(args.includes('--provenance=false'), 'Do not attest the publication main SHA as the prebuilt application source'); assert.equal(args[1], path.join(f.directory, f.candidate.tgz)); };
+ const run = async (command, args) => { calls++; assert.equal(command, 'npm'); assert(args.includes('--ignore-scripts') && args.includes('candidate')); assert(args.includes('--provenance=false'), 'Do not attest the publication workflow SHA as the prebuilt application source'); assert.equal(args[1], path.join(f.directory, f.candidate.tgz)); };
await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate, false), env: f.env }); assert.equal(calls, 1);
await publishNpm(f.directory, f.inputs, { run, fetcher: registry(f.candidate), env: f.env });
await assert.rejects(publishNpm(f.directory, f.inputs, { run, fetcher: registry({ ...f.candidate, integrity: 'different' }), env: f.env }), /different bytes/); assert.equal(calls, 1);
@@ -265,7 +271,13 @@ test('daily build and publication are separate manual entries without an indepen
const header = workflow.split('\njobs:\n')[0];
assert(build.includes('workflow_dispatch:') && build.includes('version:') && build.includes('source_sha:'));
assert(build.includes('name: ' + candidateJobName) && build.includes('ref: ${{ steps.source.outputs.source_sha }}'));
- assert(build.includes("github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/motion'"));
+ for (const entry of [build, workflow, recovery]) {
+ assert(entry.includes('name: Require Motion integration branch'));
+ assert(entry.includes("Select feature/motion in Run workflow"));
+ const guard = entry.split(' - name: Require Motion integration branch\n')[1].split(/\n - |\n [a-z]/)[0];
+ assert(guard.includes("exit 1"));
+ }
+ assert(recovery.includes('needs: select-ref'));
assert(build.includes('--template-env=dev') && !build.includes('--template-env=prod'));
assert(build.includes('tests/native-runtime.test.ts'), 'Candidate checks include the integrated native-preparation regression');
assert(build.includes('HYPERFRAMES_BROWSER_PATH: /usr/bin/google-chrome') && build.includes('\"$HYPERFRAMES_BROWSER_PATH\" --version'));
@@ -285,6 +297,19 @@ test('daily build and publication are separate manual entries without an indepen
assert(recovery.includes('uses: ./.github/workflows/motion-publish-test.yml') && !recovery.includes('source_sha:'));
});
+test('each manual entry accepts only feature/motion before checkout or publication', async () => {
+ for (const name of ['motion-candidate', 'motion-publish-test', 'motion-publication-recovery']) {
+ const workflow = await readFile(new URL(`../.github/workflows/${name}.yml`, import.meta.url), 'utf8');
+ const step = workflow.split(' - name: Require Motion integration branch\n')[1].split(/\n - |\n [a-z]/)[0];
+ const script = step.split(' run: |\n')[1].split('\n').map(line => line.replace(/^ {10}/, '')).join('\n');
+ const run = ref => runFile('bash', ['-e', '-o', 'pipefail', '-c', script], { env: { ...process.env, GITHUB_REF: ref } });
+ await run('refs/heads/feature/motion');
+ for (const ref of ['refs/heads/main', 'refs/heads/legacy', 'refs/heads/codex/unreviewed', 'refs/tags/feature/motion']) {
+ await assert.rejects(run(ref), /Select feature\/motion/);
+ }
+ }
+});
+
test('rendering tools reuse installed packages, bound apt networking and stop on installation failure', async t => {
const directory = await mkdtemp(path.join(os.tmpdir(), 'motion-render-tools-'));
t.after(() => rm(directory, { recursive: true, force: true }));
@@ -380,7 +405,7 @@ test('an unexpected npm latest change stops promotion and consumer processes can
test('no-publication rehearsal carries one accepted candidate through npm and storage using simulated services only', async t => {
const f = await candidateFixture(t), store = storage(f.candidate);
- const run = { ...origin, id: 800, path: publicationWorkflow, actor: { login: 'operator' } };
+ const run = { ...origin, head_branch: 'feature/motion', id: 800, path: publicationWorkflow, actor: { login: 'operator' } };
const github = async url => { assert(String(url).endsWith('/actions/runs/800')); return Response.json(run); };
await writeFile(path.join(f.directory, 'authorization.json'), '{}');
let npmWrites = 0, tagWrites = 0, published = false, testTag = '0.6.4-test.1';