@runeditrun/rer 0.2.26 → 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/README.md CHANGED
@@ -126,13 +126,20 @@ rebuild preview. A build that regenerates its own files declares them as
126
126
  paths are not inputs, while any other file touched during the build is refused by name. Both use the same `.wrangler/state` and saved owner. Dev opens signed in through `RER_OPEN`, including with the legacy
127
127
  `--login` flag. Stop before changing modes.
128
128
 
129
- Local startup holds the checkout's exclusive operation lock until serving stops.
129
+ Setup, local import/restore, reset and local startup hold the checkout's exclusive
130
+ operation lock through completion (or until serving stops).
130
131
  Its state-holder inspection selects only regular files under `.wrangler/state`,
131
- including SQLite sidecars. Dev and demo give `lsof` three seconds to answer. A confirmed
132
+ including SQLite sidecars. Each local custody check gives inspection three seconds to answer. A confirmed
132
133
  holder is refused with its PID and process name. If inspection cannot answer,
133
- dev (including demo) continues under the held checkout lock; another
134
- cooperating launch cannot acquire it. This lock does not inventory unmanaged
135
- processes. Setup, reset and preview still require their state inspection to complete.
134
+ canonical-state commands probe existing SQLite databases with an immediate exclusive transaction,
135
+ then continue under the held checkout lock; another cooperating operation cannot
136
+ acquire it. A conflicting SQLite transaction is refused even when its PID could not
137
+ be inspected. The probe rolls back without changing rows. Neither proof inventories
138
+ idle unmanaged file handles or WAL readers. Keep the bounded inspection even when
139
+ the launch lock is free: skipping it would miss unmanaged state holders and saved
140
+ origin listeners that a completed inspection currently detects.
141
+ Demo uses the launch lock without opening canonical SQLite: probes can checkpoint
142
+ idle WAL or change read marks, and demo preserves every owner state byte.
136
143
  Stop dev or preview before build, verification or data transfer; use the
137
144
  documented `--stop` flag or Ctrl-C.
