@runeditrun/rer 0.2.99 → 0.2.101
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 +30 -102
- package/cli/README.md +38 -25
- package/cli/app-address.mjs +2 -0
- package/cli/business/api.mjs +2 -1
- package/cli/business/choices.mjs +1 -1
- package/cli/business/command.mjs +36 -25
- package/cli/business/connect.mjs +1 -1
- package/cli/business/lease.mjs +0 -9
- package/cli/business/local-commands.mjs +1 -18
- package/cli/business/outbound.mjs +2 -14
- package/cli/business/questions.mjs +85 -48
- package/cli/business/service.mjs +1 -24
- package/cli/business/setup-command.mjs +33 -26
- package/cli/business/state.mjs +2 -2
- package/cli/business/supervisor.mjs +26 -91
- package/cli/companion/command.mjs +2 -0
- package/cli/demo-native.mjs +1 -1
- package/cli/deploy-command.mjs +5 -4
- package/cli/deploy-inputs.mjs +1 -1
- package/cli/deploy.mjs +6 -4
- package/cli/parse.mjs +2 -1
- package/cli/production-auth.mjs +16 -3
- package/cli/production-mail.mjs +18 -1
- package/cli/site.mjs +1 -1
- package/global/CHANGELOG.md +45 -0
- package/global/README.md +30 -102
- package/global/main.mjs +2 -0
- package/modules/container/adapters/d1-limits.mjs +2 -10
- package/modules/d1-transport/limits.d.mts +10 -0
- package/modules/d1-transport/limits.mjs +10 -0
- package/modules/demo-host/native/prepare.mjs +2 -1
- package/modules/deploy-kit/README.md +10 -0
- package/modules/deploy-kit/provider.mjs +18 -2
- package/modules/import-kit/schema/importers.schema.json +104 -2
- package/modules/import-kit/src/d1/README.md +13 -0
- package/modules/import-kit/src/d1/apply-reads.ts +48 -0
- package/modules/import-kit/src/d1/apply.ts +21 -8
- package/modules/import-kit/src/d1/history.ts +2 -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 +14 -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/provenance/credentials.ts +14 -5
- package/modules/import-kit/src/status/evidence.ts +3 -1
- package/modules/import-kit/src/status/index.ts +17 -2
- package/modules/import-kit/src/status/schema.ts +8 -0
- package/modules/import-kit/src/status/types.ts +25 -4
- 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
- package/cli/business/archive-task.mjs +0 -32
- package/cli/business/catchup-task.mjs +0 -42
- package/cli/business/export-inputs.mjs +0 -69
- package/cli/business/export-task.mjs +0 -17
- package/cli/business/setup-demo.mjs +0 -95
- package/cli/business/vendor-door.mjs +0 -231
- package/cli/business/vendors/README.md +0 -176
- package/cli/business/vendors/calendly.mjs +0 -80
- package/cli/business/vendors/common.mjs +0 -199
- package/cli/business/vendors/credential-names.mjs +0 -124
- package/cli/business/vendors/index.mjs +0 -86
- package/cli/business/vendors/pagerduty.mjs +0 -61
- package/cli/business/vendors/sentry.mjs +0 -85
- package/cli/business/vendors/sorry.mjs +0 -106
- package/cli/business/vendors/uptimerobot.mjs +0 -21
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ImporterValidationIssue,
|
|
7
7
|
ImporterValidationResult,
|
|
8
8
|
ImportersDocument,
|
|
9
|
+
MoveInImporterRecord,
|
|
9
10
|
} from './types.ts';
|
|
10
11
|
|
|
11
12
|
export type * from './types.ts';
|
|
@@ -22,7 +23,18 @@ export async function validateImporters(
|
|
|
22
23
|
const counters: ImporterValidationResult['evidence'] = { required: 0, resolved: 0, verifiedReceipts: 0 };
|
|
23
24
|
if (issues.length > 0) return result(issues, counters);
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
+
const { schemaVersion, importers } = document as ImportersDocument;
|
|
27
|
+
const records = importers as Array<ImporterRecord | MoveInImporterRecord>;
|
|
28
|
+
// Version 1 rows carry no Move in fields and version 2 rows all three; the schema allows either row shape in either file.
|
|
29
|
+
for (let index = 0; index < records.length; index += 1) {
|
|
30
|
+
if (Object.hasOwn(records[index]!, 'moveIn') !== (schemaVersion === 2)) {
|
|
31
|
+
issues.push({ code: 'SCHEMA_VERSION_ROW', path: `$.importers[${index}]`, message: schemaVersion === 2 ? 'Every version 2 row declares moveIn, accepts and export.' : 'Move in fields need schemaVersion 2.' });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (schemaVersion === 1 && Object.hasOwn(document as object, 'format')) {
|
|
35
|
+
issues.push({ code: 'SCHEMA_VERSION_ROW', path: '$.format', message: 'The import format path needs schemaVersion 2.' });
|
|
36
|
+
}
|
|
37
|
+
if (issues.length > 0) return result(issues, counters);
|
|
26
38
|
const seen = new Map<string, number>();
|
|
27
39
|
for (let index = 0; index < records.length; index += 1) {
|
|
28
40
|
const record = records[index]!;
|
|
@@ -43,7 +55,10 @@ export async function validateImporters(
|
|
|
43
55
|
}
|
|
44
56
|
if (issues.length > 0) return result(issues, counters);
|
|
45
57
|
|
|
46
|
-
|
|
58
|
+
// A row with no status declares only its Move in page; it has no evidence to resolve.
|
|
59
|
+
const evidenced = records.some((record) => 'evidence' in record);
|
|
60
|
+
if (!evidenced) return result(issues, counters);
|
|
61
|
+
const evidenceCounters = await validateImporterEvidence(records, evidence, issues);
|
|
47
62
|
return result(issues, evidenceCounters);
|
|
48
63
|
}
|
|
49
64
|
|
|
@@ -13,6 +13,8 @@ interface JsonSchema {
|
|
|
13
13
|
pattern?: string;
|
|
14
14
|
minimum?: number;
|
|
15
15
|
minItems?: number;
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
uniqueItems?: boolean;
|
|
16
18
|
minProperties?: number;
|
|
17
19
|
required?: string[];
|
|
18
20
|
properties?: Record<string, JsonSchema>;
|
|
@@ -91,6 +93,12 @@ function schemaIssues(value: unknown, schema: JsonSchema, root: JsonSchema, path
|
|
|
91
93
|
if (schema.minItems !== undefined && value.length < schema.minItems) {
|
|
92
94
|
issues.push({ code: 'SCHEMA_MIN_ITEMS', path, message: `Array must contain at least ${schema.minItems} item(s).` });
|
|
93
95
|
}
|
|
96
|
+
if (schema.maxItems !== undefined && value.length > schema.maxItems) {
|
|
97
|
+
issues.push({ code: 'SCHEMA_MAX_ITEMS', path, message: `Array must contain no more than ${schema.maxItems} item(s).` });
|
|
98
|
+
}
|
|
99
|
+
if (schema.uniqueItems && new Set(value.map(canonicalJson)).size !== value.length) {
|
|
100
|
+
issues.push({ code: 'SCHEMA_UNIQUE_ITEMS', path, message: 'Array items must be unique.' });
|
|
101
|
+
}
|
|
94
102
|
if (schema.items) {
|
|
95
103
|
for (let index = 0; index < value.length; index += 1) {
|
|
96
104
|
issues.push(...schemaIssues(value[index], schema.items, root, `${path}[${index}]`));
|
|
@@ -47,14 +47,35 @@ export interface NoImporter {
|
|
|
47
47
|
evidence: NoneEvidence;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
/** A version 1 row: the evidence-bound status of an importer. */
|
|
50
51
|
export type ImporterRecord = VerifiedImporter | DocumentedImporter | NoImporter;
|
|
51
52
|
|
|
52
|
-
export
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
export type MoveInAccepts = 'file' | 'key' | 'address';
|
|
54
|
+
|
|
55
|
+
/** What a seed's Move in page takes and how to get it out of the old tool (version 2). */
|
|
56
|
+
export interface MoveInDeclaration {
|
|
57
|
+
/** The seed's Move in path; starts with `/`. */
|
|
58
|
+
moveIn: string;
|
|
59
|
+
/** A non-empty subset of file, key and address. */
|
|
60
|
+
accepts: MoveInAccepts[];
|
|
61
|
+
/** One short paragraph of plain text, at most 1,000 characters. */
|
|
62
|
+
export: string;
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
/** A version 2 row; `status` and `evidence` appear together or not at all. */
|
|
66
|
+
export type MoveInImporterRecord =
|
|
67
|
+
| ({ incumbent: string; product: string } & MoveInDeclaration)
|
|
68
|
+
| (VerifiedImporter & MoveInDeclaration)
|
|
69
|
+
| (DocumentedImporter & MoveInDeclaration)
|
|
70
|
+
| (NoImporter & MoveInDeclaration);
|
|
71
|
+
|
|
72
|
+
export type ImportersDocument = {
|
|
73
|
+
$schema: './schema/importers.schema.json';
|
|
74
|
+
} & (
|
|
75
|
+
| { schemaVersion: 1; importers: ImporterRecord[]; format?: undefined }
|
|
76
|
+
| { schemaVersion: 2; importers: MoveInImporterRecord[]; format?: string }
|
|
77
|
+
);
|
|
78
|
+
|
|
58
79
|
/** A resolver must return the bytes it actually resolved and the final URL. */
|
|
59
80
|
export interface ResolvedEvidenceArtifact {
|
|
60
81
|
url: string;
|
package/onboarding/adapter.mjs
CHANGED
|
@@ -233,6 +233,7 @@ async function start(context, hooks) {
|
|
|
233
233
|
try{return await listenerPorts(child.pid);}
|
|
234
234
|
catch(error){throw installationFailure('command_failed',{step:'start',diagnostic:error});}
|
|
235
235
|
};
|
|
236
|
+
const readinessTimeoutMs=timeoutMs??60000,readinessStarted=performance.now();
|
|
236
237
|
try {
|
|
237
238
|
await store.waitForReady(readinessLabel, child, async probeSignal => {
|
|
238
239
|
if(runtimePortHandshake){
|
|
@@ -267,10 +268,15 @@ async function start(context, hooks) {
|
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
270
|
return result;
|
|
270
|
-
}, { signal, timeoutMs:
|
|
271
|
+
}, { signal, timeoutMs: readinessTimeoutMs, ...(softAfterMs ? { softAfterMs } : {}), ...(intervalMs ? { intervalMs } : {}) });
|
|
271
272
|
} catch (error) {
|
|
272
273
|
if (signal?.aborted) throw error;
|
|
273
274
|
if(detectedMismatch)throw installationFailure('command_failed',{step:'start',diagnostic:error});
|
|
275
|
+
if(runtimePortHandshake&&!announcement){
|
|
276
|
+
const prior=approvedFailure(error);
|
|
277
|
+
const message=`No managed listener was announced after ${Math.round(performance.now()-readinessStarted)} ms (allowed ${readinessTimeoutMs} ms). Check the runtime startup output in the log below, correct the startup error, then run rer ${context.verb??'setup'} again.`;
|
|
278
|
+
throw installationFailure('command_failed',{step:'start',diagnostic:commandFailure(`${message}\n${prior?.message??readinessLabel}`,prior??{})});
|
|
279
|
+
}
|
|
274
280
|
const ports=await ownedPorts();
|
|
275
281
|
if(ports.length){
|
|
276
282
|
let diagnosis;
|
|
@@ -30,6 +30,8 @@ export function operatorInstaller({ database, features, prepare, prepareData })
|
|
|
30
30
|
return {...lifecycle,localPrerequisites:async({root,vars,demo})=>vars.AUTH_LOCAL==='true'&&vars.MAIL_PROVIDER==='development'&&Boolean(vars.SESSION_SECRET)&&(demo||await operatorPrerequisites(root)),install:(root,input,store,onApp,signal)=>installOperator(root,input,store,onApp,signal,lifecycle.hooks)};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// Setup and dev give the real Vite listener one finite fifteen-minute startup
|
|
34
|
+
// budget, including its announcement and health check; no second readiness wait.
|
|
33
35
|
// Only local runtimes receive the dev key; vite.config.ts passes it to `vite dev` alone.
|
|
34
36
|
// No runtime rer starts serves the Local Explorer: it reads and writes the store
|
|
35
37
|
// without the key. trafficProxy also refuses /cdn-cgi/* on the public listener.
|
|
@@ -38,6 +40,6 @@ const developmentEnvironment = () => { const { RER_MODELS_SERVICE, RER_MODELS_KE
|
|
|
38
40
|
// A demo's Vite persists to its own folder (the seed's vite.config reads RER_STATE_DIR)
|
|
39
41
|
// and its Worker sees RER_DEMO=1 and the demo's end (modules/demo).
|
|
40
42
|
const demoBindings = demo => demo ? { RER_DEMO: '1', RER_DEMO_EXPIRES: demo.ends, RER_STATE_DIR: demo.state, RER_DEMO_RUN_URL: demo.runUrl } : {};
|
|
41
|
-
export const developmentTarget = ({ root, origin, devKey, modelsLive, demo }) => [process.execPath, [fileURLToPath(new URL('./development-runtime.mjs',import.meta.url)), 'dev', '--host', '127.0.0.1', '--port', '0', '--strictPort'], { runtimePortHandshake: true, stdio: ['ignore','pipe','pipe','ipc'], env: { ...developmentEnvironment(), PATH: [process.env.PATH, join(root, 'node_modules', '.bin')].filter(value => value !== undefined).join(delimiter), RER_DEV_ORIGIN: origin, WRANGLER_SEND_METRICS: 'false', X_LOCAL_EXPLORER: 'false', ...devBindings(devKey), ...(modelsLive ? { RER_MODELS_SERVICE: modelsLive.baseUrl, RER_MODELS_KEY: modelsLive.apiKey } : {}), ...demoBindings(demo) } }];
|
|
43
|
+
export const developmentTarget = ({ root, origin, devKey, modelsLive, demo }) => [process.execPath, [fileURLToPath(new URL('./development-runtime.mjs',import.meta.url)), 'dev', '--host', '127.0.0.1', '--port', '0', '--strictPort'], { timeoutMs: 900000, runtimePortHandshake: true, stdio: ['ignore','pipe','pipe','ipc'], env: { ...developmentEnvironment(), PATH: [process.env.PATH, join(root, 'node_modules', '.bin')].filter(value => value !== undefined).join(delimiter), RER_DEV_ORIGIN: origin, WRANGLER_SEND_METRICS: 'false', X_LOCAL_EXPLORER: 'false', ...devBindings(devKey), ...(modelsLive ? { RER_MODELS_SERVICE: modelsLive.baseUrl, RER_MODELS_KEY: modelsLive.apiKey } : {}), ...demoBindings(demo) } }];
|
|
42
44
|
|
|
43
45
|
export const previewTarget = ({ origin, devKey, scheduled }) => [process.execPath, [fileURLToPath(new URL('./production-runtime.mjs', import.meta.url))], { runtimePortHandshake: true, stdio: ['ignore','pipe','pipe','ipc'], env: { ...process.env, RER_DEV_ORIGIN: origin, RER_RUNTIME_HOST: '127.0.0.1', RER_RUNTIME_PORT: '0', WRANGLER_SEND_METRICS: 'false', CLOUDFLARE_INCLUDE_PROCESS_ENV: 'false', X_LOCAL_EXPLORER: 'false', RER_RUNTIME_TRIGGERS: scheduled ? '1' : '0', ...(devKey ? { RER_DEV_KEY: devKey } : {}) } }];
|
package/package.json
CHANGED
|
@@ -54,6 +54,26 @@ its worker inherits the lock so it cannot outlive its slot. Queueing has its
|
|
|
54
54
|
own one-hour cap. `timeout.json` supplies the shared default and upper bound
|
|
55
55
|
to Python and the Node/release validator.
|
|
56
56
|
|
|
57
|
+
Process failures keep the v3 INCOMPLETE/exit-2 refusal. Its optional
|
|
58
|
+
`diagnostics` array identifies worker or slot launch errors, exits and signals,
|
|
59
|
+
report read/empty/parse/shape failures, version-metadata failures and scratch
|
|
60
|
+
cleanup failures. Cleanup cannot replace the original process/report failure. Completed worker reports
|
|
61
|
+
keep their existing status, exit and coverage fields when cleanup succeeds.
|
|
62
|
+
Cleanup failure preserves an existing refusal and its diagnostics; if the
|
|
63
|
+
worker succeeded, cleanup failure returns INCOMPLETE/exit 2 instead of PASS.
|
|
64
|
+
Version stamping also preserves earlier failure facts and refuses on failure.
|
|
65
|
+
|
|
66
|
+
Only fixed stage/code strings, OS errno names, signal names and numeric exit
|
|
67
|
+
codes cross this diagnostic boundary. No exception message, traceback, command
|
|
68
|
+
argument, path, report fragment or child stderr is retained or forwarded.
|
|
69
|
+
Both holder and worker stderr are discarded; queue notices are fixed text
|
|
70
|
+
rendered by Node from the holder's private fd-3 protocol. The worker does not
|
|
71
|
+
inherit that descriptor. Protocol lines retain at most 128 characters and
|
|
72
|
+
public reports contain at most eight diagnostic facts. Scratch remains private,
|
|
73
|
+
and cleanup removes only the directory this invocation created. If removal
|
|
74
|
+
fails, the report records its errno without exposing the scratch path; there
|
|
75
|
+
is no retained-stderr file or diagnostic log to collect.
|
|
76
|
+
|
|
57
77
|
Git message records carry their kind explicitly. Only commit records enable the
|
|
58
78
|
bounded public coauthor address rule described in the command guide; a file named
|
|
59
79
|
`@commit-message` has no special status. `public_hygiene.py` matches complete raw
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Failure facts are an allowlisted protocol, never child stderr or exception text.
|
|
2
|
+
import { constants } from 'node:os';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
const errnos = new Map(Object.entries(constants.errno).map(([name, number]) => [number, name]));
|
|
6
|
+
const signals = new Set(Object.keys(constants.signals));
|
|
7
|
+
export const diagnosticLimit = 8;
|
|
8
|
+
export const controlLineLimit = 128;
|
|
9
|
+
|
|
10
|
+
export function osFailure(stage, code, error) {
|
|
11
|
+
return { stage, code, errno: errnos.get(Math.abs(error?.errno)) ?? 'UNKNOWN' };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function processFact(stage, { error, exitCode, signal }) {
|
|
15
|
+
if (error) return osFailure(stage, 'process.launch-error', error);
|
|
16
|
+
if (signal) return { stage, code: 'process.signal', signal: signals.has(signal) ? signal : 'UNKNOWN' };
|
|
17
|
+
return { stage, code: 'process.exit', exitCode: Number.isInteger(exitCode) ? exitCode : null };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// fd 3 is private to the slot holder; it is not inherited by the scan worker.
|
|
21
|
+
// Still bound framing and accept only fixed tokens and typed numeric fields.
|
|
22
|
+
export function controlReader(onMessage) {
|
|
23
|
+
let pending = '', overflow = false;
|
|
24
|
+
return data => {
|
|
25
|
+
for (const character of data) {
|
|
26
|
+
if (character === '\n') {
|
|
27
|
+
if (!overflow) onMessage(pending);
|
|
28
|
+
pending = ''; overflow = false;
|
|
29
|
+
} else if (!overflow) {
|
|
30
|
+
if (pending.length < controlLineLimit) pending += character;
|
|
31
|
+
else { pending = ''; overflow = true; }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function workerFact(message) {
|
|
38
|
+
const match = /^(worker\.(exit|signal|launch)|slot\.(directory|open|lock|wait)):(\d{1,3})$/.exec(message);
|
|
39
|
+
if (!match) return;
|
|
40
|
+
const number = Number(match[4]);
|
|
41
|
+
if (match[2] === 'exit' && number <= 255) return { stage: 'worker', code: 'process.exit', exitCode: number };
|
|
42
|
+
if (match[2] === 'signal' && number > 0 && number < 128) {
|
|
43
|
+
const signal = Object.entries(constants.signals).find(([, value]) => value === number)?.[0] ?? 'UNKNOWN';
|
|
44
|
+
return { stage: 'worker', code: 'process.signal', signal };
|
|
45
|
+
}
|
|
46
|
+
if (match[2] === 'launch') return { stage: 'worker', code: 'process.launch-error', errno: errnos.get(number) ?? 'UNKNOWN' };
|
|
47
|
+
if (match[3]) return { stage: 'slot-' + match[3], code: 'os.error', errno: errnos.get(number) ?? 'UNKNOWN' };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function readReport(path) {
|
|
51
|
+
let text, report;
|
|
52
|
+
try { text = readFileSync(path, 'utf8'); }
|
|
53
|
+
catch (error) { return { diagnostic: osFailure('report', 'report.read-error', error) }; }
|
|
54
|
+
if (!text.trim()) return { diagnostic: { stage: 'report', code: 'report.empty' } };
|
|
55
|
+
try { report = JSON.parse(text); }
|
|
56
|
+
catch { return { diagnostic: { stage: 'report', code: 'report.parse-error' } }; }
|
|
57
|
+
if (!report || typeof report !== 'object' || Array.isArray(report) ||
|
|
58
|
+
!(typeof report.help === 'string' || (Array.isArray(report.findings) &&
|
|
59
|
+
report.findings.every(finding => finding && typeof finding.rule === 'string')))) {
|
|
60
|
+
return { diagnostic: { stage: 'report', code: 'report.shape-error' } };
|
|
61
|
+
}
|
|
62
|
+
return { report };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function incompleteReport(reason) {
|
|
66
|
+
return {
|
|
67
|
+
schema: 'rer.publish-check/v3', status: 'INCOMPLETE', complete: false, source: null,
|
|
68
|
+
findings: [{ rule: reason, path: '.', commit: null, scope: 'newly-public' }],
|
|
69
|
+
preExisting: [], warnings: [], fixtures: [], reviewed: [], info: [], thirdPartyNotices: [],
|
|
70
|
+
history: { commits: 0, trees: 0, blobs: 0 },
|
|
71
|
+
guarantees: { historyScanned: false, visualRecognition: false, environmentChecked: false },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -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;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { withUploadedBundle, door, DOOR_ID, count, plural } from './vendor-door.mjs';
|
|
2
|
-
|
|
3
|
-
// Key order is not part of the door's counts; compare them as values.
|
|
4
|
-
const stable = value => JSON.stringify(value, (_, item) => item && typeof item === 'object' && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Perform a claimed switchoff.archive: the vendor's final export uploaded into
|
|
8
|
-
* the app's import door, kept there by the door's `archive` action as the tool's
|
|
9
|
-
* archive in the app's own storage (`business-archive/<tool>/<takenAt>`, the tool
|
|
10
|
-
* being the vendor's namespace), then read back by the door's `restore-check`,
|
|
11
|
-
* which parses it and writes nothing native. Run checks that the archive and its
|
|
12
|
-
* test-restore are exactly this bundle, then completes with the archive_id and
|
|
13
|
-
* the bundle's SHA-256; Business runs its own restore-check before the task is
|
|
14
|
-
* done. Returns the line to say.
|
|
15
|
-
*/
|
|
16
|
-
export function runArchive({ lease, task, grant, directory, say, ownerPage }) {
|
|
17
|
-
const takenAt = new Date().toISOString();
|
|
18
|
-
return withUploadedBundle({ lease, task, grant, directory, say,
|
|
19
|
-
doing: (name, origin, keyed) => `Archiving the final ${name} export through the shipped read-only adapter. ${keyed ? 'The key stays on this computer; the archive' : 'The archive'} goes only to the app's import door at ${origin} and stays in the app's own storage.` },
|
|
20
|
-
async ({ vendor, name, origin, uploadId, bundle, fresh }) => {
|
|
21
|
-
const kept = await door(await fresh('archive'), { uploadId, tool: vendor, takenAt }, lease.signal);
|
|
22
|
-
const [input, unique, rejected] = ['input', 'unique', 'rejected'].map(field => count(kept.counts?.[field]));
|
|
23
|
-
if (typeof kept.archiveId !== 'string' || !DOOR_ID.test(kept.archiveId) || kept.key !== `business-archive/${vendor}/${takenAt}` || kept.tool !== vendor
|
|
24
|
-
|| kept.takenAt !== takenAt || kept.bundleSha256 !== bundle.sha256 || kept.bytes !== bundle.size || [input, unique, rejected].includes(null)) throw Error("The app's import door returned an invalid archive answer.");
|
|
25
|
-
// The door reads its own copy back and parses it as a restore would, with no native writes.
|
|
26
|
-
const restored = await door(await fresh('restore-check'), { archiveId: kept.archiveId }, lease.signal);
|
|
27
|
-
if (restored.archiveId !== kept.archiveId || restored.key !== kept.key || restored.bundleSha256 !== bundle.sha256 || restored.bytes !== bundle.size
|
|
28
|
-
|| stable(restored.counts) !== stable(kept.counts) || !Array.isArray(restored.rejected)) throw Error(`The app's test-restore of the ${name} archive does not match the exported file. The archive was not reported.`);
|
|
29
|
-
return { outputs: { archive_id: kept.archiveId, bundle_sha256: bundle.sha256 },
|
|
30
|
-
said: `Archive kept in ${origin} as ${kept.key}: ${plural(bundle.size, 'byte')}, ${plural(unique, 'source record')}, test-restored with no writes (${rejected} rejected). Business test-restores it again itself; cancelling ${name} stays the owner's step in the browser: ${ownerPage}` };
|
|
31
|
-
});
|
|
32
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { withUploadedBundle, door, checkedPreview, plural } from './vendor-door.mjs';
|
|
2
|
-
|
|
3
|
-
// Why the door refused a catch-up under the owner's standing approval
|
|
4
|
-
// (import-kit door, "Catch-up and recovery": `catchup_requires_proposal:<reason>`).
|
|
5
|
-
const beyond = {
|
|
6
|
-
empty_baseline: 'the app holds no earlier import to compare with',
|
|
7
|
-
source_records_gone: 'records were removed in the old tool',
|
|
8
|
-
native_or_mapping_conflict: 'records changed in the app since they were imported',
|
|
9
|
-
rejected_or_unmapped_records: 'some records cannot be brought over as they are',
|
|
10
|
-
change_must_be_under_five_percent: '5% or more of the records changed',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Perform a claimed catchup.vendor: the vendor's current export uploaded into the
|
|
15
|
-
* app's import door, then a catch-up plan of it (a zero-write preview of what
|
|
16
|
-
* changed since the import). Business mints the plan grant under the owner's
|
|
17
|
-
* standing catch-up approval when one covers this tool; the door then refuses a
|
|
18
|
-
* change at or above its bound, and run asks for a plan grant for the owner's
|
|
19
|
-
* review instead. Completion reports the door's upload_id and plan_id and the
|
|
20
|
-
* bundle's SHA-256; Business applies the plan under the standing approval or
|
|
21
|
-
* after the owner approves it. Returns the line to say.
|
|
22
|
-
*/
|
|
23
|
-
export function runCatchup({ lease, task, grant, directory, say, ownerPage }) {
|
|
24
|
-
return withUploadedBundle({ lease, task, grant, directory, say,
|
|
25
|
-
doing: (name, origin, keyed) => `Bringing over recent ${name} changes through the shipped read-only adapter. ${keyed ? 'The key stays on this computer; records' : 'Records'} go only to the app's import door at ${origin}.` },
|
|
26
|
-
async ({ origin, uploadId, bundle, fresh }) => {
|
|
27
|
-
let planGrant = await fresh('plan'), refused = null, preview;
|
|
28
|
-
try { preview = await door(planGrant, { uploadId, catchup: true }, lease.signal); }
|
|
29
|
-
catch (error) {
|
|
30
|
-
const reason = planGrant.catchup === 'bounded' && /^catchup_requires_proposal:([a-z0-9_]+)$/.exec(error.doorCode ?? '')?.[1];
|
|
31
|
-
if (!reason) throw error;
|
|
32
|
-
refused = Object.hasOwn(beyond, reason) ? beyond[reason] : 'it is more than that approval covers';
|
|
33
|
-
planGrant = await fresh('plan', { review: true });
|
|
34
|
-
preview = await door(planGrant, { uploadId, catchup: true }, lease.signal);
|
|
35
|
-
}
|
|
36
|
-
const { records, created, updated, unchanged, gone, rejected } = checkedPreview(preview, bundle);
|
|
37
|
-
const planned = `Catch-up planned in ${origin}: ${plural(records, 'source record')}; ${created} new, ${updated} changed, ${unchanged} unchanged, ${gone} gone, ${rejected} rejected.`;
|
|
38
|
-
return { outputs: { upload_id: uploadId, plan_id: preview.planId, bundle_sha256: bundle.sha256 },
|
|
39
|
-
said: planGrant.catchup === 'bounded' ? `${planned} It is within the owner's standing catch-up approval, so Business applies it and checks the result.`
|
|
40
|
-
: `${planned} ${refused ? `It needs the owner's own approval (${refused}): nothing` : 'Nothing'} changes in the app until the owner approves this catch-up in the browser: ${ownerPage}` };
|
|
41
|
-
});
|
|
42
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// The non-secret inputs a leased vendor task carries for its shipped adapter
|
|
2
|
-
// (the executor task view's `export_inputs`, platform executors/tasks.ts): one
|
|
3
|
-
// closed shape per vendor, never a key. Business fills them from the Business's
|
|
4
|
-
// inventory evidence and the owner's answers; a window the plan does not state
|
|
5
|
-
// is the vendor's full history (`since` null or absent).
|
|
6
|
-
//
|
|
7
|
-
// sentry {organization: {id, slug, region: 'us'|'de'}, window: {since}}
|
|
8
|
-
// pagerduty {window: {since}, schedules: 'all'} (the plan moves every rota and
|
|
9
|
-
// keeps PagerDuty as the pager)
|
|
10
|
-
// sorry {page: {host}}
|
|
11
|
-
// uptimerobot needs none.
|
|
12
|
-
|
|
13
|
-
const DAY = 86_400_000;
|
|
14
|
-
const invalid = () => { throw Error('Business returned invalid export inputs for this task.'); };
|
|
15
|
-
const plain = value => value && typeof value === 'object' && !Array.isArray(value) ? value : invalid();
|
|
16
|
-
function closed(value, required, optional = []) {
|
|
17
|
-
plain(value);
|
|
18
|
-
if (Object.keys(value).some(key => !required.includes(key) && !optional.includes(key)) || required.some(key => !Object.hasOwn(value, key))) invalid();
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
const sourceId = value => typeof value === 'string' && /^[A-Za-z0-9_-]{1,128}$/.test(value) ? value : invalid();
|
|
22
|
-
/** The window's start as an ISO instant, or null for the vendor's full history. */
|
|
23
|
-
function since(window) {
|
|
24
|
-
closed(window, [], ['since']);
|
|
25
|
-
const value = window.since ?? null;
|
|
26
|
-
if (value === null) return null;
|
|
27
|
-
if (typeof value !== 'string' || value.length > 40 || !/^\d{4}-\d\d-\d\dT/.test(value) || !Number.isFinite(Date.parse(value))) invalid();
|
|
28
|
-
return new Date(value).toISOString();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const shapes = {
|
|
32
|
-
uptimerobot: () => ({}),
|
|
33
|
-
sentry(value, now) {
|
|
34
|
-
closed(value, ['organization', 'window']);
|
|
35
|
-
const organization = closed(value.organization, ['id', 'slug', 'region']);
|
|
36
|
-
if (!['us', 'de'].includes(organization.region)) invalid();
|
|
37
|
-
const id = Number.isSafeInteger(organization.id) && organization.id >= 0 ? String(organization.id) : sourceId(organization.id);
|
|
38
|
-
// Full history: from the start of time, which Sentry answers with all it retains.
|
|
39
|
-
return { organization: { id, slug: sourceId(organization.slug), region: organization.region }, start: since(value.window) ?? new Date(0).toISOString(), end: new Date(now).toISOString() };
|
|
40
|
-
},
|
|
41
|
-
pagerduty(value, now) {
|
|
42
|
-
closed(value, ['window', 'schedules']);
|
|
43
|
-
if (value.schedules !== 'all') invalid();
|
|
44
|
-
// Rotas move into Oncall beside PagerDuty, so the window runs in whole UTC days
|
|
45
|
-
// to two weeks ahead (the coming overrides; the default of Oncall's own
|
|
46
|
-
// exporter). Oncall compares a schedule's final timeline over at most 31 days
|
|
47
|
-
// and refuses a longer one, so the window starts at the plan's `since` or 31
|
|
48
|
-
// days before its end, whichever is later.
|
|
49
|
-
const until = Math.floor(now / DAY) * DAY + 14 * DAY, start = since(value.window), floor = until - 31 * DAY;
|
|
50
|
-
return { start: new Date(start === null ? floor : Math.max(Math.floor(Date.parse(start) / DAY) * DAY, floor)).toISOString(), end: new Date(until).toISOString() };
|
|
51
|
-
},
|
|
52
|
-
sorry(value) {
|
|
53
|
-
closed(value, ['page']);
|
|
54
|
-
const page = closed(value.page, ['host']);
|
|
55
|
-
if (typeof page.host !== 'string' || page.host.length > 253 || !/^[a-z0-9.-]+$/.test(page.host)) invalid();
|
|
56
|
-
return { page: { host: page.host } };
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
/** What each vendor's inputs are, in the owner's terms, while a task lacks them. */
|
|
60
|
-
export const inputNeeds = { sentry: 'its Sentry organization and export window', pagerduty: 'its export window', sorry: "its status page's address" };
|
|
61
|
-
|
|
62
|
-
/** The shipped adapter's inputs for `vendor` from the leased task's
|
|
63
|
-
* `export_inputs`, or null when the task carries none yet. */
|
|
64
|
-
export function exportInputs(vendor, task, now = Date.now()) {
|
|
65
|
-
if (!Object.hasOwn(shapes, vendor)) return null;
|
|
66
|
-
if (vendor === 'uptimerobot') return {};
|
|
67
|
-
if (task.export_inputs === undefined || task.export_inputs === null) return null;
|
|
68
|
-
return shapes[vendor](task.export_inputs, now);
|
|
69
|
-
}
|