@runeditrun/rer 0.2.98 → 0.2.100
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/README.md +1 -1
- package/cli/README.md +88 -2
- package/cli/business/api.mjs +4 -2
- package/cli/business/bounded-waves.d.mts +23 -0
- package/cli/business/bounded-waves.mjs +57 -0
- package/cli/business/catchup-task.mjs +9 -2
- package/cli/business/command.mjs +16 -4
- package/cli/business/connect.mjs +39 -33
- package/cli/business/export-inputs.mjs +12 -2
- package/cli/business/export-task.mjs +9 -2
- package/cli/business/legacy-package.mjs +117 -0
- package/cli/business/local-commands.mjs +10 -1
- package/cli/business/package-transfer.mjs +127 -0
- package/cli/business/questions.mjs +2 -2
- package/cli/business/state.mjs +47 -5
- package/cli/business/supervisor.mjs +46 -7
- package/cli/business/vendor-door.mjs +86 -13
- package/cli/business/vendors/README.md +41 -2
- package/cli/business/vendors/common.mjs +81 -0
- package/cli/business/vendors/index.mjs +12 -2
- package/cli/business/vendors/zendesk-attachments.mjs +57 -0
- package/cli/business/vendors/zendesk-encode.mjs +133 -0
- package/cli/business/vendors/zendesk-guide.mjs +34 -0
- package/cli/business/vendors/zendesk-package.mjs +28 -0
- package/cli/business/vendors/zendesk-pages.mjs +61 -0
- package/cli/business/vendors/zendesk-people.mjs +7 -0
- package/cli/business/vendors/zendesk-store.mjs +154 -0
- package/cli/business/vendors/zendesk-tickets.mjs +21 -0
- package/cli/business/vendors/zendesk-token.mjs +31 -0
- package/cli/business/vendors/zendesk-transport.mjs +48 -0
- package/cli/business/vendors/zendesk.mjs +61 -0
- package/cli/deploy-command.mjs +5 -4
- package/cli/deploy-inputs.mjs +1 -1
- package/cli/deploy.mjs +6 -4
- package/cli/production-auth.mjs +16 -3
- package/cli/production-mail.mjs +18 -1
- package/cli/site.mjs +1 -1
- package/global/CHANGELOG.md +42 -0
- package/global/README.md +1 -1
- package/modules/deploy-kit/README.md +10 -0
- package/modules/deploy-kit/provider.mjs +18 -2
- package/modules/import-kit/src/d1/jobs.ts +3 -1
- package/modules/import-kit/src/d1/retirement-scope.ts +2 -2
- package/modules/import-kit/src/d1/retirement-tally.ts +1 -0
- package/modules/import-kit/src/d1/retirement.ts +15 -5
- package/modules/import-kit/src/d1/types.ts +3 -0
- package/modules/import-kit/src/d1/wave-boundary.ts +33 -0
- package/modules/import-kit/src/d1/wave-retirement.ts +47 -0
- package/modules/import-kit/src/door/ADOPTING.md +37 -0
- package/modules/import-kit/src/door/README.md +66 -0
- package/modules/import-kit/src/door/admission.ts +13 -3
- package/modules/import-kit/src/door/authority.ts +1 -0
- package/modules/import-kit/src/door/failures.ts +1 -1
- package/modules/import-kit/src/door/grants.ts +19 -5
- package/modules/import-kit/src/door/handler.ts +12 -1
- package/modules/import-kit/src/door/index.ts +6 -0
- package/modules/import-kit/src/door/package.ts +121 -0
- package/modules/import-kit/src/door/planning.ts +44 -19
- package/modules/import-kit/src/door/protocol.ts +4 -2
- package/modules/import-kit/src/door/schema.ts +2 -0
- package/modules/import-kit/src/door/store.ts +2 -2
- package/modules/import-kit/src/door/types.ts +24 -1
- package/modules/import-kit/src/door/waves/README.md +158 -0
- package/modules/import-kit/src/door/waves/digests.ts +38 -0
- package/modules/import-kit/src/door/waves/inventory.ts +84 -0
- package/modules/import-kit/src/door/waves/journal.ts +19 -0
- package/modules/import-kit/src/door/waves/lifecycle.ts +242 -0
- package/modules/import-kit/src/door/waves/preparation.ts +190 -0
- package/modules/import-kit/src/door/waves/schema.ts +73 -0
- package/modules/import-kit/src/door/waves/store.ts +112 -0
- package/modules/import-kit/src/door/waves/types.ts +76 -0
- package/onboarding/adapter.mjs +7 -1
- package/onboarding/operator-installer.mjs +3 -1
- package/package.json +1 -1
- package/scripts/publish-check/README.md +20 -0
- package/scripts/publish-check/diagnostics.mjs +73 -0
- package/scripts/publish-check/slots.py +37 -7
- package/scripts/publish-check.mjs +64 -37
|
@@ -18,14 +18,17 @@ def notify(message):
|
|
|
18
18
|
os.write(3, (message + '\n').encode())
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def
|
|
21
|
+
def hold_slot(*, wait_seconds):
|
|
22
22
|
# wait_seconds is injectable by the test interpreter, never a user knob.
|
|
23
23
|
raw = os.environ.get('RER_SCAN_SLOTS', '3')
|
|
24
24
|
if not raw.isdecimal() or not 1 <= int(raw) <= 8:
|
|
25
25
|
notify('scan.slot-configuration')
|
|
26
26
|
return 2
|
|
27
27
|
directory = Path.home() / '.cache/rer/scan-slots'
|
|
28
|
-
|
|
28
|
+
try:
|
|
29
|
+
directory.mkdir(mode=0o700, parents=True, exist_ok=True)
|
|
30
|
+
except OSError as error:
|
|
31
|
+
return failure('slot.directory', error)
|
|
29
32
|
deadline = time.monotonic() + wait_seconds
|
|
30
33
|
waiting = False
|
|
31
34
|
while True:
|
|
@@ -33,27 +36,40 @@ def main(*, wait_seconds=3600):
|
|
|
33
36
|
notify('scan.slot-timeout')
|
|
34
37
|
return 2
|
|
35
38
|
for number in range(int(raw)):
|
|
36
|
-
|
|
39
|
+
try:
|
|
40
|
+
fd = os.open(directory / f'slot-{number}', os.O_CREAT | os.O_RDWR | os.O_NOFOLLOW, 0o600)
|
|
41
|
+
except OSError as error:
|
|
42
|
+
return failure('slot.open', error)
|
|
37
43
|
try:
|
|
38
44
|
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
39
45
|
except BlockingIOError:
|
|
40
46
|
os.close(fd)
|
|
41
47
|
continue
|
|
48
|
+
except OSError as error:
|
|
49
|
+
os.close(fd)
|
|
50
|
+
return failure('slot.lock', error)
|
|
42
51
|
try:
|
|
43
52
|
notify('acquired')
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
try:
|
|
54
|
+
worker = subprocess.Popen([sys.executable, '-B', str(Path(__file__).with_name('cli.py')),
|
|
55
|
+
*sys.argv[1:]], stdin=subprocess.DEVNULL,
|
|
56
|
+
stderr=subprocess.DEVNULL, pass_fds=(fd,))
|
|
57
|
+
except OSError as error:
|
|
58
|
+
return failure('worker.launch', error)
|
|
47
59
|
# Node's pipe closes even on SIGKILL. Stop only this private
|
|
48
60
|
# group, so an orphan never consumes CPU or holds a slot.
|
|
49
61
|
while worker.poll() is None:
|
|
50
62
|
if parent_closed(0.2):
|
|
51
63
|
os.killpg(os.getpgrp(), signal.SIGKILL)
|
|
64
|
+
if worker.returncode < 0:
|
|
65
|
+
notify(f'worker.signal:{-worker.returncode}')
|
|
66
|
+
else:
|
|
67
|
+
notify(f'worker.exit:{worker.returncode}')
|
|
52
68
|
return worker.returncode
|
|
53
69
|
finally:
|
|
54
70
|
os.close(fd)
|
|
55
71
|
if not waiting:
|
|
56
|
-
|
|
72
|
+
notify('waiting')
|
|
57
73
|
waiting = True
|
|
58
74
|
remaining = deadline - time.monotonic()
|
|
59
75
|
if remaining <= 0:
|
|
@@ -63,5 +79,19 @@ def main(*, wait_seconds=3600):
|
|
|
63
79
|
return 2
|
|
64
80
|
|
|
65
81
|
|
|
82
|
+
def failure(stage, error):
|
|
83
|
+
# Only an OS errno crosses fd 3, never paths, argv or exception messages.
|
|
84
|
+
number = error.errno if isinstance(error.errno, int) and 0 < error.errno < 1000 else 0
|
|
85
|
+
notify(f'{stage}:{number}')
|
|
86
|
+
return 2
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def main(*, wait_seconds=3600):
|
|
90
|
+
try:
|
|
91
|
+
return hold_slot(wait_seconds=wait_seconds)
|
|
92
|
+
except OSError as error:
|
|
93
|
+
return failure('slot.wait', error)
|
|
94
|
+
|
|
95
|
+
|
|
66
96
|
if __name__ == '__main__':
|
|
67
97
|
raise SystemExit(main())
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
|
-
import { mkdtempSync,
|
|
3
|
+
import { mkdtempSync, 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
7
|
import { parseTimeoutSeconds, timeoutBounds } from './publish-check/timeout.mjs';
|
|
8
|
+
import { controlReader, diagnosticLimit, incompleteReport, osFailure, processFact, readReport, workerFact } from './publish-check/diagnostics.mjs';
|
|
8
9
|
|
|
9
10
|
const args = process.argv.slice(2);
|
|
10
11
|
let seconds = timeoutBounds.default;
|
|
@@ -14,10 +15,9 @@ for (let i = 0; i < args.length; i++) {
|
|
|
14
15
|
try { seconds = parseTimeoutSeconds(raw); } catch { /* Python reports invalid arguments. */ }
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
let child, reason, timer;
|
|
18
|
+
let scratch, fd, child, reason, timer;
|
|
19
|
+
const diagnostics = [];
|
|
20
|
+
const record = fact => { if (fact && diagnostics.length < diagnosticLimit) diagnostics.push(fact); };
|
|
21
21
|
const stop = value => {
|
|
22
22
|
reason ??= value;
|
|
23
23
|
// The child remains unreaped until its close handler; descendants (native
|
|
@@ -29,52 +29,79 @@ const stop = value => {
|
|
|
29
29
|
const interrupt = () => stop('scan.interrupted');
|
|
30
30
|
process.on('SIGINT', interrupt);
|
|
31
31
|
process.on('SIGTERM', interrupt);
|
|
32
|
-
let report, code = 2;
|
|
32
|
+
let report, code = 2, stage = 'scratch';
|
|
33
33
|
try {
|
|
34
|
+
scratch = mkdtempSync(join(tmpdir(), 'publish-check-'));
|
|
35
|
+
const output = join(scratch, 'report.json');
|
|
36
|
+
fd = openSync(output, 'wx', 0o600);
|
|
37
|
+
stage = 'slot';
|
|
34
38
|
child = spawn('python3', ['-B', new URL('./publish-check/slots.py', import.meta.url).pathname, ...args], {
|
|
35
|
-
|
|
39
|
+
// Neither holder tracebacks nor worker stderr are safe public diagnostics.
|
|
40
|
+
detached: true, stdio: ['pipe', fd, 'ignore', 'pipe'], env: { ...process.env, TMPDIR: scratch },
|
|
36
41
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
});
|
|
49
|
-
const result = await new Promise(resolve => {
|
|
50
|
-
child.once('error', () => resolve(null));
|
|
51
|
-
child.once('close', value => resolve(value));
|
|
42
|
+
const finished = new Promise(resolve => {
|
|
43
|
+
let error;
|
|
44
|
+
child.once('error', value => { error = value; });
|
|
45
|
+
child.once('close', (exitCode, signal) => resolve({ error, exitCode, signal }));
|
|
52
46
|
});
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
closeSync(fd);
|
|
48
|
+
fd = undefined;
|
|
49
|
+
child.stdio[3]?.setEncoding('utf8');
|
|
50
|
+
child.stdio[3]?.on('data', controlReader(message => {
|
|
51
|
+
if (message === 'acquired' && !timer) timer = setTimeout(() => stop('scan.deadline-exceeded'), seconds * 1000);
|
|
52
|
+
else if (message === 'waiting') process.stderr.write('waiting for a scan slot\n');
|
|
53
|
+
else if (['scan.slot-timeout', 'scan.slot-configuration'].includes(message)) reason ??= message;
|
|
54
|
+
else record(workerFact(message));
|
|
55
|
+
}));
|
|
56
|
+
const result = await finished;
|
|
57
|
+
const parsed = readReport(output);
|
|
58
|
+
// Report errors are secondary facts even when the process failed first.
|
|
59
|
+
if (reason || result.error || result.signal || ![0, 1, 2].includes(result.exitCode) || parsed.diagnostic) {
|
|
60
|
+
reason ??= 'scan.worker-incomplete';
|
|
61
|
+
record(processFact('slot', result));
|
|
62
|
+
record(parsed.diagnostic);
|
|
63
|
+
} else {
|
|
64
|
+
report = parsed.report;
|
|
65
|
+
code = result.exitCode;
|
|
66
|
+
}
|
|
67
|
+
} catch (error) {
|
|
68
|
+
reason ??= 'scan.worker-incomplete';
|
|
69
|
+
record(osFailure(stage, 'io.error', error));
|
|
70
|
+
} finally {
|
|
59
71
|
clearTimeout(timer);
|
|
60
72
|
process.removeListener('SIGINT', interrupt);
|
|
61
73
|
process.removeListener('SIGTERM', interrupt);
|
|
62
|
-
|
|
74
|
+
if (fd !== undefined) {
|
|
75
|
+
try { closeSync(fd); }
|
|
76
|
+
catch (error) { record(osFailure('cleanup', 'cleanup.close-error', error)); }
|
|
77
|
+
}
|
|
78
|
+
if (scratch) {
|
|
79
|
+
try { rmSync(scratch, { recursive: true, force: true }); }
|
|
80
|
+
catch (error) {
|
|
81
|
+
record(osFailure('cleanup', 'cleanup.remove-error', error));
|
|
82
|
+
// Retain existing failures, and never publish PASS after failed cleanup.
|
|
83
|
+
if (code === 0) { reason ??= 'scan.worker-incomplete'; code = 2; }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
63
86
|
}
|
|
64
|
-
if (reason) report =
|
|
65
|
-
|
|
66
|
-
findings: [{ rule: reason, path: '.', commit: null, scope: 'newly-public' }],
|
|
67
|
-
preExisting: [], warnings: [], fixtures: [], reviewed: [], info: [], thirdPartyNotices: [],
|
|
68
|
-
history: { commits: 0, trees: 0, blobs: 0 },
|
|
69
|
-
guarantees: { historyScanned: false, visualRecognition: false, environmentChecked: false },
|
|
70
|
-
};
|
|
87
|
+
if (reason) report = incompleteReport(reason);
|
|
88
|
+
if (reason || diagnostics.some(fact => fact.stage === 'cleanup')) report.diagnostics = diagnostics;
|
|
71
89
|
if (report.help) process.stdout.write(report.help);
|
|
72
90
|
else {
|
|
73
91
|
for (const finding of report.findings) {
|
|
74
92
|
if (finding.rule === 'scan.usage') process.stderr.write(`publish-check: ${finding.message}; see --help\n`);
|
|
75
93
|
}
|
|
76
94
|
report.implementation ??= {};
|
|
77
|
-
report.implementation.version = runningVersion();
|
|
95
|
+
try { report.implementation.version = runningVersion(); }
|
|
96
|
+
catch (error) {
|
|
97
|
+
record(osFailure('implementation', 'version.error', error));
|
|
98
|
+
if (code === 0) {
|
|
99
|
+
reason ??= 'scan.worker-incomplete';
|
|
100
|
+
report = incompleteReport(reason);
|
|
101
|
+
code = 2;
|
|
102
|
+
}
|
|
103
|
+
report.diagnostics = diagnostics;
|
|
104
|
+
}
|
|
78
105
|
process.stdout.write(JSON.stringify(report) + '\n');
|
|
79
106
|
}
|
|
80
107
|
process.exitCode = code;
|