138
145
 
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', '--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/lifecycle.mjs CHANGED
@@ -49,16 +49,19 @@ async function runLifecycle(project, options, out, deployRedaction) {
49
49
  if (!project.adapter?.run) throw refuse('The first-party command adapter is unavailable. Restore the shared lifecycle adapter.');
50
50
  if (options.forwarded.length) throw refuse('First-party commands do not accept arbitrary forwarded arguments. Run rer VERB --help.');
51
51
  await stateSafety(project);
52
- if(options.verb==='setup')await refuseLegacyProcess(project,{verb:options.verb});
52
+ const { localOperation } = await shared('local/operation.mjs');
53
+ // The run site reads no local state: it builds beside a running rer dev.
54
+ if (!options.site) try { operation = await localOperation(project.root, process.env.RER_LOCAL_OPERATION); } catch (error) { throw refuse(error.message); }
55
+ if(options.verb==='setup'||options.verb==='import'&&(options.target??'local')==='local'){
56
+ const ownership=await refuseLegacyProcess(project,{verb:options.verb,operation});
57
+ if(ownership?.lockProof)out.progress('Local process inspection did not answer; continuing with the exclusive checkout launch lock.\n');
58
+ }
53
59
  if (options.verb === 'setup') {
54
60
  selected = await selectedOrigin(project, options, { setup: options.verb === 'setup' });
55
61
  if (options.verb === 'setup') {input = await setupInput(project, options, selected.vars, signal, { origin: selected.url });await dependencyInputs({project,input,origin:selected.url});}
56
62
  if (!selected.door) await availablePort(selected.host, selected.port, { root: project.root, saved: !selected.explicitPort && selected.savedOrigin !== undefined, verb:options.verb });
57
63
  if (options.verb === 'setup') announcePort(out, options, selected);
58
64
  }
59
- const { localOperation } = await shared('local/operation.mjs');
60
- // The run site reads no local state: it builds beside a running rer dev.
61
- if (!options.site) try { operation = await localOperation(project.root, process.env.RER_LOCAL_OPERATION); } catch (error) { throw refuse(error.message); }
62
65
  const { recoverInterrupted } = await shared('local/recovery.mjs');
63
66
  if (operation) await recoverInterrupted(project.root, operation);
64
67
  if (project.ownerReplacement) await replaceOwner(project, options, out);
package/cli/local.mjs CHANGED
@@ -66,7 +66,15 @@ async function safeTree(project, path) {
66
66
 
67
67
  export async function reset(project, options, out) {
68
68
  await stateSafety(project);
69
- await refuseLegacyProcess(project,{reset:true,verb:'reset'});
69
+ const { localOperation } = await shared('local/operation.mjs');
70
+ let operation;
71
+ try { operation = await localOperation(project.root); } catch (error) { throw refuse(error.message); }
72
+ try { return await resetHeld(project,options,out,operation); }
73
+ finally { await operation.release(); }
74
+ }
75
+
76
+ async function resetHeld(project,options,out,operation) {
77
+ await refuseLegacyProcess(project,{reset:true,verb:'reset',operation});
70
78
  const { strandedOriginals } = await shared('local/recovery.mjs');
71
79
  if ((await strandedOriginals(project.root)).length) throw refuse('An interrupted build holds private settings. Run rer build to recover them before reviewing reset.');
72
80
  // The seed's own safety check (legacy data it still has to recover, for
@@ -89,29 +97,32 @@ export async function reset(project, options, out) {
89
97
  }
90
98
  if (!confirmed) throw refuse('Reset requires explicit confirmation. Review the inventory, then pass --yes.');
91
99
  // The shared lock lives outside every removal path and remains held throughout.
92
- const { localOperation } = await shared('local/operation.mjs');
93
- let operation;
94
- try { operation = await localOperation(project.root); } catch (error) { throw refuse(error.message); }
95
- try {
96
- for (const path of inventory) { const absolute = await safeTree(project, path); if (absolute) await rm(absolute, { recursive: true, force: true }); }
97
- } finally { await operation.release(); }
100
+ for (const path of inventory) { const absolute = await safeTree(project, path); if (absolute) await rm(absolute, { recursive: true, force: true }); }
98
101
  return { paths: inventory };
99
102
  }
100
103
 
101
- export async function refuseLegacyProcess(project,{reset=false,verb='dev',operation}={}) {
104
+ export async function refuseLegacyProcess(project,{reset=false,verb='dev',operation,isolated=false}={}) {
105
+ // Every caller must keep this exclusive checkout proof through its operation.
106
+ const {localOperation}=await shared('local/operation.mjs');
107
+ if(!operation?.token)throw refuse('Local ownership inspection requires the checkout operation lock.');
108
+ await localOperation(project.root,operation.token);
102
109
  let selected;try{selected=await selectedOrigin(project,{});}catch(error){if(!reset)throw error;}
103
110
  // Confirmed reset can recover malformed settings; checkout/state custody is
104
111
  // still checked even when there is no usable saved origin.
105
112
  const {localProcessConflict,inspectionContext,uncheckedInspection}=await shared('process-diagnostics.mjs');
106
113
  // The front door holds a door origin's port, not this checkout.
107
114
  let conflict;
108
- try{conflict=await localProcessConflict(project.root,selected?.door?undefined:selected?.savedOrigin,inspectionContext({verb}));}
115
+ try{conflict=await localProcessConflict(project.root,selected?.door?undefined:selected?.savedOrigin,inspectionContext({verb,budgetMs:3000}));}
109
116
  catch(error){
110
- // Startup already holds the exclusive checkout operation through teardown.
111
- // An unanswered observation must not defeat that cooperating-launch proof.
112
- // Setup/reset retain their destructive-operation inspection requirement.
113
- if(operation?.token&&verb==='dev'&&uncheckedInspection(error))return {lockProof:true};
114
- throw error;
117
+ if(!uncheckedInspection(error))throw error;
118
+ // Demo serves isolated data. Even a read-only SQLite connection can update
119
+ // canonical WAL read marks, so its owner-state byte preservation forbids it.
120
+ if(!isolated){
121
+ const {sqliteCustody}=await shared('local/sqlite-custody.mjs');
122
+ const database=await sqliteCustody(project.root);
123
+ if(database)throw refuse(`Another process holds an active SQLite lock on ${database}. Process inspection did not identify its PID. Stop unmanaged local servers (including Wrangler), then retry. Use rer dev --stop or rer preview --stop for a registered server.`);
124
+ }
125
+ return {lockProof:true};
115
126
  }
116
127
  if(conflict)throw refuse(`A local process holds ${conflict.reason}: PID ${conflict.pid} (${conflict.command}). Stop it with kill -TERM ${conflict.pid}, then retry. Use rer dev --stop or rer preview --stop for a registered server.`);
117
128
  }
@@ -87,7 +87,7 @@ export async function managedServer(project,options,out,{clock={}}={}){
87
87
  await stateSafety(project);
88
88
  const {localOperation}=await shared('local/operation.mjs');
89
89
  try{operation=await localOperation(project.root);}catch(error){throw refuse(error.message);}
90
- const ownership=await refuseLegacyProcess(project,{verb:options.verb,operation});
90
+ const ownership=await refuseLegacyProcess(project,{verb:options.verb,operation,isolated:options.demo});
91
91
  if(ownership?.lockProof)out.progress('Local process inspection did not answer; continuing with the exclusive checkout launch lock.\n');
92
92
  const {recoverInterrupted}=await shared('local/recovery.mjs');await recoverInterrupted(project.root,operation);
93
93
  const {loadInstallerSeed}=await shared('setup-manifest.mjs');
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.
@@ -11,9 +12,13 @@ Without --tag, write a preview. This command never pushes, uploads or deploys.
11
12
  Credential-free https://github.com/<owner>/<repository> destination.
12
13
  --output NEW_DIR New output directory outside the source repository.
13
14
  --ref REF Selected committed source (default: HEAD).
15
+ --public-base REF Public history as GIT_URL#BRANCH for exact-source scans;
16
+ defaults to this public repository's default branch.
14
17
  --tag [vVERSION] Prepare source artifacts and create a local annotated tag;
15
18
  an explicit tag must match the committed release version.
16
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.
17
22
  --clean-history Prepare a parentless public export.
18
23
  --onto GITHUB_URL#BRANCH
19
24
  Prepare a public child of the destination's current branch;
@@ -43,8 +48,9 @@ export async function dispatchRelease(args) {
43
48
  else if (args[index] === '--tag') options.tag = args[index + 1]?.startsWith('v') ? args[++index] : true;
44
49
  else if (args[index] === '--clean-history') options.cleanHistory = true;
45
50
  else if (args[index] === '--dry-run') options.dryRun = true;
46
- else if (['--repo', '--project', '--repository', '--output', '--ref', '--env-file', '--onto'].includes(args[index]) && args[index + 1] && !args[index + 1].startsWith('--'))
47
- options[args[index] === '--env-file' ? 'envFile' : args[index].slice(2)] = args[++index];
51
+ else if (args[index] === '--local-verify') options.localVerify = true;
52
+ else if (['--repo', '--project', '--repository', '--output', '--ref', '--env-file', '--onto', '--public-base'].includes(args[index]) && args[index + 1] && !args[index + 1].startsWith('--'))
53
+ options[args[index] === '--env-file' ? 'envFile' : args[index] === '--public-base' ? 'publicBase' : args[index].slice(2)] = args[++index];
48
54
  else throw Error('Invalid release arguments');
49
55
  }
50
56
  if(args.includes('--no-queue')){const {shared}=await import('./shared.mjs');const {commandPolicy}=await shared('queue.mjs');const policy=await commandPolicy();try{if(!policy.ci)throw Error('Original CI required');}finally{await policy.close();}}
@@ -1,5 +1,27 @@
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
+
13
+ ## 0.2.27
14
+
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`.
16
+ - On a busy machine, a process-table read that outlives its ordinary bound is awaited for up to 25 more seconds with a `RER_PROCESS_INSPECTION_SLOW` warning, instead of failing a passing run's cleanup. Cleanup still fails only on owned processes observed alive.
17
+ - Setup, local import/restore, reset and local startup hold the checkout's exclusive operation lock through completion, and every local ownership check falls back to that lock proof when `lsof` does not answer within three seconds. Canonical-state commands then probe existing SQLite databases with an immediate exclusive transaction that rolls back, and refuse when another process holds a SQLite lock. Demo uses the lock proof without opening canonical SQLite.
18
+ - `modules/operator-auth/policy.d.mts` ships client-safe types for `normalizeEmail`, `emailDomain` and `safeReturnTo`.
19
+ - `DEMO.md` says that new visitors may get the previous demo version for several minutes after a deploy (about 7–9 minutes measured), so measure about 10 minutes after a demo deploy.
20
+
21
+ ### Upgrade notes
22
+
23
+ - Update the exact rer package pin, or refresh vendored operating commands, to receive these changes.
24
+
3
25
  ## 0.2.26
4
26
 
5
27
  - The `rer` mail adapter carries `List-Id`, `List-Archive`, `List-Help`, `In-Reply-To` and `References` to the Managed relay as its `listId`, `listArchive`, `listHelp`, `inReplyTo` and `references` fields, and refuses invalid values before sending. Other raw headers stay refused.
@@ -0,0 +1,3 @@
1
+ export function normalizeEmail(value: unknown): string;
2
+ export function emailDomain(email: string): string;
3
+ export function safeReturnTo(value: unknown, fallback?: string): string;
@@ -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,14 +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 the original repository's complete
52
- local-ref history with publish-check. A verify that mutates tracked source fails.
53
- When declared in the committed package, it runs `pnpm run verify:release` after
54
- default verification succeeds. Keep capacity, maximum-size memory and load cases
55
- in that release-only script. Both dry runs and releases require it to pass;
56
- `gates.verify.release` records its result. Routine CI and default verification
57
- 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.
58
85
  A passing step's receipt retains exit status and numeric final summaries from
59
86
  Node's spec/TAP reporters and Playwright's text reporters. A failing install,
60
87
  `verify` or `verify:release` step also keeps `output`: the last 40 lines (at most
@@ -84,7 +111,7 @@ commit and the exact source export. Existing tags are never changed. The command
84
111
  changes repository visibility, dispatches Actions, deploys or edits a site**.
85
112
  Publication and deployment retain their separate owner authorization.
86
113
 
87
- `--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
88
115
  tag creation even with `--tag`. `--tag --dry-run` also prepares the source archive
89
116
  for inspection. Existing tags do not prevent previews.
90
117
  If gates fail, it exits 1, omits the source export, records BLOCKED in
@@ -120,6 +147,25 @@ the source tag. Release notes pass the same content rules as the public tree.
120
147
 
121
148
  ## Releasing a seed that is already public
122
149
 
150
+ Release the exact green source commit with the ordinary command:
151
+
152
+ ```sh
153
+ pnpm rer release --repo /path/to/public-seed --ref GREEN_COMMIT \
154
+ --project "$PUBLIC_PROJECT" --repository "$PUBLIC_REPOSITORY" \
155
+ --tag v1.2.3 --output /path/to/new-release-directory
156
+ ```
157
+
158
+ Both source-history and staged-annotation scans receive the repository's public
159
+ base. Public annotated tags, including the previous release, are fetched into
160
+ the scanner's isolated namespace and recognized by their exact object identity.
161
+ The selected source commit and final tag target are preserved.
162
+
163
+ Use `--public-base GIT_URL#BRANCH` to select public history explicitly, including
164
+ when the checkout has no public origin. The scanner fetches that remote branch
165
+ and its public tags; local refs and commit IDs cannot establish public history.
166
+ This option applies to exact-source releases and cannot be combined with
167
+ `--onto` or `--clean-history`.
168
+
123
169
  Use `--onto` to create one public child of the destination's current branch from
124
170
  an independently developed private source tree:
125
171
 
@@ -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,20 +1,23 @@
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';
8
9
  import { publicDestination, requirePublicDestination, remotePublicHead, publicChild, assertPublicTree } from './public-child.mjs';
9
10
  import { writePublishHandoff } from './publish-handoff.mjs';
11
+ import { releasePublicBase } from './public-base.mjs';
10
12
 
11
13
  // Failure output belongs to the private receipt, not the site preview.
12
14
  const withoutOutput = gates => JSON.parse(JSON.stringify(gates, (key, value) => key === 'output' ? undefined : value));
13
15
 
14
- export async function release({ repo, ref = 'HEAD', output, project, repository, dryRun = false, tag = false, cleanHistory: clean = false, envFile, onto }) {
16
+ export async function release({ repo, ref = 'HEAD', output, project, repository, dryRun = false, tag = false, cleanHistory: clean = false, envFile, onto, publicBase, localVerify = false }) {
15
17
  if (!/^[\w.-]+\/[\w.-]+$/.test(project ?? '')) throw Error('--project must be publisher/name');
16
18
  if (!/^https:\/\/github\.com\/[\w.-]+\/[\w.-]+(?:\.git)?$/i.test(repository ?? '')) throw Error('--repository must be a credential-free GitHub repository URL');
17
19
  if (onto !== undefined && clean) throw Error('--onto and --clean-history are mutually exclusive');
20
+ if (publicBase !== undefined && (onto !== undefined || clean)) throw Error('--public-base selects exact-source history; cannot combine with export history modes');
18
21
  const preview = dryRun || !tag;
19
22
  const source = inspectSource(repo, ref);
20
23
  validatePublicationDestination(source, project, repository);
@@ -25,6 +28,7 @@ export async function release({ repo, ref = 'HEAD', output, project, repository,
25
28
  // Validate metadata before installs or output writes.
26
29
  catalogue(source, project, repository, { verify: { status: 'PENDING' }, publishCheck: { status: 'PENDING' } }, preview);
27
30
  const destination = onto !== undefined ? publicDestination(onto, repository, source.repo) : null;
31
+ const scanBase = destination?.spec ?? (clean ? undefined : releasePublicBase(source, publicBase));
28
32
  let publicParent = null;
29
33
  if (destination) {
30
34
  requirePublicDestination(destination);
@@ -37,29 +41,15 @@ export async function release({ repo, ref = 'HEAD', output, project, repository,
37
41
  const checkout = resolve(temporary, 'seed');
38
42
  git(source.repo, 'clone', '--no-hardlinks', '--no-checkout', '--', source.repo, checkout);
39
43
  git(checkout, 'checkout', '--detach', source.commit);
40
- // Honour the seed's committed install policy. Base's native-build settings
41
- // are not interchangeable with pnpm 8's locked onlyBuiltDependencies.
42
- const install = await command('pnpm', ['install', '--frozen-lockfile'], checkout, { dependencies: true });
43
- 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 };
44
- // Release-only scale and capacity cases stay outside routine CI. The
45
- // committed seed script is an additional gate in previews and releases.
46
- if (verify.status === 'PASS' && JSON.parse(source.bytes('package.json')).scripts['verify:release']) {
47
- verify.release = await command('pnpm', ['run', 'verify:release'], checkout);
48
- if (verify.release.status !== 'PASS') {
49
- verify.status = 'FAIL'; verify.exitCode = verify.release.exitCode;
50
- verify.reason = 'release-verification-failed';
51
- }
52
- }
53
- if (git(checkout, 'status', '--porcelain', '--untracked-files=no').length) {
54
- verify.status = 'FAIL'; verify.reason = 'verify-changed-tracked-source';
55
- }
44
+ const verify = await verifySource(source, checkout, localVerify);
56
45
  // Explicit clean-history publication scans every byte and ref of the actual
57
- // parentless export. Ordinary releases retain the private full-history gate.
46
+ // parentless export. Exact-source releases classify against public history
47
+ // when available, retaining the selected source commit and tag identity.
58
48
  const exported = destination ? publicChild(source, temporary, destination, publicParent, Boolean(tag))
59
49
  : clean ? cleanHistory(source, temporary, Boolean(tag)) : null;
60
50
  const scanRepo = exported?.repo ?? source.repo;
61
51
  const scanRef = exported?.commit ?? source.commit;
62
- let report = publicationScan(scanRepo, scanRef, envFile, project, repository, destination?.spec);
52
+ let report = publicationScan(scanRepo, scanRef, envFile, project, repository, scanBase);
63
53
  if (!exported && tag && report.status === 'PASS') {
64
54
  // Stage the exact final annotation before any source tag or distributable
65
55
  // artifact exists, in a fresh clone of the selected commit: verification
@@ -70,7 +60,7 @@ export async function release({ repo, ref = 'HEAD', output, project, repository,
70
60
  git(candidate, 'checkout', '--detach', source.commit);
71
61
  const staged = git(candidate, 'tag', '--list', source.tag).toString().trim();
72
62
  annotate(candidate, source, source.commit, staged ? `${source.tag}-publication-candidate` : source.tag);
73
- const annotations = publicationScan(candidate, source.commit, envFile, project, repository);
63
+ const annotations = publicationScan(candidate, source.commit, envFile, project, repository, scanBase);
74
64
  report.annotationInspection = annotations;
75
65
  if (annotations.status !== 'PASS') {
76
66
  report.status = annotations.status;
@@ -0,0 +1,29 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { resolve } from 'node:path';
3
+ import { git } from './source.mjs';
4
+ import { publicGit } from './public-git.mjs';
5
+
6
+ const identity = url => /^(?:https:\/\/github\.com\/|ssh:\/\/git@github\.com\/|git@github\.com:)([\w.-]+\/[\w.-]+)$/i
7
+ .exec(url)?.[1].replace(/\.git$/i, '');
8
+
9
+ // Publication targets do not establish whether the source is already public.
10
+ // Infer a base from the source repository's own confirmed public origin.
11
+ export function releasePublicBase(source, explicit) {
12
+ if (explicit !== undefined) return explicit;
13
+ if (!git(source.repo, 'remote').toString().trim().split('\n').includes('origin')) return undefined;
14
+ const origin = git(source.repo, 'config', '--get', 'remote.origin.url').toString().trim();
15
+ const sourceIdentity = identity(origin);
16
+ if (!sourceIdentity) return undefined;
17
+ const repository = `https://github.com/${sourceIdentity}`;
18
+ const script = 'import sys; sys.path.insert(0, sys.argv[1]); from github_refs import GitHubResolver; print(GitHubResolver().resolve(sys.argv[2]))';
19
+ const visibility = execFileSync('python3', ['-B', '-c', script,
20
+ resolve(import.meta.dirname, '../../scripts/publish-check'), sourceIdentity],
21
+ { stdio: ['ignore', 'pipe', 'pipe'] }).toString().trim();
22
+ if (['private', 'missing'].includes(visibility)) return undefined;
23
+ if (visibility !== 'public') throw Error('Source repository visibility could not be established');
24
+ const advertised = publicGit(source.repo, ['--git-dir=/dev/null', 'ls-remote', '--symref', '--', repository, 'HEAD']).toString();
25
+ const branches = [...advertised.matchAll(/^ref: refs\/heads\/(.+)\tHEAD$/gm)].map(match => match[1]);
26
+ if (branches.length !== 1) throw Error('Public source default branch is missing or ambiguous');
27
+ publicGit(source.repo, ['check-ref-format', `refs/heads/${branches[0]}`]);
28
+ return `${repository}#${branches[0]}`;
29
+ }
@@ -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
+ }
@@ -0,0 +1,34 @@
1
+ import {open} from 'node:fs/promises';
2
+ import {join,relative} from 'node:path';
3
+ import {stateFiles} from './state-files.mjs';
4
+
5
+ // A launch lock excludes cooperating commands. When process inspection fails,
6
+ // SQLite can still positively identify a conflicting transaction without a
7
+ // process-table walk. This cannot detect idle file handles or WAL readers.
8
+ export async function sqliteCustody(root) {
9
+ for(const path of await stateFiles(join(root,'.wrangler/state'))){
10
+ // Sidecars are not databases; state can disappear after this snapshot.
11
+ if(/-(?:wal|shm|journal)$/.test(path))continue;
12
+ let file;
13
+ try{file=await open(path,'r');}catch(error){if(error.code==='ENOENT')continue;throw error;}
14
+ let sqlite;
15
+ try{
16
+ const header=Buffer.alloc(16),{bytesRead}=await file.read(header,0,16,0);
17
+ sqlite=bytesRead===16&&header.toString()==='SQLite format 3\0';
18
+ }finally{await file.close();}
19
+ if(!sqlite)continue;
20
+ // Lazy import keeps the database engine out of early launcher registration.
21
+ const {DatabaseSync}=await import('node:sqlite');
22
+ let db;
23
+ try{
24
+ // This must be a writable connection: read-only WAL transactions do not
25
+ // exclude writers. Closing it may checkpoint idle WAL, so never use it for
26
+ // demo, whose canonical owner-state bytes must remain unchanged.
27
+ db=new DatabaseSync(path);
28
+ db.exec('PRAGMA busy_timeout=0; BEGIN EXCLUSIVE; ROLLBACK;');
29
+ }catch(error){
30
+ if(error.errcode===5||error.errcode===6)return relative(root,path);
31
+ throw new Error('Could not check the local SQLite lock. Preserve local state and resolve the database error before retrying.');
32
+ }finally{db?.close();}
33
+ }
34
+ }
@@ -32,19 +32,19 @@ export async function stopOwnedGroup(child, signal, ownership) {
32
32
  const stopped = new Map()
33
33
  let lastGroup = []
34
34
 
35
- const snapshot = async (limit = deadline) => {
36
- const current = await inspect(Math.min(inspectionMs, limit - Date.now()))
37
- if (Date.now() >= limit) throw new Error('Process inspection deadline expired.')
35
+ // Every inspection gets its full bound (and process-table's extension): a
36
+ // slow but complete read is still a valid observation. The cleanup deadline
37
+ // ends the loop below, and only processes observed alive at it fail cleanup.
38
+ const snapshot = async () => {
39
+ const current = await inspect(inspectionMs)
38
40
  lastGroup = current
39
41
  return current
40
42
  }
41
- const send = async (member, name, requireLeaf = true, limit = deadline) => {
43
+ const send = async (member, name, requireLeaf = true) => {
42
44
  // Recheck both identity and children immediately before each numeric PID
43
45
  // signal. Never send a negative/group signal that can kill parents first.
44
- const timeout = Math.min(inspectionMs, limit - Date.now())
45
- const current = requireLeaf ? await readProcessTable(timeout) : []
46
- const target = await readProcessIdentity(member.pid, Math.min(inspectionMs, limit - Date.now()))
47
- if (Date.now() >= limit) throw new Error('Process inspection deadline expired.')
46
+ const current = requireLeaf ? await readProcessTable(inspectionMs) : []
47
+ const target = await readProcessIdentity(member.pid, inspectionMs)
48
48
  if (!sameProcess(member, target) || isZombie(target)) return false
49
49
  if (requireLeaf && !isLeaf(target, current)) return false
50
50
  if (name === 'SIGKILL' && !isStopped(target)) return false
@@ -122,9 +122,8 @@ export async function stopOwnedGroup(child, signal, ownership) {
122
122
  } finally {
123
123
  // Inspection/signalling failures must not leave a process suspended.
124
124
  const errors = []
125
- const resumeDeadline = Math.min(deadline + 1000, Date.now() + 1000)
126
125
  for (const member of stopped.values()) {
127
- try { await send(member, 'SIGCONT', false, resumeDeadline) } catch (error) { errors.push(error) }
126
+ try { await send(member, 'SIGCONT', false) } catch (error) { errors.push(error) }
128
127
  }
129
128
  // Preserve the original failure while reporting a failure to resume an owned process.
130
129
  // eslint-disable-next-line no-unsafe-finally
@@ -215,9 +215,7 @@ export async function localProcessConflict(root,savedOrigin,context=inspectionCo
215
215
  return {pid:held.pid,command:command||'process',reason:'the canonical local state'};
216
216
  }
217
217
  }
218
- let all;
219
- try{all=await listeners(undefined,context);}
220
- catch(error){if(!uncheckedInspection(error)||context.verb==='reset')throw error;return;}
218
+ const all=await listeners(undefined,context);
221
219
  const cwdRecords=process.platform!=='linux'&&all.length?records(await run(lsof,['-nP','-b','-w','-a','-p',all.map(row=>row.pid).join(','),'-d','cwd','-Fpn'],context)):[];
222
220
  let port;try{const url=new URL(savedOrigin);port=Number(url.port||80);}catch{}
223
221
  for(const row of all){
@@ -228,6 +226,9 @@ export async function localProcessConflict(root,savedOrigin,context=inspectionCo
228
226
  // A listener running somewhere else is another program's or another checkout's
229
227
  // server: it does not use this checkout's state, so it only blocks the port.
230
228
  if(onSavedPort&&places.length&&!places.some(place=>place===root||place.startsWith(root+'/')))continue;
231
- if(onSavedPort||inCheckout)return {pid:row.pid,command:await processName(row.pid,context),reason:onSavedPort?`saved local port ${port}`:'this checkout'};
229
+ if(onSavedPort||inCheckout){
230
+ let command;try{command=await processName(row.pid,context);}catch(error){if(!uncheckedInspection(error))throw error;}
231
+ return {pid:row.pid,command:command||'process',reason:onSavedPort?`saved local port ${port}`:'this checkout'};
232
+ }
232
233
  }
233
234
  }
@@ -3,7 +3,7 @@ import { readFile } from 'node:fs/promises'
3
3
  import { randomUUID } from 'node:crypto'
4
4
  import { promisify } from 'node:util'
5
5
  import { setTimeout as delay } from 'node:timers/promises'
6
- import { inspectionMs, readProcessIdentity, readProcessTable, sameBirth } from './process-table.mjs'
6
+ import { extensionMs, inspectionMs, readProcessIdentity, readProcessTable, sameBirth } from './process-table.mjs'
7
7
 
8
8
  const execute = promisify(execFile)
9
9
  const scopes = new WeakMap()
@@ -35,7 +35,9 @@ export function processScopeEnvironment(scope, environment) {
35
35
  }
36
36
  export async function scopedProcesses(scope, table, timeout = inspectionMs, previous = []) {
37
37
  if (!scopes.has(scope)) throw new Error('Unknown process scope.')
38
- const inspectionEnd = Date.now() + timeout
38
+ // Reading environments is the slowest inspection on a busy Mac; it shares
39
+ // process-table's bounded extension rather than failing at the ordinary bound.
40
+ const inspectionEnd = Date.now() + timeout + extensionMs
39
41
  // Inspect same-user candidates in one bounded call. A child can change cwd,
40
42
  // detach and lose its parent between captures; the exclusive inherited marker
41
43
  // still proves ownership. Arguments/environment never leave this function.
@@ -52,7 +54,7 @@ export async function scopedProcesses(scope, table, timeout = inspectionMs, prev
52
54
  && (member.uid === undefined || member.uid === process.getuid())
53
55
  )
54
56
  if (!candidates.length) return []
55
- const environments = process.platform === 'linux' ? new Map() : await readEnvironments(candidates.map(member => member.pid), timeout)
57
+ const environments = process.platform === 'linux' ? new Map() : await readEnvironments(candidates.map(member => member.pid), Math.max(1, inspectionEnd - Date.now()))
56
58
  const matches = []
57
59
  inspectCandidate: for (const member of candidates) {
58
60
  let environment
@@ -13,14 +13,26 @@ export const inspectionMs = 5000
13
13
  // launch whose own processes are accounted for.
14
14
  const transient = (message) => Object.assign(new Error(message), { transient: true })
15
15
  const retryMs = 10
16
- async function withinBound(timeout, attempt) {
17
- const deadline = Date.now() + timeout
18
- for (;;) {
19
- try { return await attempt(Math.max(1, deadline - Date.now())) } catch (error) {
20
- if (!error.transient || Date.now() + retryMs >= deadline) throw error
21
- await delay(retryMs)
16
+ // A busy machine can starve ps, or this process, past the ordinary bound while
17
+ // the read itself is healthy; its finished output can even be queued behind
18
+ // the deadline timer. Such a read is not a failure of the caller's work: the
19
+ // same in-flight read is awaited for a bounded extension, with a warning, and
20
+ // only an inspection that also outlives the extension fails.
21
+ export const extensionMs = 25000
22
+ async function withinBound(timeout, attempt, extension = extensionMs) {
23
+ const deadline = Date.now() + timeout + extension
24
+ const slow = setTimeout(() => process.emitWarning(
25
+ `Process inspection is taking longer than ${timeout} ms on a busy machine; waiting up to ${extension} ms more.`,
26
+ { code: 'RER_PROCESS_INSPECTION_SLOW' }), timeout)
27
+ slow.unref()
28
+ try {
29
+ for (;;) {
30
+ try { return await attempt(Math.max(1, deadline - Date.now())) } catch (error) {
31
+ if (!error.transient || Date.now() + retryMs >= deadline) throw error
32
+ await delay(retryMs)
33
+ }
22
34
  }
23
- }
35
+ } finally { clearTimeout(slow) }
24
36
  }
25
37
  export const validPid = (pid) => Number.isSafeInteger(pid) && pid > 0 && pid <= 0x7fffffff
26
38
 
@@ -103,7 +115,7 @@ async function processGroup(pgid, signal) {
103
115
  // cleanup slower than the existing bounded shutdown contract.
104
116
  export async function readProcessIdentity(pid, timeout = inspectionMs) {
105
117
  if (!validPid(pid) || !(timeout > 0)) throw new Error('Invalid process identity deadline.')
106
- if (process.platform === 'linux') return linuxProcess(pid, undefined, AbortSignal.timeout(timeout))
118
+ if (process.platform === 'linux') return withinBound(timeout, (remaining) => linuxProcess(pid, undefined, AbortSignal.timeout(remaining)))
107
119
  return withinBound(timeout, (remaining) => psIdentity(pid, remaining))
108
120
  }
109
121
 
@@ -122,7 +134,7 @@ async function psIdentity(pid, timeout) {
122
134
 
123
135
  // `read` is the process edge: it returns the table or throws; tests supply a
124
136
  // failing one.
125
- export async function readProcessTable(timeout = inspectionMs, pgid, read = processGroup) {
137
+ export async function readProcessTable(timeout = inspectionMs, pgid, read = processGroup, extension = extensionMs) {
126
138
  if (!(timeout > 0)) throw new Error('Process inspection deadline expired.')
127
139
  return withinBound(timeout, async (remaining) => {
128
140
  const controller = new AbortController()
@@ -135,7 +147,7 @@ export async function readProcessTable(timeout = inspectionMs, pgid, read = proc
135
147
  }, remaining)
136
148
  })])
137
149
  } finally { clearTimeout(timer) }
138
- })
150
+ }, extension)
139
151
  }
140
152
 
141
153
  export const sameBirth = (left, right) => validPid(left?.pid) && left.pid === right?.pid && left.birth === right?.birth
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeditrun/rer",
3
- "version": "0.2.26",
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",
@@ -20,6 +20,7 @@ class History:
20
20
  self.repo = str(Path(repo).resolve())
21
21
  self.env = git_environment()
22
22
  self.public_commit = self.public_label = None
23
+ self.public_tags = set()
23
24
  self.reader = None
24
25
  self.commit = self.run('rev-parse', '--verify', '--end-of-options', ref + '^{commit}').decode().strip()
25
26
  if self.run('rev-parse', '--is-shallow-repository').strip() != b'false':
@@ -27,15 +28,19 @@ class History:
27
28
  if public_base is not None:
28
29
  url, branch = parse(public_base, self.repo)
29
30
  try:
30
- self.run('fetch', '--quiet', '--no-tags', '--no-recurse-submodules', '--no-write-fetch-head', '--',
31
- url, 'refs/heads/' + branch + ':refs/publish-check/public/base')
31
+ self.run('fetch', '--quiet', '--prune', '--no-tags', '--no-recurse-submodules', '--no-write-fetch-head', '--',
32
+ url, 'refs/heads/' + branch + ':refs/publish-check/public/base',
33
+ 'refs/tags/*:refs/publish-check/public/tags/*')
32
34
  self.public_commit = self.run('rev-parse', 'refs/publish-check/public/base^{commit}').decode().strip()
33
35
  self.public_label = display(url) + '#' + branch
36
+ self.public_tags = set(self.run('for-each-ref', '--format=%(objectname)',
37
+ 'refs/publish-check/public/tags').decode().splitlines())
34
38
  except InspectionError:
35
39
  raise PublicBaseError('public-base.fetch-failed') from None
36
- self.revisions = [self.commit, self.public_commit] if public_base else ['--all', self.commit]
40
+ public_revisions = [self.public_commit, *sorted(self.public_tags)] if public_base else []
41
+ self.revisions = [self.commit, *public_revisions] if public_base else ['--all', self.commit]
37
42
  self.commits = self.run('rev-list', *self.revisions).decode().splitlines()
38
- self.public_commits = set(self.run('rev-list', self.public_commit).decode().splitlines()) if self.public_commit else set()
43
+ self.public_commits = set(self.run('rev-list', *public_revisions).decode().splitlines()) if public_base else set()
39
44
  self.trees = {}
40
45
  self.tree_ids = dict(line.split() for line in self.run('log', '--format=%H %T', *self.revisions).decode().splitlines())
41
46
  self.reader = subprocess.Popen(['git', '-C', self.repo, 'cat-file', '--batch'],
@@ -97,9 +102,12 @@ class History:
97
102
  for index in range(0, len(records) - 1, 2):
98
103
  if records[index]:
99
104
  yield 'commit', records[index].decode().strip(), records[index + 1]
100
- for record in self.run('for-each-ref', '--format=%(objecttype) %(objectname)', 'refs/tags').splitlines():
105
+ seen = set()
106
+ for record in self.run('for-each-ref', '--format=%(objecttype) %(objectname)', 'refs/tags',
107
+ 'refs/publish-check/public/tags').splitlines():
101
108
  kind, oid = record.decode().split()
102
- if kind == 'tag':
109
+ if kind == 'tag' and oid not in seen:
110
+ seen.add(oid)
103
111
  raw = self.run('cat-file', 'tag', oid)
104
112
  yield 'tag', oid, raw.partition(b'\n\n')[2]
105
113
 
@@ -161,7 +161,7 @@ def scan(repo, ref='HEAD', public_base=None, env_file=None, project=None, reposi
161
161
  report['history']['tagMessages' if message_type == 'tag' else 'commitMessages'] += 1
162
162
  rules, _ = text_rules(data, path, selected_context, resolver, hashes,
163
163
  commit_message=message_type == 'commit')
164
- scope = 'release-tree' if commit == history.commit else 'pre-existing' if commit in history.public_commits else 'newly-public'
164
+ scope = 'pre-existing' if commit in history.public_commits or commit in history.public_tags else 'release-tree' if commit == history.commit else 'newly-public'
165
165
  for rule in rules:
166
166
  add(rule, path, commit, scope=scope)
167
167
  messages.append(data + b'\n')