@runeditrun/rer 0.2.27 → 0.2.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli/contract.mjs CHANGED
@@ -26,5 +26,5 @@ export const demoVerb = Object.freeze({ flags: [...commonFlags, '--port', '--hos
26
26
  // sign the owner in to, so no seed declares it and check does not ask for it.
27
27
  export const signinVerb = Object.freeze({ flags: [...commonFlags, '--environment', '--env-file'], effects: 'A one-time sign-in link for the hosted owner, without mail. Uses the Cloudflare credentials that deployed --environment (default production; from the environment or --env-file) to write a single-use grant for the recorded owner into that deployment\'s auth database, then prints the link once to this terminal; it is never saved. The link works once, only for that owner, expires within 15 minutes, and its use is recorded in the owner\'s audit log. Signed in this way, the owner can correct a wrong email in settings.' });
28
28
  export const aliases = Object.fromEntries([...Object.keys(verbs).filter(v => v !== 'install'), 'release', 'deps', 'rer'].map(name => [name, name === 'deps' ? 'install' : name === 'rer' ? null : name]));
29
- export const releaseFlags = ['--repo', '--project', '--repository', '--output', '--ref', '--public-base', '--dry-run', '--tag', '--clean-history', '--onto', '--env-file', '--no-queue'];
29
+ export const releaseFlags = ['--repo', '--project', '--repository', '--output', '--ref', '--public-base', '--dry-run', '--local-verify', '--tag', '--clean-history', '--onto', '--env-file', '--no-queue'];
30
30
  export const requiredHooks = ['preview', 'dependencies', 'build', 'migrate', 'start', 'health', 'owner', 'signIn', 'verify', 'deploy', 'portability', 'state', 'settings', 'input'];
package/cli/release.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  // Preserve release's accepted parser, producer, receipt and validation exits.
2
2
  const releaseHelp = `Usage: rer release --repo DIR --project PUBLISHER/NAME --repository GITHUB_URL --output NEW_DIR [FLAGS]
3
3
 
4
- Produce local release artifacts after frozen installation, verification and publication checks.
4
+ Produce local artifacts using the exact source commit's green GitHub Verify,
5
+ frozen installation, local build and publication checks.
5
6
  Without --tag, write a preview. This command never pushes, uploads or deploys.
6
7
 
7
8
  --repo DIR Source Git repository.
@@ -16,6 +17,8 @@ Without --tag, write a preview. This command never pushes, uploads or deploys.
16
17
  --tag [vVERSION] Prepare source artifacts and create a local annotated tag;
17
18
  an explicit tag must match the committed release version.
18
19
  --dry-run Run the real gates and suppress local tag creation.
20
+ --local-verify Run the seed's full verification locally instead of
21
+ requiring its exact commit's green GitHub Verify.
19
22
  --clean-history Prepare a parentless public export.
20
23
  --onto GITHUB_URL#BRANCH
21
24
  Prepare a public child of the destination's current branch;
@@ -45,6 +48,7 @@ export async function dispatchRelease(args) {
45
48
  else if (args[index] === '--tag') options.tag = args[index + 1]?.startsWith('v') ? args[++index] : true;
46
49
  else if (args[index] === '--clean-history') options.cleanHistory = true;
47
50
  else if (args[index] === '--dry-run') options.dryRun = true;
51
+ else if (args[index] === '--local-verify') options.localVerify = true;
48
52
  else if (['--repo', '--project', '--repository', '--output', '--ref', '--env-file', '--onto', '--public-base'].includes(args[index]) && args[index + 1] && !args[index + 1].startsWith('--'))
49
53
  options[args[index] === '--env-file' ? 'envFile' : args[index] === '--public-base' ? 'publicBase' : args[index].slice(2)] = args[++index];
50
54
  else throw Error('Invalid release arguments');
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.28
4
+
5
+ - `rer release` of a GitHub source uses the exact source commit's completed successful **Verify** run instead of re-running the seed's full verification locally. Only a `push` or `workflow_dispatch` run on the default branch, or on the version's release tag when that tag resolves remotely to the same commit, qualifies; PR runs, other SHAs, repositories, branches and unsuccessful runs do not. The receipt and site provenance record the repository, commit, workflow, run id and URL. The producer still installs frozen dependencies, runs the committed `build` script, scans publication history and packages locally; a local install or build failure still blocks. A missing green Verify, or a GitHub API or authentication failure, blocks and names the exact SHA.
6
+ - `rer release --local-verify` keeps the previous path: frozen install, `pnpm run verify` and, when declared, `pnpm run verify:release`. Sources with neither a GitHub origin nor a committed `rer-project.json.sourceRepository` keep that path without the flag.
7
+
8
+ ### Upgrade notes
9
+
10
+ - Update the exact rer package pin, or refresh vendored operating commands, to receive these changes.
11
+ - `rer release` now needs `gh` authenticated with read access to the source repository's Actions runs, and the exact commit pushed with a green Verify on the default branch or release tag. Pass `--local-verify` to verify on the producer machine instead.
12
+
3
13
  ## 0.2.27
4
14
 
5
15
  - `rer release` of an exact source commit scans source history against the repository's public history. When the checkout's origin is a confirmed public GitHub repository, its default branch and published tags are the scanner's public base, so findings already public are classified pre-existing and unpublished content still blocks. `--public-base GIT_URL#BRANCH` selects public history explicitly; it cannot be combined with `--onto` or `--clean-history`.
@@ -14,8 +14,8 @@ pnpm rer release --repo /path/to/seed --ref main \
14
14
  ```
15
15
 
16
16
  The `rer` bin and `node bin/rer.mjs` expose the same command. Node 22+, Python 3,
17
- Git, pnpm and tar are required. Use a full, clean seed clone with its declared
18
- package-manager version and browser prerequisites available. The producer reads
17
+ Git, pnpm and tar are required, along with authenticated `gh` for GitHub sources.
18
+ Use a full, clean seed clone with its declared package-manager version. The producer reads
19
19
  committed `seed.json`, `package.json`, `RELEASE.json`, `LICENSE`, `CONTRACT.md` and
20
20
  `AGENTS.md`. Version declarations must agree. `--project` declares the publishing
21
21
  identity; `--repository` is the credential-free public destination URL. Neither is inferred
@@ -47,18 +47,41 @@ and does not authorize publication. Legacy sources with neither declaration
47
47
  accept independent project and repository inputs, retain strict reference checks
48
48
  and cannot receive this INFO classification.
49
49
 
50
- It installs frozen dependencies and runs `pnpm run verify` in a disposable clone
51
- of the exact selected commit, then scans source history with publish-check.
52
- When the checkout's origin is a confirmed public repository, the scanner uses
53
- that source repository's advertised default branch and published tags as its public
54
- base. Already-public findings are classified pre-existing; unpublished content
55
- still blocks. Other sources retain complete local-ref history inspection.
56
- A verify that mutates tracked source fails.
57
- When declared in the committed package, it runs `pnpm run verify:release` after
58
- default verification succeeds. Keep capacity, maximum-size memory and load cases
59
- in that release-only script. Both dry runs and releases require it to pass;
60
- `gates.verify.release` records its result. Routine CI and default verification
61
- do not invoke it.
50
+ For a GitHub source, the producer uses the operator's existing `gh` authentication
51
+ to resolve the source repository's **Verify** workflow for the exact selected
52
+ commit. The source identity comes from its GitHub `origin` (HTTPS or SSH), or the
53
+ committed `rer-project.json.sourceRepository` when no GitHub origin is present;
54
+ it is independent of the publication destination. Only a completed successful
55
+ `push` or `workflow_dispatch` run on the default branch or the version's release
56
+ tag qualifies. The run and head repository must both match the source repository,
57
+ and a release tag must resolve remotely to the exact source commit. PR merge runs,
58
+ other SHAs, repositories, branches and unsuccessful runs cannot authorize release.
59
+ `gates.verify` records the source repository and commit, workflow id, `runId`,
60
+ `runUrl`, event, branch and conclusion in both receipt and site provenance.
61
+
62
+ CI is the verification wall: this path skips both local `verify` targets. It
63
+ still installs frozen dependencies and runs the committed `pnpm run build`
64
+ script, when declared, in a disposable clone. `gates.verify.install` and
65
+ `gates.verify.build` record those local results; failure or a tracked-source
66
+ mutation blocks release. Publication/history/annotation scans, exact-source
67
+ packaging, package integrity checks and the separate signing commands still run
68
+ locally. A missing green Verify blocks with the exact SHA and instructions to
69
+ push or re-run it. API/authentication failures also block, without substituting
70
+ local verification.
71
+
72
+ Pass **`--local-verify`** to explicitly retain the previous behavior: frozen
73
+ installation, `pnpm run verify`, then the committed `pnpm run verify:release`
74
+ when declared, with its result in `gates.verify.release`. Sources without a
75
+ GitHub origin or committed source identity also retain this behavior. This local
76
+ path needs the seed's browser prerequisites and any resources its verification
77
+ requires. Routine CI and default verification do not invoke the release-only
78
+ script.
79
+
80
+ Both paths then scan source history with publish-check. When the checkout's
81
+ origin is a confirmed public repository, the scanner uses that source
82
+ repository's advertised default branch and published tags as its public base.
83
+ Already-public findings are classified pre-existing; unpublished content still
84
+ blocks. Other sources retain complete local-ref history inspection.
62
85
  A passing step's receipt retains exit status and numeric final summaries from
63
86
  Node's spec/TAP reporters and Playwright's text reporters. A failing install,
64
87
  `verify` or `verify:release` step also keeps `output`: the last 40 lines (at most
@@ -88,7 +111,7 @@ commit and the exact source export. Existing tags are never changed. The command
88
111
  changes repository visibility, dispatches Actions, deploys or edits a site**.
89
112
  Publication and deployment retain their separate owner authorization.
90
113
 
91
- `--dry-run` performs the real install, verify and history scan and suppresses
114
+ `--dry-run` performs the selected verification path, local artifact steps and history scan and suppresses
92
115
  tag creation even with `--tag`. `--tag --dry-run` also prepares the source archive
93
116
  for inspection. Existing tags do not prevent previews.
94
117
  If gates fail, it exits 1, omits the source export, records BLOCKED in
@@ -0,0 +1,84 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { git } from './source.mjs';
3
+
4
+ const same = (left, right) => typeof left === 'string' && left.toLowerCase() === right.toLowerCase();
5
+ function identity(value) {
6
+ if (typeof value !== 'string') return undefined;
7
+ const scp = /^git@github\.com:([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/i.exec(value);
8
+ if (scp) return scp[1];
9
+ try {
10
+ const url = new URL(value.replace(/^git\+/, ''));
11
+ if (url.hostname.toLowerCase() !== 'github.com' || !['https:', 'http:', 'ssh:', 'git:'].includes(url.protocol) || url.search || url.hash) return undefined;
12
+ return /^\/([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/.exec(url.pathname)?.[1];
13
+ } catch { return undefined; }
14
+ }
15
+
16
+ export function githubSource(source) {
17
+ const origin = git(source.repo, 'remote').toString().split(/\s+/).includes('origin')
18
+ ? git(source.repo, 'remote', 'get-url', 'origin').toString().trim() : '';
19
+ const declared = source.entries.has('rer-project.json')
20
+ ? JSON.parse(source.bytes('rer-project.json')).sourceRepository : '';
21
+ return identity(origin) ?? identity(declared ?? '');
22
+ }
23
+
24
+ function api(path, paginated = false) {
25
+ const env = { ...process.env, GH_PROMPT_DISABLED: '1' };
26
+ delete env.GH_DEBUG; delete env.DEBUG;
27
+ return JSON.parse(execFileSync('gh', ['api', '--hostname', 'github.com',
28
+ ...(paginated ? ['--paginate', '--slurp'] : []), path],
29
+ { env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 60000, maxBuffer: 16 * 1024 * 1024 }));
30
+ }
31
+
32
+ function tagCommit(repository, tag) {
33
+ let object = api(`repos/${repository}/git/ref/tags/${encodeURIComponent(tag)}`).object;
34
+ // A tag can point at another annotated tag. Bound malformed/cyclic replies.
35
+ for (let depth = 0; object?.type === 'tag' && depth < 8; depth++) {
36
+ if (!/^[a-f0-9]{40}$/.test(object.sha)) return null;
37
+ object = api(`repos/${repository}/git/tags/${object.sha}`).object;
38
+ }
39
+ return object?.type === 'commit' ? object.sha : null;
40
+ }
41
+
42
+ export function githubVerify(source, repository) {
43
+ const result = { status: 'FAIL', provider: 'github', repository, commit: source.commit,
44
+ reason: 'github-verify-not-successful',
45
+ message: `No successful Verify run exists for ${repository} at exact source commit ${source.commit}. Push this commit to the default branch or release tag, or re-run Verify for this SHA with workflow_dispatch. Use --local-verify to run verification locally.` };
46
+ try {
47
+ const metadata = api(`repos/${repository}`);
48
+ if (!same(metadata.full_name, repository) || typeof metadata.default_branch !== 'string' || !metadata.default_branch) throw Error('repository');
49
+ const workflows = api(`repos/${repository}/actions/workflows?per_page=100`, true)
50
+ .flatMap(page => page.workflows).filter(workflow => workflow.name === 'Verify' && Number.isSafeInteger(workflow.id));
51
+ const rejected = new Set();
52
+ let checkedTag = false, tagSHA;
53
+ for (const workflow of workflows) {
54
+ const runs = api(`repos/${repository}/actions/workflows/${workflow.id}/runs?head_sha=${source.commit}&per_page=100`, true)
55
+ .flatMap(page => page.workflow_runs);
56
+ for (const run of runs) {
57
+ if (run.head_sha !== source.commit) { rejected.add('different source SHA'); continue; }
58
+ if (!same(run.repository?.full_name, repository) || !same(run.head_repository?.full_name, repository)) {
59
+ rejected.add('different source repository'); continue;
60
+ }
61
+ if (run.workflow_id !== workflow.id) { rejected.add('different workflow'); continue; }
62
+ if (!['push', 'workflow_dispatch'].includes(run.event)) { rejected.add('event must be push or workflow_dispatch'); continue; }
63
+ if (run.status !== 'completed' || run.conclusion !== 'success') {
64
+ rejected.add(run.status === 'completed' ? `conclusion ${['failure', 'cancelled', 'skipped', 'timed_out', 'neutral', 'action_required', 'stale'].includes(run.conclusion) ? run.conclusion : 'not success'}` : 'run not completed');
65
+ continue;
66
+ }
67
+ if (run.head_branch !== metadata.default_branch) {
68
+ if (run.head_branch !== source.tag) { rejected.add('neither default branch nor release tag'); continue; }
69
+ if (!checkedTag) { tagSHA = tagCommit(repository, source.tag); checkedTag = true; }
70
+ if (tagSHA !== source.commit) { rejected.add('release tag points at a different commit'); continue; }
71
+ }
72
+ if (!Number.isSafeInteger(run.id) || run.id <= 0) throw Error('run');
73
+ return { status: 'PASS', provider: 'github', repository: metadata.full_name, commit: source.commit,
74
+ workflowId: workflow.id, runId: run.id, runUrl: `https://github.com/${metadata.full_name}/actions/runs/${run.id}`,
75
+ event: run.event, branch: run.head_branch, conclusion: run.conclusion };
76
+ }
77
+ }
78
+ result.details = workflows.length ? (rejected.size ? [...rejected].join('; ') : 'No runs found for this SHA.') : 'No Verify workflow found.';
79
+ } catch {
80
+ result.reason = 'github-verify-unavailable';
81
+ result.details = 'GitHub Verify could not be resolved. Check gh authentication and repository access, then try again; no local verification was substituted.';
82
+ }
83
+ return result;
84
+ }
@@ -1,7 +1,8 @@
1
1
  import { mkdtempSync, rmSync, writeFileSync, cpSync } from 'node:fs';
