@runeditrun/rer 0.2.127 → 0.2.128

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.
@@ -93,9 +93,9 @@ export async function applyChoices(api, state, { reconnecting = false } = {}) {
93
93
  }
94
94
  const undecided = names.filter(name => decided[name] === null && !inapplicable[name]);
95
95
  if (undecided.length) {
96
- once('undecided', `The owner has not chosen yet:\n${undecided.map(name => ` - ${choices[name]}\n`).join('')}They choose on this computer's row in ${state.origin}/business/${encodeURIComponent(state.businessId)}/settings; the run and next commands apply the choices at their next check-in, ${reconnecting ? 'without pairing again' : 'so connect does not need to run again'}.\n`);
96
+ once('undecided', `Optional choices for this computer (nothing waits on them):\n${undecided.map(name => ` - ${choices[name]}\n`).join('')}The owner can make these choices whenever they like on this computer's row in ${state.origin}/business/${encodeURIComponent(state.businessId)}/settings. The run and next commands apply the choices at their next check-in, ${reconnecting ? 'without pairing again' : 'so connect does not need to run again'}.\n`);
97
97
  }
98
- once('choices-next-step', `After choosing this computer's permissions in Business, run ${businessCommand('next')} to apply them and see the next task.\n`);
98
+ once('choices-next-step', `Run ${businessCommand('next')} to see the next task.\n`);
99
99
  if (carried?.summaryChanged) {
100
100
  const count = carried.checkouts.length;
101
101
  process.stdout.write(count
@@ -1,6 +1,7 @@
1
1
  // Chromium from the seed's own Playwright, the two ways of serving pages to it
2
2
  // (the production build as rer deploy hosts it, or a running origin), and one
3
3
  // load: scripts held until the probe releases them, every external request aborted.
4
+ import { availableParallelism, loadavg } from 'node:os';
4
5
  import { checkoutPlaywright } from '../browser-runtime.mjs';
5
6
  import { RerError } from '../errors.mjs';
6
7
  import { serveHosted } from '../hosted-output.mjs';
@@ -38,14 +39,18 @@ export function originServer(origin) {
38
39
  * same-origin script requests (scripts), those answered before the probe released
39
40
  * the hold (unheld: none unless the hold failed) and the aborted cross-origin script
40
41
  * requests sent in CORS mode, as module fetches are (crossScripts). */
41
- export async function runLoad(browser, server, path, item, { timeout = 30000 } = {}) {
42
+ export async function runLoad(browser, server, path, item, { timeout } = {}) {
43
+ const loadFactor = Math.min(4, Math.max(1, loadavg()[0] / availableParallelism()));
44
+ const scale = ms => Math.round(ms * loadFactor);
45
+ const browserLimitMs = timeout ?? scale(30000);
46
+ const probeLimits = { noHydrationMs: scale(8000), settleMs: scale(20000) };
42
47
  const context = await browser.newContext({ viewport: { width: 1440, height: 900 }, reducedMotion: item.reduced ? 'reduce' : 'no-preference', serviceWorkers: 'block' });
43
48
  const errors = [], warnings = [], aborted = new Set(), scripts = new Set(), unheld = new Set(), crossScripts = new Set();
44
49
  let release, isReleased = false; const released = new Promise(resolve => { release = () => { isReleased = true; resolve(); }; });
45
50
  try {
46
51
  const page = await context.newPage();
47
52
  await page.exposeBinding('__rerRelease', () => { release(); });
48
- await page.addInitScript({ content: `(${probe})(${JSON.stringify({ kind: item.kind, section: item.section, release: item.release })})` });
53
+ await page.addInitScript({ content: `(${probe})(${JSON.stringify({ kind: item.kind, section: item.section, release: item.release, ...probeLimits })})` });
49
54
  page.on('pageerror', error => errors.push(`page error: ${String(error.message).split('\n')[0]}`));
50
55
  page.on('console', message => {
51
56
  const text = message.text(), type = message.type();
@@ -70,10 +75,10 @@ export async function runLoad(browser, server, path, item, { timeout = 30000 } =
70
75
  } catch (error) { if (!page.isClosed()) await route.abort().catch(() => {}); if (!/closed|disposed/i.test(String(error))) errors.push(`check could not serve ${url.pathname}: ${error.message}`); }
71
76
  });
72
77
  const started = Date.now();
73
- await page.goto(server.origin + path, { waitUntil: 'commit', timeout });
74
- const settled = await page.waitForFunction(() => window.__rerProbe?.settledAt !== null && window.__rerProbe?.settledAt !== undefined, null, { timeout, polling: 50 }).then(() => true, () => false);
78
+ await page.goto(server.origin + path, { waitUntil: 'commit', timeout: browserLimitMs });
79
+ const settled = await page.waitForFunction(() => window.__rerProbe?.settledAt !== null && window.__rerProbe?.settledAt !== undefined, null, { timeout: browserLimitMs, polling: 50 }).then(() => true, () => false);
75
80
  const record = await page.evaluate(() => window.__rerProbe ?? null).catch(() => null);
76
- return { record: settled ? record : { ...(record ?? {}), settled: 'timeout' }, errors, warnings, aborted: [...aborted], scripts: [...scripts], unheld: [...unheld], crossScripts: [...crossScripts], ms: Date.now() - started };
81
+ return { record: settled ? record : { ...(record ?? {}), settled: 'timeout', settledLimitMs: browserLimitMs }, errors, warnings, aborted: [...aborted], scripts: [...scripts], unheld: [...unheld], crossScripts: [...crossScripts], ms: Date.now() - started };
77
82
  } finally { release(); await context.close(); }
78
83
  }
79
84
 
@@ -142,15 +142,16 @@ export function probe(config) {
142
142
  if (S.hydratedAt === null && fiber(document.body) && pending() === 0) S.hydratedAt = t;
143
143
  const quiet = t - lastMutation > 300 && !oneShot().some(a => a.playState === 'running');
144
144
  if (S.hydratedAt !== null && t - S.hydratedAt > 300 && quiet) return settle('hydrated');
145
- if (S.hydratedAt === null && t - S.releasedAt > 8000 && !anyFiber()) return settle('not hydrated');
146
- if (t - S.releasedAt > 20000) return settle('timeout');
145
+ if (S.hydratedAt === null && t - S.releasedAt > config.noHydrationMs && !anyFiber()) return settle('not hydrated', config.noHydrationMs);
146
+ if (t - S.releasedAt > config.settleMs) return settle('timeout', config.settleMs);
147
147
  }
148
148
  } catch (error) { S.error = String(error && error.stack || error); return settle('error'); }
149
149
  requestAnimationFrame(frame);
150
150
  }
151
151
 
152
- function settle(state) {
152
+ function settle(state, limitMs) {
153
153
  S.settled = state; S.settledAt = now();
154
+ if (limitMs !== undefined) S.settledLimitMs = limitMs;
154
155
  S.replaced = snapshot.filter(([el]) => !el.isConnected).map(([, key]) => key);
155
156
  S.rer = window.__rerHydration ? JSON.parse(JSON.stringify(window.__rerHydration)) : null;
156
157
  }
@@ -5,6 +5,7 @@ import { describeCase } from './cases.mjs';
5
5
  const LATE_MS = 34; // two frames
6
6
  const within = (key, scope) => key === scope || key.startsWith(scope + '>');
7
7
  const list = (keys, limit = 6) => keys.slice(0, limit).join(', ') + (keys.length > limit ? ` and ${keys.length - limit} more` : '');
8
+ const settleBound = record => record?.settledLimitMs === undefined ? '' : ` within ${record.settledLimitMs} ms`;
8
9
 
9
10
  /** Replays in one load: a one-shot animation on a rebuilt element starting more
10
11
  * than two frames after the original did, or an animated element whose opacity
@@ -43,7 +44,8 @@ export const plainHtml = (load, scripts) => load.record?.settled === 'not hydrat
43
44
  /** The failure for a page whose plain load never hydrated and is not plain HTML. */
44
45
  export function judgeUnhydrated({ path, scripts, baseline: { record, errors } }) {
45
46
  const state = record?.settled ?? 'no probe record';
46
- const why = state === 'not hydrated' ? `React never hydrated the page${scripts.length ? ` although it loads application scripts (${list(scripts, 3)})` : ''}` : `the page did not settle (${state}${record?.error ? ': ' + record.error : ''})`;
47
+ const bound = settleBound(record);
48
+ const why = state === 'not hydrated' ? `React never hydrated the page${bound}${scripts.length ? ` although it loads application scripts (${list(scripts, 3)})` : ''}` : `the page did not settle${bound} (${state}${record?.error ? ': ' + record.error : ''})`;
47
49
  return `${path} plain load: ${why}${errors.length ? `; ${list([...new Set(errors)], 3)}` : ''}`;
48
50
  }
49
51
 
@@ -59,7 +61,7 @@ export function judgePage(page) {
59
61
  let exercised = false;
60
62
  for (const { item, load } of loads) {
61
63
  const what = describeCase(item, survey), record = load.record;
62
- if (!record || record.settled !== 'hydrated') { fail(what, record?.settled === 'error' ? `the probe failed: ${record.error}` : `the page did not settle after hydration within the time limit (${record?.settled ?? 'no record'})`); continue; }
64
+ if (!record || record.settled !== 'hydrated') { fail(what, record?.settled === 'error' ? `the probe failed: ${record.error}` : `the page did not settle after hydration${settleBound(record)} (${record?.settled ?? 'no record'})`); continue; }
63
65
  if (unheld(what, load)) continue;
64
66
  noisy(what, load);
65
67
  if (item.kind === 'plain') {
@@ -21,6 +21,7 @@ import {archiveReader} from './archive-source.mjs';
21
21
  import {apiReader} from './api-source.mjs';
22
22
 
23
23
  export const RECORD = 'base-copies.json';
24
+ export const MIGRATION_IGNORE_GUIDE = 'https://github.com/runeditrun/base/blob/main/modules/catalogue-ordering/ADOPTING.md#fresh-schema-and-populated-cutover';
24
25
  const commit = /^[a-f0-9]{40}$/, sha256 = /^[a-f0-9]{64}$/;
25
26
  const FILE_MODES = ['100644', '100755'];
26
27
  // Unrecorded-copy detection skips files under this many bytes: a one-line file such
@@ -31,6 +32,7 @@ const DEFAULT_DISCOVERY_IGNORES = new Set(['LICENSE', 'CLAUDE.md']);
31
32
  const modeOf = executable => executable ? '100755' : '100644';
32
33
  const within = (name, prefix) => name === prefix || name.startsWith(prefix + '/');
33
34
  const mapped = (name, from, to) => to + name.slice(from.length);
35
+ export const isMigrationPath = name => name.split('/').slice(0, -1).includes('migrations');
34
36
 
35
37
  function baseRepository(root) {
36
38
  const recipe = path.join(root, 'edition.json');
@@ -513,8 +515,8 @@ export function refreshCopies(root, {positional: [revision], record: recordPath,
513
515
  // A migration a database may already have applied is never rewritten in place:
514
516
  // the schema change it brings belongs in a new migration of the seed's own.
515
517
  const applied = plans.flatMap(({copy, sources}) => sources.map(([source, {object}]) => [mapped(source, copy.originPath, copy.path), object])
516
- .filter(([name, object]) => name.split('/').slice(0, -1).includes('migrations') && local(name) && local(name) !== upstream.get(object)).map(([name]) => name));
517
- if (applied.length) throw Error(`Refusing to rewrite migrations that may already be applied: ${applied.join(', ')}. Base changed these files after they were copied; keep them as they are, drop them from ${recordPath}, and add a new migration for the change instead.`);
518
+ .filter(([name, object]) => isMigrationPath(name) && local(name) && local(name) !== upstream.get(object)).map(([name]) => name));
519
+ if (applied.length) throw Error(`Refusing to rewrite migrations that may already be applied: ${applied.join(', ')}. Base changed these files after they were copied. Preserve their filenames and bytes, remove their copy entries from ${recordPath}, and add a new migration for the change. If the preserved bytes still match Base, add each exact path to the ignore array in ${recordPath}. See ${MIGRATION_IGNORE_GUIDE}.`);
518
520
  // A file already owned by the edition can become byte-equal when Base adds
519
521
  // its own implementation. Preserve ownership explicitly for discovery; it
520
522
  // must never enter the copy write plan merely because the bytes now match.
@@ -5,7 +5,7 @@ import {release, verifyReceipt} from './release.mjs';
5
5
  import {changes, extract, compare} from './updates.mjs';
6
6
  import {manifest} from './manifest.mjs';
7
7
  import {snapshot, source, merge} from './sources.mjs';
8
- import {options, adaptCopy, recordCopy, refreshCopies, verifyCopies} from './base-copies.mjs';
8
+ import {options, adaptCopy, recordCopy, refreshCopies, verifyCopies, isMigrationPath, MIGRATION_IGNORE_GUIDE} from './base-copies.mjs';
9
9
  import {json, tracked, writeTree, fresh} from './files.mjs';
10
10
 
11
11
  import {resolveSources} from './lock.mjs';
@@ -77,6 +77,9 @@ try {
77
77
  else if (command === 'verify-base') {
78
78
  result = verifyCopies(root, options(args.slice(1), 0));
79
79
  if (!result.ok) process.exitCode = 1;
80
+ for (const {path} of result.unrecordedCopies.filter(copy => isMigrationPath(copy.path))) {
81
+ console.error(`${path} matches Base and is outside the recorded copies. If this is an applied, seed-owned migration, preserve its filename and bytes and add its exact path to the ignore array in ${result.record}. See ${MIGRATION_IGNORE_GUIDE}.`);
82
+ }
80
83
  } else if (command === 'record-base') result = recordCopy(root, options(args.slice(1), 3));
81
84
  else if (command === 'adapt-base') result = adaptCopy(root, options(args.slice(1), 1));
82
85
  else if (command === 'refresh-base') result = refreshCopies(root, options(args.slice(1), 1));
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.128
4
+
5
+ Signed: Run Edit Run fleet, 2026-11-21.
6
+
7
+ ### Optional computer choices
8
+
9
+ - `rer business connect`, `run` and `next` describe undecided computer choices as optional: “Optional choices for this computer (nothing waits on them):”. The first check-in no longer says “After choosing ... run next to apply them”; it says to run `business next` to see the next task. Choices still apply at the next check-in. Other output, exit codes and JSON are unchanged.
10
+
11
+ ### Local sign-in and migration guidance
12
+
13
+ - The local `rer dev` sign-in gate places the expired-link alert inside the page's main content. Its text and alert role, sign-in links, expiry and refusals are unchanged.
14
+ - `refresh-base`'s applied-migration refusal, `verify-base`'s finding and the agent-door adoption guide point maintainers to the existing exact-path ignore rule for applied migrations that match a Base file but are not recorded copies. Preserve those migrations' filenames and bytes. Behavior, exit codes and JSON are unchanged.
15
+
16
+ ### Verification under load
17
+
18
+ - `rer verify` hydration deadlines scale with one-minute CPU load per available core, up to four times their idle limits. Idle limits are unchanged. The three hydration failure messages include the deadline in use. Maintained CLI copies and inventory are regenerated.
19
+ - This does not establish that standalone `rer verify` passes on HappyToHelp under load. Its test profiler's fixed 30-second inspector timer and a homepage tooltip mounted outside React remain HappyToHelp-owned limits, reported to hh.
20
+
21
+ Nothing in this release changes archives: `modules/portability`, `modules/import-kit`, every product migration and the archive format identity (`runeditrun-portability` version 2) are unchanged from 0.2.127. Core-only and owner-migration archives remain interchangeable with 0.2.127 for the same fixtures.
22
+
23
+ HappyToHelp, Lamp, Uptime, Oncall, Spool and other seeds on 0.2.126 or 0.2.127: re-pinning to 0.2.128 is optional; it only changes the four items above. Seeds on older pins: re-pin.
24
+
25
+ These changes require adoption through the seed's pinned package or refreshed source. This preparation establishes no seed adoption, live deployment, provider delivery or production result.
26
+
3
27
  ## 0.2.127
4
28
 
5
29
  Signed: Run Edit Run fleet, 2026-11-21.
@@ -16,7 +16,7 @@ export const EXCHANGE_SCRIPT = `(() => {
16
16
  method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body)
17
17
  });
18
18
  if (!response.ok) {
19
- document.body.insertAdjacentHTML('beforeend', ${JSON.stringify('<p role="alert">This link no longer opens the app. Run ~/.local/bin/rer dev again for a fresh one.</p>' + `<p>${terminalHelpHtml}</p>`)});
19
+ document.querySelector('main').insertAdjacentHTML('beforeend', ${JSON.stringify('<p role="alert">This link no longer opens the app. Run ~/.local/bin/rer dev again for a fresh one.</p>' + `<p>${terminalHelpHtml}</p>`)});
20
20
  return;
21
21
  }
22
22
  const next = signature ? (await response.json()).location : fragment.get('next') ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runeditrun/rer",
3
- "version": "0.2.127",
3
+ "version": "0.2.128",
4
4
  "description": "The rer command: install, set up, run and launch Run Edit Run checkouts.",
5
5
  "license": "MIT",
6
6
  "type": "module",