@runeditrun/rer 0.2.73 → 0.2.75

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.
Files changed (47) hide show
  1. package/cli/contract.mjs +1 -1
  2. package/cli/export.mjs +1 -1
  3. package/cli/parse.mjs +1 -0
  4. package/cli/portability-worker.mjs +6 -7
  5. package/cli/release.mjs +9 -0
  6. package/cli/site-check.mjs +4 -2
  7. package/cli/site-prepare.mjs +6 -0
  8. package/cli/site-render.mjs +7 -1
  9. package/cli/site-runtime.mjs +55 -0
  10. package/cli/site.mjs +45 -17
  11. package/global/CHANGELOG.md +13 -0
  12. package/modules/container/build.mjs +2 -1
  13. package/modules/deploy-kit/README.md +47 -2
  14. package/modules/deploy-kit/owner-cli.mjs +2 -1
  15. package/modules/deploy-kit/site-readback.mjs +12 -2
  16. package/modules/deploy-kit/site-runtime.mjs +33 -0
  17. package/modules/deploy-kit/site.mjs +27 -8
  18. package/modules/operator-auth/scheduled/definition.mjs +3 -1
  19. package/modules/operator-auth/scheduled/expiry.mjs +2 -2
  20. package/modules/operator-auth/scheduled/fence.mjs +2 -1
  21. package/modules/operator-auth/scheduled/runner.mjs +13 -5
  22. package/modules/portability/README.md +27 -8
  23. package/modules/portability/backfills.mjs +22 -14
  24. package/modules/portability/bridge.mjs +9 -6
  25. package/modules/portability/migration-sql.mjs +8 -0
  26. package/modules/portability/migration-statements.mjs +22 -17
  27. package/modules/portability/rebuilds.mjs +106 -0
  28. package/modules/portability/replay-views.mjs +35 -0
  29. package/modules/release/produce.mjs +5 -3
  30. package/modules/release/publication-scan.mjs +5 -4
  31. package/modules/site/docs-search/SearchField.tsx +18 -0
  32. package/modules/site/docs-search/artifacts.mjs +54 -0
  33. package/modules/site/docs-search/client.ts +194 -0
  34. package/modules/site/docs-search/index-build.mjs +63 -0
  35. package/modules/site/docs-search/retrieve.ts +16 -0
  36. package/modules/site/docs-search/search.css +19 -0
  37. package/modules/site/docs-search/sections.ts +24 -0
  38. package/modules/site/docs-search/types.ts +14 -0
  39. package/modules/site/docs-search/worker.ts +39 -0
  40. package/package.json +1 -1
  41. package/scripts/publish-check/README.md +6 -1
  42. package/scripts/publish-check/cli.py +8 -4
  43. package/scripts/publish-check/history_hydration.py +4 -1
  44. package/scripts/publish-check/slots.py +67 -0
  45. package/scripts/publish-check/timeout.json +1 -0
  46. package/scripts/publish-check/timeout.mjs +14 -0
  47. package/scripts/publish-check.mjs +18 -5