2
2
  import { tmpdir } from 'node:os';
3
3
  import { resolve } from 'node:path';
4
- import { inspectSource, newOutput, git, command } from './source.mjs';
4
+ import { inspectSource, newOutput, git } from './source.mjs';
5
+ import { verifySource } from './source-verification.mjs';
5
6
  import { catalogue, writeCatalogue, sha256, json } from './catalogue.mjs';
6
7
  import { publicExport, cleanHistory, annotate, releaseMessage } from './export.mjs';
7
8
  import { publicationScan, validatePublicationDestination } from './publication-scan.mjs';
@@ -12,7 +13,7 @@ import { releasePublicBase } from './public-base.mjs';
12
13
  // Failure output belongs to the private receipt, not the site preview.
13
14
  const withoutOutput = gates => JSON.parse(JSON.stringify(gates, (key, value) => key === 'output' ? undefined : value));
14
15
 
15
- export async function release({ repo, ref = 'HEAD', output, project, repository, dryRun = false, tag = false, cleanHistory: clean = false, envFile, onto, publicBase }) {
16
+ export async function release({ repo, ref = 'HEAD', output, project, repository, dryRun = false, tag = false, cleanHistory: clean = false, envFile, onto, publicBase, localVerify = false }) {
16
17
  if (!/^[\w.-]+\/[\w.-]+$/.test(project ?? '')) throw Error('--project must be publisher/name');
17
18
  if (!/^https:\/\/github\.com\/[\w.-]+\/[\w.-]+(?:\.git)?$/i.test(repository ?? '')) throw Error('--repository must be a credential-free GitHub repository URL');
18
19
  if (onto !== undefined && clean) throw Error('--onto and --clean-history are mutually exclusive');
@@ -40,22 +41,7 @@ export async function release({ repo, ref = 'HEAD', output, project, repository,
40
41
  const checkout = resolve(temporary, 'seed');
41
42
  git(source.repo, 'clone', '--no-hardlinks', '--no-checkout', '--', source.repo, checkout);
42
43
  git(checkout, 'checkout', '--detach', source.commit);
43
- // Honour the seed's committed install policy. Base's native-build settings
44
- // are not interchangeable with pnpm 8's locked onlyBuiltDependencies.
45
- const install = await command('pnpm', ['install', '--frozen-lockfile'], checkout, { dependencies: true });
46
- const verify = install.status === 'PASS' ? await command('pnpm', ['run', 'verify'], checkout) : { status: 'FAIL', reason: 'frozen-install-failed', tests: 0, passed: 0, failed: 0, output: install.output };
47
- // Release-only scale and capacity cases stay outside routine CI. The
48
- // committed seed script is an additional gate in previews and releases.
49
- if (verify.status === 'PASS' && JSON.parse(source.bytes('package.json')).scripts['verify:release']) {
50
- verify.release = await command('pnpm', ['run', 'verify:release'], checkout);
51
- if (verify.release.status !== 'PASS') {
52
- verify.status = 'FAIL'; verify.exitCode = verify.release.exitCode;
53
- verify.reason = 'release-verification-failed';
54
- }
55
- }
56
- if (git(checkout, 'status', '--porcelain', '--untracked-files=no').length) {
57
- verify.status = 'FAIL'; verify.reason = 'verify-changed-tracked-source';
58
- }
44
+ const verify = await verifySource(source, checkout, localVerify);
59
45
  // Explicit clean-history publication scans every byte and ref of the actual
60
46
  // parentless export. Exact-source releases classify against public history
61
47
  // when available, retaining the selected source commit and tag identity.
@@ -0,0 +1,35 @@
1
+ import { command, git } from './source.mjs';
2
+ import { githubSource, githubVerify } from './github-verify.mjs';
3
+
4
+ export async function verifySource(source, checkout, localVerify) {
5
+ const repository = localVerify ? null : githubSource(source);
6
+ const verify = repository ? githubVerify(source, repository) : null;
7
+ // Refuse missing CI evidence before spending time installing or building.
8
+ if (verify?.status === 'FAIL') return verify;
9
+ const install = await command('pnpm', ['install', '--frozen-lockfile'], checkout, { dependencies: true });
10
+ if (verify) {
11
+ verify.install = install;
12
+ if (install.status !== 'PASS') {
13
+ verify.status = 'FAIL'; verify.reason = 'frozen-install-failed';
14
+ } else {
15
+ const scripts = JSON.parse(source.bytes('package.json')).scripts;
16
+ verify.build = scripts.build ? await command('pnpm', ['run', 'build'], checkout)
17
+ : { status: 'PASS', skipped: true, reason: 'no-build-script' };
18
+ if (verify.build.status !== 'PASS') { verify.status = 'FAIL'; verify.reason = 'release-build-failed'; }
19
+ }
20
+ }
21
+ const result = verify ?? (install.status === 'PASS' ? await command('pnpm', ['run', 'verify'], checkout)
22
+ : { status: 'FAIL', reason: 'frozen-install-failed', tests: 0, passed: 0, failed: 0, output: install.output });
23
+ // --local-verify preserves both of the seed's existing verification targets.
24
+ if (!verify && result.status === 'PASS' && JSON.parse(source.bytes('package.json')).scripts['verify:release']) {
25
+ result.release = await command('pnpm', ['run', 'verify:release'], checkout);
26
+ if (result.release.status !== 'PASS') {
27
+ result.status = 'FAIL'; result.exitCode = result.release.exitCode;
28
+ result.reason = 'release-verification-failed';
29
+ }
30
+ }
31
+ if (git(checkout, 'status', '--porcelain', '--untracked-files=no').length) {
32
+ result.status = 'FAIL'; result.reason = 'verify-changed-tracked-source';
33
+ }
34
+ return result;
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeditrun/rer",
3
- "version": "0.2.27",
3
+ "version": "0.2.28",
4
4
  "description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
5
5
  "license": "MIT",
6
6
  "type": "module",