@runeditrun/rer 0.2.9 → 0.2.11
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/bounded.mjs +1 -1
- package/global/CHANGELOG.md +18 -0
- package/modules/job-queue/load-admission.mjs +38 -0
- package/modules/operator-auth/README.md +4 -1
- package/modules/operator-auth/dev/index.mjs +7 -5
- package/modules/operator-auth/dev-gate.mjs +2 -1
- package/modules/operator-auth/identity/email-link/index.mjs +6 -2
- package/modules/operator-auth/identity/oidc/index.mjs +6 -1
- package/modules/operator-auth/rejected-response.mjs +44 -0
- package/modules/operator-auth/routes.mjs +6 -1
- package/modules/owner-claim/README.md +8 -6
- package/modules/owner-claim/transaction.mjs +4 -4
- package/onboarding/commands.mjs +2 -1
- package/onboarding/queue.mjs +8 -1
- package/onboarding/queued-entry.mjs +1 -1
- package/package.json +1 -1
package/cli/bounded.mjs
CHANGED
|
@@ -24,7 +24,7 @@ export async function boundedCommand(project,options,argv,out){
|
|
|
24
24
|
const {createCommands}=await shared('commands.mjs');
|
|
25
25
|
store=await createCommands(directory,{logs:[]},{terminal:()=>{}});
|
|
26
26
|
result=await queuedCommand(process.execPath,[fileURLToPath(new URL('../bin/rer.mjs',import.meta.url)),...childArgs],{
|
|
27
|
-
cwd:project.root,signal:cancellation.signal,stdio:[!options.json&&!options.nonInteractive?'inherit':'ignore','pipe','pipe'],originalCI:policy.ci,env:{...process.env,...policy.environment,RER_BOUNDED_OUTPUT:'1'},
|
|
27
|
+
cwd:project.root,verb:options.verb,signal:cancellation.signal,stdio:[!options.json&&!options.nonInteractive?'inherit':'ignore','pipe','pipe'],originalCI:policy.ci,env:{...process.env,...policy.environment,RER_BOUNDED_OUTPUT:'1'},
|
|
28
28
|
label:await queueLabel(project.root,options.verb,'workflow'),report:text=>out.progress(store.redact(text)+'\n'),onWaiting:options.json?details=>out.event('waiting',details):undefined,
|
|
29
29
|
spawn:(command,args,native)=>{
|
|
30
30
|
const child=store.spawn('Running bounded workflow',command,args,native);
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.11
|
|
4
|
+
|
|
5
|
+
- New Base foundations generate public Run instructions for the edition's planned product repository, distinct migration ordinals, and setup names matching the edition.
|
|
6
|
+
- Owned early auth, OIDC, local dev and template refusals finish ordinary request bodies before responding. Oversized or stalled uploads are bounded while privacy headers are retained.
|
|
7
|
+
|
|
8
|
+
### Upgrade notes
|
|
9
|
+
|
|
10
|
+
- Seeds receive these source changes with their next Base refresh; changing the npm pin alone does not refresh seed-owned runtime copies. Existing applied migration histories keep their names.
|
|
11
|
+
- Optional import-kit selection remains deferred until a canonical complete migration schema can drive generation; product import flows still need their own authorized adapter.
|
|
12
|
+
|
|
13
|
+
## 0.2.10
|
|
14
|
+
|
|
15
|
+
- First-owner bootstrap and signed owner claims use a client-IP rate budget, so junk setup-token requests from another client cannot block the correct claim. Repeated wrong tokens from one client remain limited.
|
|
16
|
+
|
|
17
|
+
### Upgrade notes
|
|
18
|
+
|
|
19
|
+
- Seeds receive this auth runtime fix with their next Base refresh. Updating the rer package alone does not replace seed-owned runtime copies.
|
|
20
|
+
|
|
3
21
|
## 0.2.9
|
|
4
22
|
|
|
5
23
|
- `rer deploy --remove --yes` empties each R2 bucket whose saved creation identity proves rer owns it, deletes the bucket, and verifies removal. Buckets with uncertain or replaced ownership are refused; interrupted deletion retains the deployment record so removal can resume.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { loadavg } from 'node:os';
|
|
2
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
3
|
+
import { configuration } from './config.mjs';
|
|
4
|
+
import { signalExit } from './command.mjs';
|
|
5
|
+
|
|
6
|
+
// CI and descendants sharing a live lease need no second queue slot, but each
|
|
7
|
+
// verification command still waits for load before starting its own deadlines.
|
|
8
|
+
// Once admitted, a running command is never suspended or polled here.
|
|
9
|
+
export async function waitForLoad({ signal, onWaiting, report } = {}) {
|
|
10
|
+
const controller = new AbortController();
|
|
11
|
+
const interrupt = () => controller.abort('SIGINT'), terminate = () => controller.abort('SIGTERM');
|
|
12
|
+
const external = () => controller.abort(signal.reason === 'SIGINT' ? 'SIGINT' : 'SIGTERM');
|
|
13
|
+
process.on('SIGINT', interrupt); process.on('SIGTERM', terminate);
|
|
14
|
+
signal?.addEventListener('abort', external, { once: true });
|
|
15
|
+
if (signal?.aborted) external();
|
|
16
|
+
try {
|
|
17
|
+
const config = await configuration();
|
|
18
|
+
let reportedAt;
|
|
19
|
+
while (!controller.signal.aborted) {
|
|
20
|
+
const load = loadavg()[0];
|
|
21
|
+
if (Number.isFinite(load) && load <= config.loadThreshold) return null;
|
|
22
|
+
if (reportedAt === undefined || Date.now() - reportedAt >= 15_000) {
|
|
23
|
+
const reason = Number.isFinite(load)
|
|
24
|
+
? `the 1-minute load is ${load.toFixed(1)} and verification commands start at ${config.loadThreshold} or below (change with RER_JOBS_LOAD_THRESHOLD)`
|
|
25
|
+
: 'this computer\'s load could not be read';
|
|
26
|
+
const detail = { reason, reasonCodes: [Number.isFinite(load) ? 'load' : 'resources_unavailable'], resources: { load }, limits: { loadThreshold: config.loadThreshold } };
|
|
27
|
+
if (onWaiting) await onWaiting(detail);
|
|
28
|
+
else report?.(`Waiting to start verification command: ${reason}. Running commands finish uninterrupted.`);
|
|
29
|
+
reportedAt = Date.now();
|
|
30
|
+
}
|
|
31
|
+
await delay(config.pollMs, undefined, { signal: controller.signal }).catch(error => { if (error.name !== 'AbortError') throw error; });
|
|
32
|
+
}
|
|
33
|
+
return { code: signalExit(controller.signal.reason), signal: controller.signal.reason };
|
|
34
|
+
} finally {
|
|
35
|
+
process.off('SIGINT', interrupt); process.off('SIGTERM', terminate);
|
|
36
|
+
signal?.removeEventListener('abort', external);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -285,7 +285,10 @@ an invitation whose issuer still has authority.
|
|
|
285
285
|
Durable fixed-window limits pair the client-IP resolver with a normalized email;
|
|
286
286
|
defaults are 30 per IP and 5 per email per 15 minutes. `limitWindowSeconds`,
|
|
287
287
|
`ipLimit` and `emailLimit` configure those defaults. Bootstrap, magic link,
|
|
288
|
-
invitation, confirmation and review use separate scopes.
|
|
288
|
+
invitation, confirmation and review use separate scopes. Bootstrap uses only
|
|
289
|
+
the client-IP budget: its configured owner email is shared by every caller,
|
|
290
|
+
so wrong setup tokens from one client cannot exhaust another client's budget.
|
|
291
|
+
The same bootstrap policy applies to signed owner claims. Confirmation limits bind
|
|
289
292
|
the presented opaque token instead of the address. `clientIp` is mandatory;
|
|
290
293
|
unavailable addresses fail closed (503). Header trust belongs to the deployment
|
|
291
294
|
boundary. Do not trust X-Forwarded-For.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rejectedResponse } from '../rejected-response.mjs';
|
|
1
2
|
// Local dev identity. SERVER-ONLY and LOCAL-ONLY: load this layer only from a
|
|
2
3
|
// local-only Worker entry (a `wrangler dev` or Vite-serve entry), never from the
|
|
3
4
|
// deployed main. `rer build` refuses any build output containing the marker.
|
|
@@ -40,19 +41,20 @@ export function withDevIdentity(worker, { bindings = env => env, config: authCon
|
|
|
40
41
|
if (managedInstallation(env)) {
|
|
41
42
|
// Never admit a dev credential here; with dev identity on, serve nothing.
|
|
42
43
|
registerDevAdmission(null);
|
|
43
|
-
if (env.RER_DEV_IDENTITY !== 'off') return text(503, 'Dev identity refuses to run beside RER_INSTALLATION_ID with a non-loopback RER_MANAGEMENT_ORIGIN. Remove those bindings from local settings or use rer dev --login.');
|
|
44
|
-
return new URL(request.url).pathname === '/auth/dev/enter' || new URL(request.url).pathname === '/__dev/personas' ? devNotFound() : worker.fetch(request, original, execution);
|
|
44
|
+
if (env.RER_DEV_IDENTITY !== 'off') return rejectedResponse(request, text(503, 'Dev identity refuses to run beside RER_INSTALLATION_ID with a non-loopback RER_MANAGEMENT_ORIGIN. Remove those bindings from local settings or use rer dev --login.'));
|
|
45
|
+
return new URL(request.url).pathname === '/auth/dev/enter' || new URL(request.url).pathname === '/__dev/personas' ? rejectedResponse(request, devNotFound()) : worker.fetch(request, original, execution);
|
|
45
46
|
}
|
|
46
47
|
const gate = devGate({ key: env.RER_DEV_KEY, origin: env.AUTH_ORIGIN, local: env.AUTH_LOCAL === 'true' });
|
|
47
48
|
registerDevAdmission(gate ? r => gate.admits(r) : null);
|
|
48
49
|
const path = new URL(request.url).pathname;
|
|
49
50
|
if (path === '/auth/dev/enter' || path === '/__dev/personas') {
|
|
50
|
-
if (!gate || env.RER_DEV_IDENTITY === 'off' || !await gate.admits(request)) return devNotFound();
|
|
51
|
+
if (!gate || env.RER_DEV_IDENTITY === 'off' || !await gate.admits(request)) return rejectedResponse(request, devNotFound());
|
|
51
52
|
const context = identity(env, authConfig, declared);
|
|
52
53
|
try {
|
|
53
|
-
|
|
54
|
+
const response = path === '/__dev/personas' ? Response.json(await context.list(), { headers }) : await enter(request, gate, context);
|
|
55
|
+
return rejectedResponse(request, response);
|
|
54
56
|
} catch (error) {
|
|
55
|
-
if (error instanceof AuthError) return Response.json({ error: error.code }, { status: error.status, headers });
|
|
57
|
+
if (error instanceof AuthError) return rejectedResponse(request, Response.json({ error: error.code }, { status: error.status, headers }));
|
|
56
58
|
throw error;
|
|
57
59
|
}
|
|
58
60
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rejectedResponse } from './rejected-response.mjs';
|
|
1
2
|
import { constantEqual } from './crypto.mjs';
|
|
2
3
|
import { isLoopbackHost, localCookieName } from './http.mjs';
|
|
3
4
|
|
|
@@ -76,7 +77,7 @@ export function devGate({ key, origin, local }) {
|
|
|
76
77
|
return new Response(request.method === 'HEAD' ? null : body, { headers: { ...privateHeaders, 'content-type': 'text/html; charset=utf-8',
|
|
77
78
|
'content-security-policy': `default-src 'none'; script-src ${script}; style-src ${style}; connect-src 'self'; base-uri 'none'; form-action 'none'; frame-ancestors 'none'` } });
|
|
78
79
|
}
|
|
79
|
-
if (request.method !== 'POST' || request.headers.get('sec-fetch-site') === 'cross-site' || !request.headers.get('content-type')?.startsWith('application/json')) return devNotFound();
|
|
80
|
+
if (request.method !== 'POST' || request.headers.get('sec-fetch-site') === 'cross-site' || !request.headers.get('content-type')?.startsWith('application/json')) return rejectedResponse(request, devNotFound());
|
|
80
81
|
const text = await request.text();
|
|
81
82
|
let presented; try { presented = text.length <= 1024 ? JSON.parse(text)?.key : undefined; } catch {}
|
|
82
83
|
if (typeof presented !== 'string' || !constantEqual(presented, key)) return devNotFound();
|
|
@@ -24,10 +24,14 @@ export function createEmailLinkLifecycle({ config: input, clock = Date.now, mail
|
|
|
24
24
|
if ((scope === 'magic' || scope === 'bootstrap') && await isLocalCli(request, config)) return;
|
|
25
25
|
const ip = await clientIp(request);
|
|
26
26
|
if (typeof ip !== 'string' || !ip || ip.length > 128) deny('client_ip_unavailable', 503);
|
|
27
|
-
|
|
27
|
+
// Bootstrap's email is the configured owner, shared by every caller. An
|
|
28
|
+
// unauthenticated caller must not spend another client's setup budget.
|
|
29
|
+
const subjects = [`${scope}:ip:${ip}`];
|
|
30
|
+
if (scope !== 'bootstrap') subjects.push(`${scope}:email:${email}`);
|
|
31
|
+
const keys = await Promise.all(subjects.map(subject => hash('rate', subject)));
|
|
28
32
|
const counts = await store.limits(keys, clock(), config.limitWindowSeconds * 1000);
|
|
29
33
|
if (!Array.isArray(counts) || counts.length !== keys.length || counts.some(value => !Number.isSafeInteger(value) || value < 0)) deny('invalid_proof_persistence', 503);
|
|
30
|
-
if (counts[0] > config.ipLimit || counts[1] > config.emailLimit) deny('rate_limited', 429);
|
|
34
|
+
if (counts[0] > config.ipLimit || (scope !== 'bootstrap' && counts[1] > config.emailLimit)) deny('rate_limited', 429);
|
|
31
35
|
}
|
|
32
36
|
async function newToken(kind, returnTo) {
|
|
33
37
|
const token = opaqueToken();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rejectedResponse } from '../../rejected-response.mjs';
|
|
1
2
|
// Server-only entry. Never include this module or its configuration in a browser bundle.
|
|
2
3
|
// OpenID Connect sign-in for several pinned providers at once. Each provider
|
|
3
4
|
// has its own start and callback route; its output is a verified principal,
|
|
@@ -279,7 +280,7 @@ export function createOidcProviders({ admission, db, config: input, clientIp, fe
|
|
|
279
280
|
|
|
280
281
|
// Exact routes only: /auth/oidc/<id>/start and /auth/oidc/<id>/callback.
|
|
281
282
|
export function createOidcHandler(oidc, { signInPath = oidc.signInPath ?? '/signin' } = {}) {
|
|
282
|
-
|
|
283
|
+
const handle = async request => {
|
|
283
284
|
const path = new URL(request.url).pathname;
|
|
284
285
|
const callbackId = oidc.callbackPaths?.[path];
|
|
285
286
|
if (callbackId) return oidc.callback(request, callbackId);
|
|
@@ -303,4 +304,8 @@ export function createOidcHandler(oidc, { signInPath = oidc.signInPath ?? '/sign
|
|
|
303
304
|
return oidc.begin(request, match[1], { returnTo: input.returnTo });
|
|
304
305
|
} catch (e) { return errorResponse(e instanceof OidcError ? e : new OidcError('oidc_invalid_input'), { signInPath }, request); }
|
|
305
306
|
};
|
|
307
|
+
return async request => {
|
|
308
|
+
const response = await handle(request);
|
|
309
|
+
return response ? rejectedResponse(request, response) : response;
|
|
310
|
+
};
|
|
306
311
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const maximumDiscardBytes = 64 * 1024
|
|
2
|
+
const maximumDiscardMs = 2000
|
|
3
|
+
|
|
4
|
+
function limitedResponse(response, message, status) {
|
|
5
|
+
const headers = new Headers(response.headers)
|
|
6
|
+
// Keep privacy/security policy, but never issue credentials or a redirect
|
|
7
|
+
// when the upload itself was refused.
|
|
8
|
+
for (const name of ['set-cookie', 'location', 'content-length', 'content-encoding']) headers.delete(name)
|
|
9
|
+
headers.set('content-type', 'text/plain; charset=utf-8')
|
|
10
|
+
void response.body?.cancel().catch(() => {})
|
|
11
|
+
return new Response(message, { status, headers })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Finish a rejected upload before returning its response. This preserves the
|
|
16
|
+
* intended status through workerd's upload proxy without buffering input.
|
|
17
|
+
* Oversized or stalled uploads receive explicit 413/408 responses instead.
|
|
18
|
+
*/
|
|
19
|
+
export async function rejectedResponse(request, response) {
|
|
20
|
+
if (!request.body || request.bodyUsed || request.body.locked) return response
|
|
21
|
+
const reader = request.body.getReader()
|
|
22
|
+
let bytes = 0
|
|
23
|
+
let timer
|
|
24
|
+
const deadline = new Promise(resolve => {
|
|
25
|
+
timer = setTimeout(() => resolve('timeout'), maximumDiscardMs)
|
|
26
|
+
})
|
|
27
|
+
try {
|
|
28
|
+
for (;;) {
|
|
29
|
+
const result = await Promise.race([reader.read(), deadline])
|
|
30
|
+
if (result === 'timeout') {
|
|
31
|
+
void reader.cancel('Rejected upload exceeded time limit').catch(() => {})
|
|
32
|
+
return limitedResponse(response, 'Request body timeout', 408)
|
|
33
|
+
}
|
|
34
|
+
if (result.done) return response
|
|
35
|
+
bytes += result.value.byteLength
|
|
36
|
+
if (bytes > maximumDiscardBytes) {
|
|
37
|
+
void reader.cancel('Rejected upload exceeded size limit').catch(() => {})
|
|
38
|
+
return limitedResponse(response, 'Request body too large', 413)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
} finally {
|
|
42
|
+
clearTimeout(timer)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { rejectedResponse } from './rejected-response.mjs';
|
|
1
2
|
import { identitySettingsPage } from './accounts/settings-page.mjs';
|
|
2
3
|
import { confirmationResponse } from './identity/email-link/confirmation.mjs';
|
|
3
4
|
import { createOidcHandler } from './identity/oidc/index.mjs';
|
|
@@ -20,7 +21,7 @@ function notice(auth, code, extra = {}) {
|
|
|
20
21
|
/** Fetch-compatible optional HTTP adapter. Returns null for paths it does not own. */
|
|
21
22
|
export function createAuthHandler(auth) {
|
|
22
23
|
const oidc = auth.providers ? createOidcHandler(auth.providers, { signInPath: auth.presentation.signInPath }) : null;
|
|
23
|
-
|
|
24
|
+
const handleAuth = async function(request) {
|
|
24
25
|
const url = new URL(request.url);
|
|
25
26
|
const path = url.pathname;
|
|
26
27
|
let form = false;
|
|
@@ -88,4 +89,8 @@ export function createAuthHandler(auth) {
|
|
|
88
89
|
return json({ error: 'auth_unavailable' }, 503);
|
|
89
90
|
}
|
|
90
91
|
};
|
|
92
|
+
return async function(request) {
|
|
93
|
+
const response = await handleAuth(request);
|
|
94
|
+
return response ? rejectedResponse(request, response) : response;
|
|
95
|
+
};
|
|
91
96
|
}
|
|
@@ -109,12 +109,14 @@ COOP `same-origin` to these two cooperating screens.
|
|
|
109
109
|
|
|
110
110
|
## Atomic admission and checks
|
|
111
111
|
|
|
112
|
-
Operator-auth normally commits rate
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
Operator-auth normally commits its client-IP rate limit before bootstrap. This
|
|
113
|
+
budget is per client, so wrong setup tokens from another client cannot block a
|
|
114
|
+
valid signed claim. A request-local D1 adapter reads the actual existing counter
|
|
115
|
+
and projects the real UPSERT result without writing. It defers that unchanged
|
|
116
|
+
UPSERT until the real bootstrap's unchanged three-statement batch. One D1
|
|
117
|
+
transaction inserts the single-use claim, checks an empty auth store, runs the
|
|
118
|
+
original limit and bootstrap SQL, then checks owner/session identity and the
|
|
119
|
+
actual client-IP threshold before committing.
|
|
118
120
|
A SQL CHECK failure or racing claim rolls the entire batch back. No application
|
|
119
121
|
mock, substitute owner/session creation, in-memory lock or retry is involved.
|
|
120
122
|
The adapter accepts only that exact SQL protocol and never serves other auth APIs.
|
|
@@ -36,7 +36,7 @@ export function bootstrapTransaction(db, claim, config, clock) {
|
|
|
36
36
|
async batch(statements) {
|
|
37
37
|
if (committed || !Array.isArray(statements) || statements.some(s => !owned.has(s))) return drift();
|
|
38
38
|
if (!limits) {
|
|
39
|
-
if (statements.length !==
|
|
39
|
+
if (statements.length !== 1 || statements.some(s => normalize(s.sql) !== LIMIT || s.args.length !== 2)) return drift();
|
|
40
40
|
limits = statements;
|
|
41
41
|
// Read the exact counters which the real UPSERT will increment. Auth's
|
|
42
42
|
// configured limit check still runs; repeat it on actual transaction
|
|
@@ -61,9 +61,9 @@ export function bootstrapTransaction(db, claim, config, clock) {
|
|
|
61
61
|
EXISTS(SELECT 1 FROM oa_operators WHERE id=? AND email=? AND role='owner' AND status='active') AND
|
|
62
62
|
EXISTS(SELECT 1 FROM oa_sessions WHERE id=? AND operator_id=?) AND
|
|
63
63
|
${claim.identity ? `EXISTS(SELECT 1 FROM rer_dependency_link WHERE interface='oidc-provider@1' AND issuer=? AND client_id=? AND metadata=? AND needs_relink=0 AND linked_at=?) AND EXISTS(SELECT 1 FROM rer_dependency_installation WHERE singleton=1 AND sector_id=?) AND` : ''}
|
|
64
|
-
${pin.sql} AND (SELECT count FROM oa_limits WHERE key=?)<=?
|
|
64
|
+
${pin.sql} AND (SELECT count FROM oa_limits WHERE key=?)<=?
|
|
65
65
|
THEN 1 ELSE 2 END WHERE jti=?`).bind(owner, owner, claim.email, session, owner,
|
|
66
|
-
...(claim.identity?[claim.identity.issuer,claim.identity.clientId,claim.identity.metadata,claim.identity.linkedAt,claim.installationId]:[]), ...pin.args, limits[0].args[0], config.ipLimit,
|
|
66
|
+
...(claim.identity?[claim.identity.issuer,claim.identity.clientId,claim.identity.metadata,claim.identity.linkedAt,claim.installationId]:[]), ...pin.args, limits[0].args[0], config.ipLimit, claim.jti);
|
|
67
67
|
try {
|
|
68
68
|
const identity = claim.identity ? [
|
|
69
69
|
db.prepare('INSERT INTO oc_idp_grants(issuer,client_id,jti,subject,sector_id) VALUES(?,?,?,?,?)').bind(claim.identity.issuer,claim.identity.clientId,claim.jti,claim.identity.subject,claim.installationId),
|
|
@@ -76,7 +76,7 @@ export function bootstrapTransaction(db, claim, config, clock) {
|
|
|
76
76
|
] : [];
|
|
77
77
|
const results = await db.batch([start, ...[...limits, ...statements].map(s => db.prepare(s.sql).bind(...s.args)), ...identity, finish]);
|
|
78
78
|
committed = true;
|
|
79
|
-
return results.slice(
|
|
79
|
+
return results.slice(1 + limits.length, 1 + limits.length + statements.length);
|
|
80
80
|
} catch {
|
|
81
81
|
// Includes unique/empty-store fences and final CHECK failure. D1 has
|
|
82
82
|
// rolled the whole batch back, including every original limit UPSERT.
|
package/onboarding/commands.mjs
CHANGED
|
@@ -141,7 +141,8 @@ export async function createCommands(directory,state,{terminal=text=>writeSync(1
|
|
|
141
141
|
async run(label,command,args=[],options={}) {
|
|
142
142
|
if(queuePolicy && options.heavy !== false) {
|
|
143
143
|
let queuedChild;
|
|
144
|
-
const
|
|
144
|
+
const commandSignal=signal&&options.signal?AbortSignal.any([signal,options.signal]):options.signal||signal;
|
|
145
|
+
const result = await queuedCommand(command,args,{...options,verb:queuePolicy.verb,signal:commandSignal,originalCI:policy.ci,
|
|
145
146
|
label:await queueLabel(options.cwd??process.cwd(),queuePolicy.verb,options.phase??'command'),report,onWaiting,
|
|
146
147
|
spawn:(program,argv,native)=>(queuedChild=spawnCommand(label,program,argv,{...native,onChild:options.onChild})),cleanup:async(child,result)=>{await stopCommand(child);await options.afterCommand?.(result);}});
|
|
147
148
|
if(result){if(result.code!==0)throw failure(label,result,captures.get(queuedChild));return result;}
|
package/onboarding/queue.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import { readFile, realpath } from 'node:fs/promises';
|
|
|
5
5
|
const portable = basename(dirname(fileURLToPath(import.meta.url))) === 'base-onboarding';
|
|
6
6
|
const queueURL = new URL(portable ? '../base-cli/modules/job-queue/' : '../modules/job-queue/', import.meta.url);
|
|
7
7
|
export const heavyVerbs = new Set(['install', 'setup', 'build', 'verify', 'dev', 'preview', 'deploy', 'release', 'export', 'import', 'installer']);
|
|
8
|
+
export const verificationBoundary = verb => verb === 'release' || verb === 'verify' || verb?.startsWith('verify:');
|
|
8
9
|
export async function queueLabel(root, verb, phase) {
|
|
9
10
|
root = await realpath(root);
|
|
10
11
|
let project='project';
|
|
@@ -35,7 +36,13 @@ export async function queuedCommand(command, args, options) {
|
|
|
35
36
|
// Keep the human recipe relative while retaining the executable argv for tools.
|
|
36
37
|
const statusCommandText = [basename(process.execPath), relative(options.cwd ?? process.cwd(), statusCommand[1]), ...statusCommand.slice(2)].map(shellQuote).join(' ');
|
|
37
38
|
// Read the original caller's decision before an install synthesizes CI=true.
|
|
38
|
-
if (options.originalCI === true || await liveMembership())
|
|
39
|
+
if (options.originalCI === true || await liveMembership()) {
|
|
40
|
+
if (verificationBoundary(options.verb)) {
|
|
41
|
+
const { waitForLoad } = await import(new URL('load-admission.mjs', queueURL));
|
|
42
|
+
return waitForLoad(options);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
39
46
|
const queue = await createQueue();
|
|
40
47
|
try {
|
|
41
48
|
const result = await queue.run([command, ...args], { ...options, kind: 'heavy', maxWait: 1200,
|
|
@@ -16,7 +16,7 @@ export async function queuedEntrypoint(url,verb='verify') {
|
|
|
16
16
|
const policy=await commandPolicy();
|
|
17
17
|
try{
|
|
18
18
|
const result=await queuedCommand(process.execPath,[...process.execArgv,fileURLToPath(url),...process.argv.slice(2)],{
|
|
19
|
-
cwd:process.cwd(),originalCI:policy.ci,label:await queueLabel(process.cwd(),verb,'suite'),report:text=>store.report(text),env:{...process.env,...policy.environment},
|
|
19
|
+
cwd:process.cwd(),verb,originalCI:policy.ci,label:await queueLabel(process.cwd(),verb,'suite'),report:text=>store.report(text),env:{...process.env,...policy.environment},
|
|
20
20
|
spawn:(command,args,options)=>store.spawn(verb,command,args,options),cleanup:child=>store.stop(child)});
|
|
21
21
|
return result?.code??null;
|
|
22
22
|
}finally{await policy.close();}
|