@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.
- package/cli/contract.mjs +1 -1
- package/cli/export.mjs +1 -1
- package/cli/parse.mjs +1 -0
- package/cli/portability-worker.mjs +6 -7
- package/cli/release.mjs +9 -0
- package/cli/site-check.mjs +4 -2
- package/cli/site-prepare.mjs +6 -0
- package/cli/site-render.mjs +7 -1
- package/cli/site-runtime.mjs +55 -0
- package/cli/site.mjs +45 -17
- package/global/CHANGELOG.md +13 -0
- package/modules/container/build.mjs +2 -1
- package/modules/deploy-kit/README.md +47 -2
- package/modules/deploy-kit/owner-cli.mjs +2 -1
- package/modules/deploy-kit/site-readback.mjs +12 -2
- package/modules/deploy-kit/site-runtime.mjs +33 -0
- package/modules/deploy-kit/site.mjs +27 -8
- package/modules/operator-auth/scheduled/definition.mjs +3 -1
- package/modules/operator-auth/scheduled/expiry.mjs +2 -2
- package/modules/operator-auth/scheduled/fence.mjs +2 -1
- package/modules/operator-auth/scheduled/runner.mjs +13 -5
- package/modules/portability/README.md +27 -8
- package/modules/portability/backfills.mjs +22 -14
- package/modules/portability/bridge.mjs +9 -6
- package/modules/portability/migration-sql.mjs +8 -0
- package/modules/portability/migration-statements.mjs +22 -17
- package/modules/portability/rebuilds.mjs +106 -0
- package/modules/portability/replay-views.mjs +35 -0
- package/modules/release/produce.mjs +5 -3
- package/modules/release/publication-scan.mjs +5 -4
- package/modules/site/docs-search/SearchField.tsx +18 -0
- package/modules/site/docs-search/artifacts.mjs +54 -0
- package/modules/site/docs-search/client.ts +194 -0
- package/modules/site/docs-search/index-build.mjs +63 -0
- package/modules/site/docs-search/retrieve.ts +16 -0
- package/modules/site/docs-search/search.css +19 -0
- package/modules/site/docs-search/sections.ts +24 -0
- package/modules/site/docs-search/types.ts +14 -0
- package/modules/site/docs-search/worker.ts +39 -0
- package/package.json +1 -1
- package/scripts/publish-check/README.md +6 -1
- package/scripts/publish-check/cli.py +8 -4
- package/scripts/publish-check/history_hydration.py +4 -1
- package/scripts/publish-check/slots.py +67 -0
- package/scripts/publish-check/timeout.json +1 -0
- package/scripts/publish-check/timeout.mjs +14 -0
- 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 =
|
|
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
|
|
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/
|
|
32
|
-
detached: true, stdio: ['
|
|
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
|
-
|
|
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));
|