@@ -0,0 +1,67 @@
1
+ """Hold a per-user advisory scan slot until the real scan worker exits."""
2
+ import fcntl
3
+ import os
4
+ from pathlib import Path
5
+ import select
6
+ import signal
7
+ import subprocess
8
+ import sys
9
+ import time
10
+
11
+
12
+ def parent_closed(seconds):
13
+ ready, _, _ = select.select([sys.stdin], [], [], max(0, seconds))
14
+ return bool(ready) and not os.read(sys.stdin.fileno(), 1)
15
+
16
+
17
+ def notify(message):
18
+ os.write(3, (message + '\n').encode())
19
+
20
+
21
+ def main(*, wait_seconds=3600):
22
+ # wait_seconds is injectable by the test interpreter, never a user knob.
23
+ raw = os.environ.get('RER_SCAN_SLOTS', '3')
24
+ if not raw.isdecimal() or not 1 <= int(raw) <= 8:
25
+ notify('scan.slot-configuration')
26
+ return 2
27
+ directory = Path.home() / '.cache/rer/scan-slots'
28
+ directory.mkdir(mode=0o700, parents=True, exist_ok=True)
29
+ deadline = time.monotonic() + wait_seconds
30
+ waiting = False
31
+ while True:
32
+ if waiting and time.monotonic() >= deadline:
33
+ notify('scan.slot-timeout')
34
+ return 2
35
+ for number in range(int(raw)):
36
+ fd = os.open(directory / f'slot-{number}', os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
37
+ try:
38
+ fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
39
+ except BlockingIOError:
40
+ os.close(fd)
41
+ continue
42
+ try:
43
+ notify('acquired')
44
+ worker = subprocess.Popen([sys.executable, '-B', str(Path(__file__).with_name('cli.py')),
45
+ *sys.argv[1:]], stdin=subprocess.DEVNULL,
46
+ stderr=subprocess.DEVNULL, pass_fds=(fd,))
47
+ # Node's pipe closes even on SIGKILL. Stop only this private
48
+ # group, so an orphan never consumes CPU or holds a slot.
49
+ while worker.poll() is None:
50
+ if parent_closed(0.2):
51
+ os.killpg(os.getpgrp(), signal.SIGKILL)
52
+ return worker.returncode
53
+ finally:
54
+ os.close(fd)
55
+ if not waiting:
56
+ print('waiting for a scan slot', file=sys.stderr, flush=True)
57
+ waiting = True
58
+ remaining = deadline - time.monotonic()
59
+ if remaining <= 0:
60
+ notify('scan.slot-timeout')
61
+ return 2
62
+ if parent_closed(min(2, remaining)):
63
+ return 2
64
+
65
+
66
+ if __name__ == '__main__':
67
+ raise SystemExit(main())
@@ -0,0 +1 @@
1
+ {"default": 300, "max": 7200}
@@ -0,0 +1,14 @@
1
+ import { readFileSync } from 'node:fs';
2
+
3
+ export const timeoutBounds = Object.freeze(JSON.parse(readFileSync(new URL('./timeout.json', import.meta.url), 'utf8')));
4
+
5
+ // Release requires whole seconds; publish-check also accepts fractional
6
+ // seconds, which its existing deadline test and standalone callers use.
7
+ export function parseTimeoutSeconds(value, { integer = false } = {}) {
8
+ const seconds = Number(value);
9
+ if ((integer && !/^\d+$/.test(String(value))) || !String(value).trim() ||
10
+ !(seconds > 0 && seconds <= timeoutBounds.max)) {
11
+ throw new RangeError(`Scan timeout must be ${integer ? 'integer ' : ''}seconds from ${integer ? '1' : 'above 0'} to ${timeoutBounds.max}.`);
12
+ }
13
+ return seconds;
14
+ }
@@ -4,12 +4,15 @@ import { mkdtempSync, readFileSync, openSync, closeSync, rmSync } from 'node:fs'
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { runningVersion } from '../cli/version.mjs';
7
+ import { parseTimeoutSeconds, timeoutBounds } from './publish-check/timeout.mjs';
7
8
 
8
9
  const args = process.argv.slice(2);
9
- let seconds = 300;
10
+ let seconds = timeoutBounds.default;
10
11
  for (let i = 0; i < args.length; i++) {
11
12
  const raw = args[i] === '--timeout-seconds' ? args[i + 1] : args[i].startsWith('--timeout-seconds=') ? args[i].slice(18) : null;
12
- if (raw !== null && Number(raw) > 0 && Number(raw) <= 7200) seconds = Number(raw);
13
+ if (raw !== null) {
14
+ try { seconds = parseTimeoutSeconds(raw); } catch { /* Python reports invalid arguments. */ }
15
+ }
13
16
  }
14
17
  const scratch = mkdtempSync(join(tmpdir(), 'publish-check-'));
15
18
  const output = join(scratch, 'report.json');
@@ -28,11 +31,21 @@ process.on('SIGINT', interrupt);
28
31
  process.on('SIGTERM', interrupt);
29
32
  let report, code = 2;
30
33
  try {
31
- child = spawn('python3', ['-B', new URL('./publish-check/cli.py', import.meta.url).pathname, ...args], {
32
- detached: true, stdio: ['ignore', fd, 'ignore'], env: { ...process.env, TMPDIR: scratch },
34
+ child = spawn('python3', ['-B', new URL('./publish-check/slots.py', import.meta.url).pathname, ...args], {
35
+ detached: true, stdio: ['pipe', fd, 'inherit', 'pipe'], env: { ...process.env, TMPDIR: scratch },
33
36
  });
34
37
  closeSync(fd);
35
- timer = setTimeout(() => stop('scan.deadline-exceeded'), seconds * 1000);
38
+ let messages = '';
39
+ child.stdio[3].setEncoding('utf8');
40
+ child.stdio[3].on('data', data => {
41
+ messages += data;
42
+ for (let at; (at = messages.indexOf('\n')) !== -1;) {
43
+ const message = messages.slice(0, at);
44
+ messages = messages.slice(at + 1);
45
+ if (message === 'acquired' && !timer) timer = setTimeout(() => stop('scan.deadline-exceeded'), seconds * 1000);
46
+ else if (message.startsWith('scan.')) reason ??= message;
47
+ }
48
+ });
36
49
  const result = await new Promise(resolve => {
37
50
  child.once('error', () => resolve(null));
38
51
  child.once('close', value => resolve(value));