@runeditrun/rer 0.2.116 → 0.2.118
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 +0 -6
- package/cli/README.md +25 -0
- package/cli/business/command.mjs +5 -8
- package/cli/business/connect.mjs +6 -104
- package/cli/business/local-commands.mjs +2 -2
- package/cli/business/state.mjs +3 -3
- package/cli/contract.mjs +2 -2
- package/cli/hosted-output.mjs +4 -4
- package/cli/inspect.mjs +8 -3
- package/cli/parse.mjs +1 -1
- package/cli/size/clock.mjs +7 -3
- package/cli/size/command.mjs +2 -1
- package/cli/size/flows.mjs +23 -12
- package/cli/size/grow.mjs +27 -10
- package/cli/size/install.mjs +16 -5
- package/cli/size/measure.mjs +10 -3
- package/cli/size/meter.mjs +6 -1
- package/cli/size/verdict.mjs +5 -4
- package/global/CHANGELOG.md +32 -0
- package/global/README.md +0 -6
- package/modules/deploy-kit/owner-cli.mjs +6 -3
- package/modules/deploy-kit/owner.mjs +21 -3
- package/operations/README.md +14 -1
- package/operations/operations.mjs +2 -0
- package/operations/project-operations.mjs +8 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -531,12 +531,6 @@ different origin or Business: disconnect first or use a separate
|
|
|
531
531
|
`RER_BUSINESS_STATE_DIR`. It reports this computer's plain name, working folder,
|
|
532
532
|
agent and OS (including WSL) for the owner to recognise.
|
|
533
533
|
|
|
534
|
-
For older Business pages, `rer business connect --code ABCD-1234 --origin URL`
|
|
535
|
-
keeps the browser-created code and six-digit confirmation-number flow unchanged
|
|
536
|
-
in 0.2.98. It cannot be combined with `--business` or `--timeout`. Removal is
|
|
537
|
-
planned for a later release after the production rollback target uses device pairing.
|
|
538
|
-
The install.sh form still passes either connect command through unchanged.
|
|
539
|
-
|
|
540
534
|
The owner chooses three things on the computer's row in the browser: "Add rules
|
|
541
535
|
so Claude Code never reads your secret files" (Claude Code user Read deny
|
|
542
536
|
rules), "Keep this computer awake while it works" (recorded; nothing keeps the computer awake now that rer runs no exports) and "Install the background service" (a launchd or systemd user
|
package/cli/README.md
CHANGED
|
@@ -292,6 +292,17 @@ anything is built or uploaded. The seed owns what an installation does with mail
|
|
|
292
292
|
off, and turning mail on later is a `rer deploy --set-secret` of the provider
|
|
293
293
|
inputs the seed documents.
|
|
294
294
|
|
|
295
|
+
The adapter must apply that selection to the runtime as well as pass preflight.
|
|
296
|
+
For example, the foundation declares optional `MAIL_PROVIDER` and `MAIL_FROM`
|
|
297
|
+
environment-to-binding mappings in `deploy.json`, and makes `MAIL_API_KEY`
|
|
298
|
+
optional there; production preflight still requires all enabled-provider inputs.
|
|
299
|
+
Its mail facade returns no sender for `none`, so email requests report
|
|
300
|
+
`mail_unavailable` rather than claiming delivery. Independently authored adapters
|
|
301
|
+
must implement their own matching contract. Declarative operations loops can
|
|
302
|
+
offer `none` for optional mail; required delivery loops continue to fail while off.
|
|
303
|
+
|
|
304
|
+
— Codex, 2026-11-15T03:31:15Z
|
|
305
|
+
|
|
295
306
|
The production preflight also reads the product's `artifact.specInputs` in
|
|
296
307
|
`rer-packaging.json`, `packaging.json` or `scripts/delivery/base/packaging.json`,
|
|
297
308
|
and `management/integration/deployment-spec.json`. Public inputs come from
|
|
@@ -672,3 +683,17 @@ new clauses start missing, and seed-owned AGENT and SURFACE clauses stay intact.
|
|
|
672
683
|
Run the edition's source-lock command last. See
|
|
673
684
|
[Contract clauses](../modules/agent-door/ADOPTING.md#contract-clauses) for source
|
|
674
685
|
delivery and generation details.
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
## Size measurement isolation
|
|
689
|
+
|
|
690
|
+
`rer size` uses the disposable host's preparation API to hold queue consumers
|
|
691
|
+
before owner setup or fixtures can enqueue work. Producers and declared scheduled
|
|
692
|
+
handlers still run. Setup `waitUntil` work settles before the first flow.
|
|
693
|
+
A request failure, timeout or unsettled measurement stops that session before
|
|
694
|
+
another repeat, flow or size: aborting the client does not prove D1 cancellation.
|
|
695
|
+
`--write-statements DIR` retains both size files on failure, marking partial and
|
|
696
|
+
unattempted sizes `complete:false`; these files keep the existing statement names,
|
|
697
|
+
SQL and bound parameters and carry diagnostic flow summaries. Missing work never
|
|
698
|
+
produces a passing growth verdict. See the size section of
|
|
699
|
+
[the command contract](../export/SEED-COMMAND-CONTRACT.md#statement-size-and-growth-sc-15).
|
package/cli/business/command.mjs
CHANGED
|
@@ -8,7 +8,8 @@ import { describe } from './errors.mjs';
|
|
|
8
8
|
import { identifier, originUrl } from './api.mjs';
|
|
9
9
|
import { appAddress, appSignInHelp } from '../app-address.mjs';
|
|
10
10
|
|
|
11
|
-
const usage = `Set up your business: rer business connect
|
|
11
|
+
const usage = `Set up your business: rer business connect --business ID
|
|
12
|
+
The Business Connect page names the ID.
|
|
12
13
|
Business keeps your business name, logo and brand colour together for the apps
|
|
13
14
|
that support shared Business settings. Choose what to share in your browser.
|
|
14
15
|
|
|
@@ -19,7 +20,6 @@ Advanced commands (Usage: rer business VERB)
|
|
|
19
20
|
scan [DIR...] [--json] Names-only local discovery
|
|
20
21
|
connect --business ID [--origin URL] [--timeout SECONDS]
|
|
21
22
|
Print a code and link for the owner to approve in a signed-in browser
|
|
22
|
-
Older Business pages: connect --code CODE [--origin URL]
|
|
23
23
|
Connect carries the Business name into local apps
|
|
24
24
|
run [--once] Work this computer's tasks: the folder scan the owner allows. Says what
|
|
25
25
|
it is doing and what it waits for; applies the owner's choices at each
|
|
@@ -72,13 +72,12 @@ the code's 10 minutes), then keeps the credential in OS credential storage.
|
|
|
72
72
|
--origin URL Business platform address (default: ${appAddress}).
|
|
73
73
|
--timeout SECONDS Wait at most this long, then exit 75 with the pairing kept;
|
|
74
74
|
run the same command again to keep waiting (same code).
|
|
75
|
-
--code CODE Older Business pages: redeem a code made in the browser.
|
|
76
75
|
Exits 0 connected, 1 ended (refused, expired or failed), 2 usage, 75 still waiting.
|
|
77
76
|
`,
|
|
78
77
|
token: `Usage: rer business token
|
|
79
78
|
Print an MCP Authorization header object for this computer's paired Business.
|
|
80
79
|
Send this headersHelper output directly to the MCP client; it contains a credential.
|
|
81
|
-
Requires an existing pairing: rer business connect.
|
|
80
|
+
Requires an existing pairing: rer business connect --business ID (the Connect page names the ID).
|
|
82
81
|
`,
|
|
83
82
|
};
|
|
84
83
|
|
|
@@ -93,11 +92,9 @@ export async function businessCommand(argv) {
|
|
|
93
92
|
const options = {};
|
|
94
93
|
for (let index = 0; index < args.length; index += 2) {
|
|
95
94
|
const name = args[index];
|
|
96
|
-
if (!['--
|
|
95
|
+
if (!['--origin', '--business', '--timeout'].includes(name) || !args[index + 1] || args[index + 1].startsWith('--') || Object.hasOwn(options, name.slice(2))) return invalid();
|
|
97
96
|
options[name.slice(2)] = args[index + 1];
|
|
98
97
|
}
|
|
99
|
-
if (options.code !== undefined && !/^[A-Za-z0-9]{4}-?[A-Za-z0-9]{4}$/.test(options.code)) return invalid();
|
|
100
|
-
if (options.code !== undefined && (options.business !== undefined || options.timeout !== undefined)) return invalid();
|
|
101
98
|
if (options.timeout !== undefined) {
|
|
102
99
|
if (!/^\d{1,3}$/.test(options.timeout) || Number(options.timeout) > 900) return invalid();
|
|
103
100
|
options.timeout = Number(options.timeout);
|
|
@@ -106,7 +103,7 @@ export async function businessCommand(argv) {
|
|
|
106
103
|
if (options.business !== undefined) identifier(options.business);
|
|
107
104
|
if (options.origin !== undefined && options.business !== undefined) originUrl(options.origin);
|
|
108
105
|
} catch { return invalid(); }
|
|
109
|
-
if (options.origin !== undefined && options.
|
|
106
|
+
if (options.origin !== undefined && options.business === undefined) originUrl(options.origin);
|
|
110
107
|
await connect(options);
|
|
111
108
|
} else if (verb === 'done' && args.length === 3) await done(...args);
|
|
112
109
|
else if (verb === 'answer' && [3, 4].includes(args.length)) await answer(...args);
|
package/cli/business/connect.mjs
CHANGED
|
@@ -17,113 +17,15 @@ const approvalWindow = 600_000;
|
|
|
17
17
|
export const capabilities = ['discover.local'];
|
|
18
18
|
|
|
19
19
|
const clock = time => new Date(time).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/** Pair (or resume a saved pairing) and wait in the foreground until the owner
|
|
23
|
-
* approves or refuses in the browser, or the code expires. Exit 0 means the
|
|
24
|
-
* computer is active: its credential is stored and the server has seen it.
|
|
25
|
-
*/
|
|
20
|
+
/** Pair (or resume a saved device pairing) and wait for the owner to approve. */
|
|
26
21
|
export async function connect(options = {}) {
|
|
27
22
|
if (options.business !== undefined) return connectDevice(options);
|
|
28
23
|
const pending = await loadPending();
|
|
29
|
-
|
|
30
|
-
// not discard a device pairing that is still within its collection window.
|
|
31
|
-
if (pending?.flow === 'device' && options.code !== undefined && Date.parse(pending.keep_until) > Date.now()) throw Error('Business is already waiting for a device pairing. Resume that command, or run business disconnect before using another code.');
|
|
32
|
-
if (pending?.flow === 'device' && options.code === undefined) return connectDevice(options);
|
|
33
|
-
return connectLegacy(options);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Removal of the browser-created --code flow is planned for a later release,
|
|
37
|
-
// once the production rollback target uses device pairing.
|
|
38
|
-
async function connectLegacy({ code, origin } = {}) {
|
|
24
|
+
if (pending?.flow === 'device') return connectDevice(options);
|
|
39
25
|
const stored = await loadState();
|
|
40
|
-
|
|
41
|
-
origin = originUrl(origin ??
|
|
42
|
-
|
|
43
|
-
if (stored.revoked) throw Error(`This computer was ${revokedText(stored)}\nThen connect with a new code from ${stored.origin}/business.`);
|
|
44
|
-
if (stored.origin !== origin) throw Error(`This computer is already connected to Business at ${stored.origin}. Run ${rerCommand()} business disconnect before connecting it elsewhere.`);
|
|
45
|
-
const credential = await createCredentialStore().get(deviceCredentialHandle(stored));
|
|
46
|
-
if (!credential) throw Error(`This computer's Business credential is missing from OS credential storage. Run ${rerCommand()} business disconnect, then connect again with a new code from ${origin}/business.`);
|
|
47
|
-
await connected(new Api(origin, credential), stored, { reconnecting: true });
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (pending && Date.parse(pending.expires_at) <= Date.now()) { await clearPending(); pending = null; }
|
|
51
|
-
if (pending && (pending.origin !== origin || code && pending.code !== code)) throw Error(`Business is already waiting for approval of another code${pending.origin === origin ? '' : ` at ${pending.origin}`}. Run ${rerCommand()} business connect to resume it, or ${rerCommand()} business disconnect to drop it before using another code.`);
|
|
52
|
-
if (!pending && !code) throw Error(`Set up your business: open ${origin}/business and take the prompt from the Business Connect page. It names the Business to join with --business.`);
|
|
53
|
-
// Refuse before redeeming the one-use code or collecting an approval when this
|
|
54
|
-
// session cannot keep the pairing or store the device credential.
|
|
55
|
-
await checkStateWritable();
|
|
56
|
-
const store = createCredentialStore();
|
|
57
|
-
try { await store.check(); }
|
|
58
|
-
catch (error) {
|
|
59
|
-
const outside = error.sandboxRefused ? ` Approve this command outside the sandbox: ${rerCommand()} business connect${code ? ` --code ${code}` : ''} --origin ${origin}. Every other business command runs inside the sandbox.` : '';
|
|
60
|
-
throw Error(`${error.message}${outside} ${pending ? 'The saved pairing was kept; run connect again once this is fixed.' : nothingSent}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Ctrl-C or a stopped tool call never strands a pairing: the redeemed pairing
|
|
64
|
-
// is saved before waiting, and a collected credential is stored before exit.
|
|
65
|
-
const stop = new AbortController();
|
|
66
|
-
const stopWith = signal => () => stop.abort(signal);
|
|
67
|
-
const onInterrupt = stopWith('SIGINT'), onTerminate = stopWith('SIGTERM');
|
|
68
|
-
process.on('SIGINT', onInterrupt); process.on('SIGTERM', onTerminate);
|
|
69
|
-
try {
|
|
70
|
-
const api = new Api(origin);
|
|
71
|
-
if (!pending) {
|
|
72
|
-
// The computer's plain name and the folder connect runs in help the owner
|
|
73
|
-
// recognise this computer and prefill the scan folder; each is left out when empty.
|
|
74
|
-
const name = deviceName(), folder = workingFolder();
|
|
75
|
-
const response = await api.post('/api/business/executors/pair', {
|
|
76
|
-
code, ...(name ? { device_name: name } : {}), ...(folder ? { working_folder: folder } : {}),
|
|
77
|
-
os: process.platform === 'darwin' ? 'macos' : 'linux', agent_kind: agentKind(), capabilities,
|
|
78
|
-
}).catch(error => { throw error.status === 401 ? Error(`Business did not accept code ${code}: it has expired or was already used${error.reason ? ` (the server said: ${error.reason})` : ''}. Create a new code in ${origin}/business.`) : error; });
|
|
79
|
-
const expires = Math.min(Date.now() + 600_000, Date.parse(response?.expires_at));
|
|
80
|
-
if (response?.status !== 'pending_approval' || !/^\d{6}$/.test(response.confirmation_number) || typeof response.pairing_token !== 'string' || !response.pairing_token || !Number.isFinite(expires) || expires <= Date.now()) throw Error('Business server returned an invalid pairing response.');
|
|
81
|
-
pending = { origin, code, pairing_token: response.pairing_token, confirmation_number: response.confirmation_number, code_expires_at: new Date(expires).toISOString(), expires_at: new Date(expires + approvalWindow).toISOString() };
|
|
82
|
-
await savePending(pending);
|
|
83
|
-
}
|
|
84
|
-
const resume = `${rerCommand()} business connect --origin ${origin}`;
|
|
85
|
-
const until = pending.code_expires_at ? ` until ${clock(pending.code_expires_at)}, when the code expires` : ' until the code expires';
|
|
86
|
-
process.stdout.write(`Confirmation number: ${pending.confirmation_number}\nCompare this number in the browser that created the code, then approve there.\nWaiting for approval in ${origin}/business${until}. Keep this command running.\nIf it stops, run ${resume} to resume this pairing.\n`);
|
|
87
|
-
while (Date.now() < Date.parse(pending.expires_at)) {
|
|
88
|
-
if (stop.signal.aborted) break;
|
|
89
|
-
let result;
|
|
90
|
-
try { result = await api.post('/api/business/executors/pair', { pairing_token: pending.pairing_token }, { signal: stop.signal }); }
|
|
91
|
-
catch (error) {
|
|
92
|
-
if (stop.signal.aborted) break;
|
|
93
|
-
if ([401, 403, 410].includes(error.status)) {
|
|
94
|
-
await clearPending();
|
|
95
|
-
throw Error(`Business pairing ended without approval: the owner refused it, or the code expired${error.reason ? ` (the server said: ${error.reason})` : ''}. Create a new code in ${origin}/business and run connect with it.`);
|
|
96
|
-
}
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
if (result?.status === 'paired') {
|
|
100
|
-
if (typeof result.device_credential !== 'string') throw Error('Business server returned an invalid device credential.');
|
|
101
|
-
const folder = workingFolder();
|
|
102
|
-
const state = { version: 1, credentialVersion: 2, origin, businessId: identifier(result.business_id), executorId: identifier(result.executor_id), vendorHandles: [], awakeConsent: false, ...(folder ? { workingFolder: folder } : {}) };
|
|
103
|
-
const handle = credentialHandle(origin, state.businessId);
|
|
104
|
-
// No authenticated request (including activation) before both durable writes.
|
|
105
|
-
await store.set(handle, result.device_credential);
|
|
106
|
-
try { await saveState(state); } catch (error) { await store.delete(handle); throw error; }
|
|
107
|
-
await clearPending();
|
|
108
|
-
process.stdout.write('Approved. Device credential stored in OS credential storage.\n');
|
|
109
|
-
await connected(new Api(origin, result.device_credential), state);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (['denied', 'refused', 'expired'].includes(result?.status)) {
|
|
113
|
-
await clearPending();
|
|
114
|
-
throw Error(`Business pairing was ${result.status === 'expired' ? 'not approved before the code expired' : 'refused in the browser'}. Create a new code in ${origin}/business and run connect with it.`);
|
|
115
|
-
}
|
|
116
|
-
if (result?.status !== 'authorization_pending') throw Error('Business server returned an invalid pairing status.');
|
|
117
|
-
try { await pause(Math.max(1, Math.min(5, Number(result.interval) || 5)) * 1000, stop.signal); } catch { break; }
|
|
118
|
-
}
|
|
119
|
-
if (stop.signal.aborted) {
|
|
120
|
-
throw new Stopped(`Stopped waiting for approval. The pairing is saved: run ${resume} to resume it${pending.code_expires_at ? ` before ${clock(pending.code_expires_at)}` : ''}.`, stop.signal.reason === 'SIGTERM' ? 143 : 130);
|
|
121
|
-
}
|
|
122
|
-
await clearPending();
|
|
123
|
-
throw Error(`Business pairing code expired before it was approved. Create a new code in ${origin}/business and run connect with it.`);
|
|
124
|
-
} finally {
|
|
125
|
-
process.off('SIGINT', onInterrupt); process.off('SIGTERM', onTerminate);
|
|
126
|
-
}
|
|
26
|
+
if (stored) return connectDevice({ ...options, business: stored.businessId });
|
|
27
|
+
const origin = originUrl(options.origin ?? pending?.origin);
|
|
28
|
+
throw Error(`Set up your business: open ${origin}/business and take the prompt from the Business Connect page. It names the ID for ${rerCommand()} business connect --business ID.`);
|
|
127
29
|
}
|
|
128
30
|
|
|
129
31
|
const shortCode = /^[2-9A-HJKMNP-Z]{4}-[2-9A-HJKMNP-Z]{4}$/;
|
|
@@ -153,7 +55,7 @@ async function connectDevice({ business, origin, timeout } = {}) {
|
|
|
153
55
|
process.on('SIGINT', interrupt); process.on('SIGTERM', terminate);
|
|
154
56
|
let pending, resume, timer, unlock;
|
|
155
57
|
try {
|
|
156
|
-
await checkStateWritable(
|
|
58
|
+
await checkStateWritable();
|
|
157
59
|
unlock = await lockPairing(stop.signal);
|
|
158
60
|
const stored = await loadState();
|
|
159
61
|
pending = await loadPending();
|
|
@@ -13,10 +13,10 @@ import { supportsTaskKind } from './supervisor.mjs';
|
|
|
13
13
|
|
|
14
14
|
export async function paired() {
|
|
15
15
|
const state = await loadState();
|
|
16
|
-
if (!state?.origin || !state.businessId || !state.executorId) throw Error(`This computer is not paired. Run ${rerCommand()} business connect --
|
|
16
|
+
if (!state?.origin || !state.businessId || !state.executorId) throw Error(`This computer is not paired. Run ${rerCommand()} business connect --business ID; the Business Connect page names the ID.`);
|
|
17
17
|
if (state.revoked) throw Error(`This computer was ${revokedText(state)}`);
|
|
18
18
|
const credential = await createCredentialStore().get(deviceCredentialHandle(state));
|
|
19
|
-
if (!credential) throw Error(`This computer's Business credential is missing from OS credential storage. Run ${rerCommand()} business disconnect, then connect
|
|
19
|
+
if (!credential) throw Error(`This computer's Business credential is missing from OS credential storage. Run ${rerCommand()} business disconnect, then run ${rerCommand()} business connect --business ID; the Connect page at ${state.origin}/business names the ID.`);
|
|
20
20
|
return { state, credential };
|
|
21
21
|
}
|
|
22
22
|
|
package/cli/business/state.mjs
CHANGED
|
@@ -57,12 +57,12 @@ async function saveJson(name, value) {
|
|
|
57
57
|
} finally { await unlink(temporary).catch(error => { if (error.code !== 'ENOENT') throw error; }); }
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/** Before a
|
|
60
|
+
/** Before a pairing starts or an approval is collected, prove the state
|
|
61
61
|
* folder takes the same private create, write and replace the pairing needs.
|
|
62
62
|
* Folders made only for the check are removed again, so a refused connect
|
|
63
63
|
* leaves nothing behind.
|
|
64
64
|
*/
|
|
65
|
-
export async function checkStateWritable(
|
|
65
|
+
export async function checkStateWritable() {
|
|
66
66
|
const directory = stateDirectory(), probe = join(directory, `${randomUUID()}.tmp`), created = [];
|
|
67
67
|
for (let path = directory; path !== dirname(path); path = dirname(path)) {
|
|
68
68
|
try { await lstat(path); break; } catch (error) { if (error.code !== 'ENOENT') break; created.push(path); }
|
|
@@ -78,7 +78,7 @@ export async function checkStateWritable({ codeExists = true } = {}) {
|
|
|
78
78
|
const fix = chosenStateDirectory()
|
|
79
79
|
? 'Allow writes to that folder in this session, or set RER_BUSINESS_STATE_DIR to a folder this session can write'
|
|
80
80
|
: 'Allow writes to that folder, or set RER_BUSINESS_STATE_DIR to a folder this session can write (in Codex, one inside the working folder, such as RER_BUSINESS_STATE_DIR="$PWD/.rer-business")';
|
|
81
|
-
throw Error(`Business cannot save its state in ${directory}: ${localCause(error) ?? error.message}.
|
|
81
|
+
throw Error(`Business cannot save its state in ${directory}: ${localCause(error) ?? error.message}. Nothing was sent. ${fix}, then run connect again.`);
|
|
82
82
|
} finally {
|
|
83
83
|
for (const path of created) await rmdir(path).catch(() => {});
|
|
84
84
|
}
|
package/cli/contract.mjs
CHANGED
|
@@ -12,8 +12,8 @@ const definitions = {
|
|
|
12
12
|
verify: [[], 'Run the complete internal verification target.'],
|
|
13
13
|
reset: [['--yes'], 'Confirmed removal of the declared local inventory only.'],
|
|
14
14
|
deploy: [['--owner-name', '--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret', '--rotate-secret', '--reopen-installation-key'], 'Owner-account deployment and health; dry run builds and validates the local deployment plan, printing target names, bindings and migration names. No Cloudflare credentials or requests are needed and nothing changes remotely. Valid fixture senders on .test, .example, .invalid, .localhost and example.com, example.net or example.org (including subdomains) are accepted only in a dry run; real deploys refuse placeholder senders. Dry run never prompts for or requires a missing owner name, saves no name and bypasses custom deploy hooks and their owner-email preflight. Target secrets, permissions and remote readiness are checked only by a real deploy. Builds and deploy hooks run with the checkout\'s local settings files moved aside, and a build output holding one (.dev.vars, .env) is refused. Declared secrets come from the environment or --env-file (an owned 0600 KEY=VALUE file); a new Worker gets the local setup owner and fresh generated secrets when they are not given. rer keeps the secrets it generates in .rer/deploy/ENVIRONMENT.secrets.env (0600) and reuses them on every redeploy; it refuses to generate a replacement for one a live Worker holds, and --rotate-secret NAME[,NAME] replaces them on purpose. After a healthy deploy rer claims the setup owner on the hosted app with the saved setup owner name and the one-time setup token, then removes the token. For a real deploy, the managed adapter checks its hosted owner email before rer resolves the owner name, so its placeholder-email refusal comes first. If the installer declares an owner-name field and no name is saved, deploy asks once and saves it; --non-interactive requires --owner-name NAME before any upload. --set-secret NAME[,NAME] (each value from the environment or --env-file; repeat the flag or join names with commas) and --unset-secret NAME[,NAME] change those secrets of the deployed Worker without a build, all of them in one new Worker version or none, and record that version; a missing value refuses before any change. --reopen-installation-key KID temporarily binds a retired installation key from private custody, reseals restored dependency keys under the current key, verifies them and removes the previous binding. --remove --yes deletes what this environment\'s deploy record says rer created (Worker, D1, R2, KV, queues), reads back that each is gone, and touches nothing else. --site deploys the run site instead: an assets-only Worker on its custom domain with www redirected; with --dry-run it builds the site and prints the plan with no provider request. --demo deploys the hosted demo instead (deploy-demo.json): a front Worker on demo.<domain> giving each visitor their own signed-in, throwaway native Worker isolate of this seed with real public reads/checks and simulated external writes; --dry-run writes it to .rer/demo-host with no provider request; --demo --remove --yes deletes that demo (its Worker, demo.<domain> Custom Domain, each only while the record its deploy left proves it the demo\'s), reads back that each is gone, and is a no-op once it is.'],
|
|
15
|
-
export: [['--target', '--output', '--origin', '--session-file'], 'For owner move-in, run rer dev and open /app/import: export people there, then upload through the destination door. Developer-only installation backup: complete supported archive of the local copy on this computer, with integrity and exclusions, written to --output. The hosted install cannot be exported yet: --origin or --target remote refuses (exit 2) before any effect and names the command that saves the hosted database.'],
|
|
16
|
-
import: [['--target', '--input', '--journal', '--origin', '--session-file', '--yes', '--legacy-v1', '--acknowledge-unverified-metadata', '--acknowledge-unverified-schema-objects', '--output'], 'For owner move-in, run rer dev and open /app/import: upload, review and apply through the door. Developer-only installation recovery: confirmed atomic restore into an empty destination; --journal LATER_ARCHIVE also fences rows that installation erased since. Backup-only local v1 recovery requires --legacy-v1 --acknowledge-unverified-metadata and a new --output v2 archive; --journal requires normal v2 import. A v2 archive without schemaObjects requires --acknowledge-unverified-schema-objects, an empty destination and compatible destination migration history; its receipt records schemaUnverified. A fresh export from current rer is preferred; current archives need no acknowledgment.'],
|
|
15
|
+
export: [['--target', '--output', '--origin', '--session-file'], 'For owner move-in, run rer dev and open the app\'s signed-in Move in page (/app/import in the Base reference; the project\'s own docs name its path): export people there, then upload through the destination door. Developer-only installation backup: complete supported archive of the local copy on this computer, with integrity and exclusions, written to --output. The hosted install cannot be exported yet: --origin or --target remote refuses (exit 2) before any effect and names the command that saves the hosted database.'],
|
|
16
|
+
import: [['--target', '--input', '--journal', '--origin', '--session-file', '--yes', '--legacy-v1', '--acknowledge-unverified-metadata', '--acknowledge-unverified-schema-objects', '--output'], 'For owner move-in, run rer dev and open the app\'s signed-in Move in page (/app/import in the Base reference; the project\'s own docs name its path): upload, review and apply through the door. Developer-only installation recovery: confirmed atomic restore into an empty destination; --journal LATER_ARCHIVE also fences rows that installation erased since. Backup-only local v1 recovery requires --legacy-v1 --acknowledge-unverified-metadata and a new --output v2 archive; --journal requires normal v2 import. A v2 archive without schemaObjects requires --acknowledge-unverified-schema-objects, an empty destination and compatible destination migration history; its receipt records schemaUnverified. A fresh export from current rer is preferred; current archives need no acknowledgment.'],
|
|
17
17
|
doctor: [[], 'Read-only installed tool, configuration and state diagnostics.', 'never'],
|
|
18
18
|
describe: [[], 'Read-only description of actual command capabilities.'],
|
|
19
19
|
check: [['--profile'], 'Read-only structural command contract and operations validation.'],
|
package/cli/hosted-output.mjs
CHANGED
|
@@ -130,7 +130,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
130
130
|
durableObjects: Object.fromEntries((config.durable_objects?.bindings ?? []).filter(item => !item.script_name).map(item => [item.name, { className: item.class_name, useSQLite: true }])),
|
|
131
131
|
...(config.assets ? { assets: { directory: client, binding: config.assets.binding ?? 'ASSETS', routerConfig: { has_user_worker: true, invoke_user_worker_ahead_of_assets: RUN_WORKER_FIRST } } } : {}),
|
|
132
132
|
}] };
|
|
133
|
-
let preparation, producers, held = false;
|
|
133
|
+
let preparation, producers, held = false, closing = false;
|
|
134
134
|
const waiting = new Set();
|
|
135
135
|
const release = () => { held = false; for (const resume of waiting) resume(); waiting.clear(); };
|
|
136
136
|
// Install the gate before owner hooks retain any D1 handles; replacing
|
|
@@ -140,10 +140,10 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
140
140
|
const wrapper = join(build, '__rer_preparation.mjs');
|
|
141
141
|
const native = './' + config.main;
|
|
142
142
|
app.modules = [{ type: 'ESModule', path: wrapper, contents:
|
|
143
|
-
`import app from ${JSON.stringify(native)};export * from ${JSON.stringify(native)};export default {...app,async queue(batch,env,ctx){await env.RER_PREPARATION_QUEUE_GATE.fetch('https://queue.invalid');return app.queue(batch,env,ctx)}}` }, ...modules];
|
|
143
|
+
`import app from ${JSON.stringify(native)};export * from ${JSON.stringify(native)};export default {...app,async queue(batch,env,ctx){const gate=await env.RER_PREPARATION_QUEUE_GATE.fetch('https://queue.invalid');if(!gate.ok)throw new Error('Preparation host closed');return app.queue(batch,env,ctx)}}` }, ...modules];
|
|
144
144
|
app.serviceBindings = { ...app.serviceBindings, RER_PREPARATION_QUEUE_GATE: async () => {
|
|
145
145
|
if (held) await new Promise(resume => waiting.add(resume));
|
|
146
|
-
return new Response(null, { status: 204 });
|
|
146
|
+
return new Response(null, { status: closing ? 410 : 204 });
|
|
147
147
|
} };
|
|
148
148
|
producers = preparationProducers(options, config);
|
|
149
149
|
}
|
|
@@ -227,7 +227,7 @@ export async function serveHosted(root, { declaration: declarationPath = 'deploy
|
|
|
227
227
|
if (!origins.includes(origin)) throw new RerError('agent_door_origin', 'Agent conformance request must use a declared hosted installation origin.', 1);
|
|
228
228
|
return mf.dispatchFetch(`http://127.0.0.1/${path}`, { headers: { ...headers, upgrade: 'websocket', 'x-rer-original-url': `${origin}/${path}` } });
|
|
229
229
|
},
|
|
230
|
-
close: () => { release(); return mf.dispose(); },
|
|
230
|
+
close: () => { closing = true; release(); return mf.dispose(); },
|
|
231
231
|
fetch: (path, { headers, origin = HOSTED_ORIGIN, ...init } = {}) => {
|
|
232
232
|
if (!origins.includes(origin)) throw new RerError('agent_door_origin', 'Agent conformance request must use a declared hosted installation origin.', 1);
|
|
233
233
|
return loopbackFetch(loopback, { ...init, redirect: 'manual', headers: { ...headers, 'x-rer-original-url': `${origin}/${path}` } });
|
package/cli/inspect.mjs
CHANGED
|
@@ -253,9 +253,14 @@ export async function doctor(project, store, signal) {
|
|
|
253
253
|
const firstParty = project.profile === 'first-party';
|
|
254
254
|
const workflowInputs = firstParty ? diagnostic.missingEnvironment.filter(name => buildWorkflowInput.test(name)) : [];
|
|
255
255
|
const deploymentInputs = firstParty ? diagnostic.missingEnvironment.filter(name => !buildWorkflowInput.test(name) && !inputs.includes(name) && !(typeof values[name] === 'string' && values[name].trim())) : [];
|
|
256
|
+
// A required loop that waits only on inputs a deployment supplies (a hosted mail provider's key, say) is ready for
|
|
257
|
+
// local use: the local app suppresses that delivery. Its inputs are named with the other deploy inputs.
|
|
258
|
+
const deployOnlyLoop = loop => firstParty && loop.status === 'missing-inputs' && (loop.missingEnvironment ?? []).every(name => !inputs.includes(name));
|
|
259
|
+
const loopDeploymentInputs = (diagnostic.loops ?? []).filter(deployOnlyLoop).flatMap(loop => loop.missingEnvironment ?? []);
|
|
256
260
|
if (firstParty) {
|
|
257
261
|
diagnostic.missingEnvironment = diagnostic.missingEnvironment.filter(name => inputs.includes(name));
|
|
258
|
-
diagnostic.ok = diagnostic.commands.every(command => command.available) && !diagnostic.missingEnvironment.length && diagnostic.configuration === 'valid' && (diagnostic.loops ?? []).every(loop => ['ready', 'optional-disabled'].includes(loop.status));
|
|
262
|
+
diagnostic.ok = diagnostic.commands.every(command => command.available) && !diagnostic.missingEnvironment.length && diagnostic.configuration === 'valid' && (diagnostic.loops ?? []).every(loop => ['ready', 'optional-disabled'].includes(loop.status) || deployOnlyLoop(loop));
|
|
263
|
+
diagnostic.loops = (diagnostic.loops ?? []).map(loop => deployOnlyLoop(loop) ? { ...loop, deploymentOnly: true } : loop);
|
|
259
264
|
}
|
|
260
265
|
const setupNeeded = firstParty ? !(await localState(project)).prepared : false;
|
|
261
266
|
const warnings = project.profile === 'first-party' ? await cacheWarnings(project.root) : [];
|
|
@@ -263,7 +268,7 @@ export async function doctor(project, store, signal) {
|
|
|
263
268
|
node: { actual: process.versions.node, expected: expectedNode },
|
|
264
269
|
pnpm: project.profile === 'first-party' ? { actual: pnpm, expected: expectedPnpm ?? null, ...(pnpmIssues.length ? { issue: [...new Set(pnpmIssues)].join('\n') } : {}) } : undefined,
|
|
265
270
|
ai: { issues: aiIssues },
|
|
266
|
-
missingInputs: [...new Set([...diagnostic.missingEnvironment, ...inputs])], deploymentInputs, workflowInputs, setupNeeded: setupNeeded || (!firstParty && diagnostic.missingEnvironment.length > 0),
|
|
271
|
+
missingInputs: [...new Set([...diagnostic.missingEnvironment, ...inputs])], deploymentInputs: [...new Set([...deploymentInputs, ...loopDeploymentInputs])], workflowInputs, setupNeeded: setupNeeded || (!firstParty && diagnostic.missingEnvironment.length > 0),
|
|
267
272
|
sources: project.descriptor.environmentSources ?? {}, state: { path: project.adapter?.state, safe: stateValid, ...(stateIssue ? { issue: stateIssue } : {}) }, scope: 'local-inputs-only' };
|
|
268
273
|
}
|
|
269
274
|
|
|
@@ -282,7 +287,7 @@ export function doctorSummary(result) {
|
|
|
282
287
|
const unavailable = result.operations.commands.filter(command => !command.available);
|
|
283
288
|
if (unavailable.length) lines.push('Unavailable command inputs:', ...unavailable.map(command => ` ${command.name}: restore its declared input files.`));
|
|
284
289
|
if (result.operations.configuration === 'invalid') lines.push('Local configuration is invalid. Check the declared configuration module; private validator details are suppressed.');
|
|
285
|
-
for (const loop of result.operations.loops ?? []) if (!['ready', 'optional-disabled'].includes(loop.status)) lines.push(`Loop ${loop.id}: ${loop.status}${loop.missingEnvironment?.length ? `; missing ${loop.missingEnvironment.join(', ')}` : ''}.`);
|
|
290
|
+
for (const loop of result.operations.loops ?? []) if (!['ready', 'optional-disabled'].includes(loop.status) && !loop.deploymentOnly) lines.push(`Loop ${loop.id}: ${loop.status}${loop.missingEnvironment?.length ? `; missing ${loop.missingEnvironment.join(', ')}` : ''}.`);
|
|
286
291
|
if (!result.state.safe) lines.push(`Local state: ${result.state.issue}`);
|
|
287
292
|
if (result.browser?.issue) lines.push(`Browser dependencies: ${result.browser.issue}`);
|
|
288
293
|
else if (result.browser?.note) lines.push(result.browser.note);
|
package/cli/parse.mjs
CHANGED
|
@@ -111,7 +111,7 @@ export function parse(argv, cwd = process.cwd(), { independent = false, deferTai
|
|
|
111
111
|
export function help(verb) {
|
|
112
112
|
if (!verb) return `Usage: rer VERB [FLAGS]\nCommands: ${Object.keys({...verbs, ...authoringVerbs}).join(', ')}, signin, size, release, listing, rehearse\nRun rer VERB --help for flags.\n${appSignInHelp}\n`;
|
|
113
113
|
const known = verbs[verb] ?? authoringVerbs[verb] ?? (verb === 'signin' ? signinVerb : verb === 'size' ? sizeVerb : undefined);
|
|
114
|
-
const door = ['export', 'import'].includes(verb) ? 'To move records, start the app and open its signed-in owner import door:\n\n rer dev\n\nOpen /app/import, then export or upload and review supported records there.\n\nTo back up or restore this installation:\n' : '';
|
|
114
|
+
const door = ['export', 'import'].includes(verb) ? 'To move records, start the app and open its signed-in owner import door:\n\n rer dev\n\nOpen its Move in page (/app/import in the Base reference; the project\'s own docs name its path), then export or upload and review supported records there.\n\nTo back up or restore this installation:\n' : '';
|
|
115
115
|
return `${door}Usage: rer ${verb}${verb === 'refresh-base' ? ' --ref FULL_COMMIT' : ''} [FLAGS]\nFlags: ${(known?.flags ?? commonFlags).join(', ')}\n${known?.effects ?? 'Execute the declared OPERATIONS v2 argv with explicit arguments after --.'}\n`;
|
|
116
116
|
}
|
|
117
117
|
|
package/cli/size/clock.mjs
CHANGED
|
@@ -4,18 +4,22 @@ import { RerError } from '../errors.mjs';
|
|
|
4
4
|
* deadline passes while that work is still running, naming the size, phase, table and flow it stopped in. */
|
|
5
5
|
export function runClock(timeoutSeconds) {
|
|
6
6
|
const state = { size: undefined, phase: 'starting', table: undefined, flow: undefined };
|
|
7
|
-
let timer;
|
|
7
|
+
let timer, failure;
|
|
8
8
|
const expired = new Promise((_, reject) => {
|
|
9
9
|
timer = setTimeout(() => {
|
|
10
10
|
const where = [state.size && `the ${state.size} size`, state.phase, state.table && `table ${state.table}`, state.flow && `flow ${state.flow}`].filter(Boolean).join(', ');
|
|
11
|
-
|
|
11
|
+
failure = new RerError('size_timeout', `rer size stopped after ${timeoutSeconds} s (budget.timeoutSeconds) in ${where}. Raise budget.timeoutSeconds, or declare fewer rows.`, 1);
|
|
12
|
+
reject(failure);
|
|
12
13
|
}, timeoutSeconds * 1000);
|
|
13
14
|
timer.unref?.();
|
|
14
15
|
});
|
|
15
16
|
expired.catch(() => {});
|
|
16
17
|
return {
|
|
17
18
|
enter(size, phase, table, flow) { Object.assign(state, { size, phase, table, flow }); },
|
|
18
|
-
within
|
|
19
|
+
within(work) {
|
|
20
|
+
if (failure) throw failure;
|
|
21
|
+
return Promise.race([work(), expired]);
|
|
22
|
+
},
|
|
19
23
|
stop: () => clearTimeout(timer),
|
|
20
24
|
};
|
|
21
25
|
}
|
package/cli/size/command.mjs
CHANGED
|
@@ -50,7 +50,8 @@ export async function measureSize(options, out) {
|
|
|
50
50
|
const { ok: built, flows, queueConsumersMeasured, ...sizes } = await buildFixtures(options, out, loaded);
|
|
51
51
|
ok = ok && built;
|
|
52
52
|
details.size = sizes;
|
|
53
|
-
|
|
53
|
+
details.queueConsumersMeasured = queueConsumersMeasured;
|
|
54
|
+
if (flows) details.flows = flows;
|
|
54
55
|
} else if (!options.statements && !options.migrations) out.human(undeclaredLine);
|
|
55
56
|
return { ok, details };
|
|
56
57
|
}
|
package/cli/size/flows.mjs
CHANGED
|
@@ -57,25 +57,36 @@ async function once(flow, { hosted, personas, now }) {
|
|
|
57
57
|
* unsettled, executions }. `executions` lists each statement the last run executed, in order.
|
|
58
58
|
*/
|
|
59
59
|
export async function runFlow(flow, install) {
|
|
60
|
-
|
|
60
|
+
const result = { name: flow.name, kind: kindOf(flow), persona: flow.persona ?? null, label: flowLabel(flow), runs: 0,
|
|
61
|
+
status: null, ms: 0, executions: [], rowsRead: 0, rowsWritten: 0, statements: 0, incomplete: true };
|
|
62
|
+
install.results?.push(result);
|
|
61
63
|
for (let run = 0; run < flow.repeat; run++) {
|
|
62
64
|
const window = install.meter.open();
|
|
65
|
+
Object.assign(result, { runs: run + 1, startedAt: performance.now(), executions: window.statements, incomplete: true });
|
|
63
66
|
let outcome;
|
|
64
67
|
try { outcome = await once(flow, install); }
|
|
65
|
-
catch (error) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
catch (error) {
|
|
69
|
+
Object.assign(result, { error: String(error?.message ?? error), ms: performance.now() - result.startedAt });
|
|
70
|
+
await window.close({ quietMs: 0, maxMs: 0 });
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
// An aborted request can leave unannounced D1 work running. No quiet interval proves cancellation.
|
|
74
|
+
const { statements, unsettled } = await window.close(outcome.error ? { quietMs: 0, maxMs: 0 } : undefined);
|
|
75
|
+
Object.assign(result, outcome, { unsettled, executions: statements, rowsRead: sum(statements, 'rows_read'),
|
|
76
|
+
rowsWritten: sum(statements, 'rows_written'), statements: statements.length, incomplete: Boolean(outcome.error || unsettled) });
|
|
77
|
+
if (result.incomplete) {
|
|
78
|
+
install.meter.stop();
|
|
79
|
+
throw new RerError('size_flow_incomplete', `Flow ${flow.name} did not finish safely (${outcome.error ?? 'work remained unsettled'}). This measurement session stopped; later flows and sizes were not measured because outstanding work could contaminate them.`, 1);
|
|
80
|
+
}
|
|
68
81
|
}
|
|
69
|
-
return
|
|
82
|
+
return result;
|
|
70
83
|
}
|
|
71
84
|
|
|
72
|
-
/** Every declared flow, in order, on one install
|
|
73
|
-
*
|
|
85
|
+
/** Every declared flow, in order, on one install. A transport failure or unsettled window stops the session,
|
|
86
|
+
* including repeats; only a complete response with settled work permits another measurement window. */
|
|
74
87
|
export async function runFlows(flows, install, each = (flow, work) => work()) {
|
|
75
|
-
const results = [];
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
results.push(result);
|
|
79
|
-
}
|
|
88
|
+
const results = install.results ?? [];
|
|
89
|
+
install = { ...install, results };
|
|
90
|
+
for (const flow of flows) await each(flow, () => runFlow(flow, install));
|
|
80
91
|
return results;
|
|
81
92
|
}
|
package/cli/size/grow.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { sizes } from './fixture.mjs';
|
|
|
8
8
|
import { prepareRun, buildInstall } from './install.mjs';
|
|
9
9
|
import { runClock } from './clock.mjs';
|
|
10
10
|
import { measureInstall } from './measure.mjs';
|
|
11
|
-
import { judgeFlows, statementsFile, verdictLines } from './verdict.mjs';
|
|
11
|
+
import { flowSummary, judgeFlows, statementsFile, verdictLines } from './verdict.mjs';
|
|
12
12
|
import { schemasFromBuild } from './schema.mjs';
|
|
13
13
|
|
|
14
14
|
const seconds = ms => `${(ms / 1000).toFixed(ms < 10_000 ? 2 : 1)} s`;
|
|
@@ -43,7 +43,7 @@ const phaseText = phases => Object.entries(phases).map(([phase, ms]) => `${phase
|
|
|
43
43
|
*/
|
|
44
44
|
export async function buildFixtures(options, out, loaded) {
|
|
45
45
|
const { declaration, project } = loaded ?? await declared(options), run = await prepareRun(options.cwd, declaration, { project }), clock = runClock(declaration.budget.timeoutSeconds);
|
|
46
|
-
const result = { ok: true }, measured = {};
|
|
46
|
+
const result = { ok: true, queueConsumersMeasured: null }, measured = {}, completed = {};
|
|
47
47
|
if (!options.json) out.human('Size check: queues are held while the flows run; queue consumer work is not measured.');
|
|
48
48
|
try {
|
|
49
49
|
for (const size of sizes) {
|
|
@@ -51,6 +51,8 @@ export async function buildFixtures(options, out, loaded) {
|
|
|
51
51
|
try {
|
|
52
52
|
const built = await buildInstall(run, size, clock, measureInstall(run));
|
|
53
53
|
measured[size] = built.measured;
|
|
54
|
+
completed[size] = true;
|
|
55
|
+
result.queueConsumersMeasured = false;
|
|
54
56
|
const phasesMs = Object.fromEntries(Object.entries(built.phases).map(([phase, ms]) => [phase, Math.round(ms)]));
|
|
55
57
|
result[size] = { tables: built.tables.map(table => ({ ...table, ms: Math.round(table.ms) })), totalRows: built.totalRows, phasesMs, statements: built.statements };
|
|
56
58
|
if (options.json) continue;
|
|
@@ -61,22 +63,37 @@ export async function buildFixtures(options, out, loaded) {
|
|
|
61
63
|
} catch (error) {
|
|
62
64
|
if (!(error instanceof RerError)) throw error;
|
|
63
65
|
result.ok = false;
|
|
64
|
-
|
|
66
|
+
measured[size] = error.measurement?.flows ?? [];
|
|
67
|
+
if (error.measurement?.queuesHeld) result.queueConsumersMeasured = false;
|
|
68
|
+
result[size] = { ...(error.installation ? { tables: error.installation.tables, totalRows: error.installation.totalRows } : {}),
|
|
69
|
+
error: error.message, code: error.code };
|
|
65
70
|
if (!options.json) out.human(` FAIL ${error.message}`);
|
|
66
71
|
break;
|
|
67
72
|
}
|
|
68
73
|
}
|
|
69
74
|
} finally { clock.stop(); }
|
|
70
|
-
if (!result.ok)
|
|
71
|
-
|
|
72
|
-
result
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
if (!result.ok) for (const size of sizes) {
|
|
76
|
+
const attempted = measured[size] ?? [];
|
|
77
|
+
if (!result[size]) continue;
|
|
78
|
+
result[size].measurements = attempted.map(run => ({ name: run.name, runs: run.runs, incomplete: run.incomplete, ...flowSummary(run) }));
|
|
79
|
+
result[size].unmeasuredFlows = declaration.flows.filter(flow => !attempted.some(run => run.name === flow.name)).map(flow => flow.name);
|
|
80
|
+
}
|
|
81
|
+
if (result.ok) {
|
|
82
|
+
const verdict = judgeFlows(declaration, measured.small, measured.large, await schemasFromBuild(options.cwd, { wrangler: declaration.build.wrangler }));
|
|
83
|
+
result.ok = verdict.ok;
|
|
84
|
+
result.flows = verdict.flows;
|
|
85
|
+
result.queueConsumersMeasured = false;
|
|
86
|
+
if (!options.json) verdictLines(verdict, declaration).forEach(line => out.human(line));
|
|
87
|
+
}
|
|
76
88
|
if (options.writeStatements) {
|
|
77
89
|
const directory = resolve(process.cwd(), options.writeStatements);
|
|
78
90
|
await mkdir(directory, { recursive: true });
|
|
79
|
-
for (const size of sizes)
|
|
91
|
+
for (const size of sizes) {
|
|
92
|
+
const evidence = statementsFile(size, measured[size] ?? [], { complete: completed[size] === true,
|
|
93
|
+
queueConsumersMeasured: result.queueConsumersMeasured, unmeasuredFlows: result[size]?.unmeasuredFlows ?? declaration.flows.map(flow => flow.name),
|
|
94
|
+
error: result[size]?.error ?? (completed[size] ? undefined : 'This size was not measured because the session stopped.') });
|
|
95
|
+
await writeFile(join(directory, `${size}.json`), JSON.stringify(evidence, null, 1) + '\n');
|
|
96
|
+
}
|
|
80
97
|
if (!options.json) out.human(` Wrote the statements each size ran to ${join(directory, 'small.json')} and ${join(directory, 'large.json')}.`);
|
|
81
98
|
}
|
|
82
99
|
return result;
|
package/cli/size/install.mjs
CHANGED
|
@@ -93,9 +93,10 @@ export async function buildInstall(run, size, clock, measure) {
|
|
|
93
93
|
const timed = async (phase, table, work, flow) => {
|
|
94
94
|
clock.enter(size, phase, table, flow);
|
|
95
95
|
const started = performance.now();
|
|
96
|
-
try { return await clock.within(work
|
|
96
|
+
try { return await clock.within(work); } finally { phases[phase] += performance.now() - started; }
|
|
97
97
|
};
|
|
98
|
-
let keys, serving, hosted, owner, measured;
|
|
98
|
+
let keys, serving, hosted, owner, measured, built;
|
|
99
|
+
const measurement = { flows: [], queuesHeld: false };
|
|
99
100
|
const meter = measure ? createMeter() : undefined;
|
|
100
101
|
try {
|
|
101
102
|
if (run.owner) keys = await ownerKeys(run.root, run.owner.native, { email: run.owner.email, sub: run.owner.sub });
|
|
@@ -103,8 +104,11 @@ export async function buildInstall(run, size, clock, measure) {
|
|
|
103
104
|
fixturePreparation: true, fixtureDiagnostics: true, outboundService: refuseNetwork, meter,
|
|
104
105
|
bindings: keys ? ownerBindings(keys, { claim: run.owner.claim, native: run.owner.native, email: run.owner.email }) : {} });
|
|
105
106
|
hosted = await timed('serve', undefined, () => serving);
|
|
107
|
+
const preparation = await timed('serve', undefined, () => hosted.preparation());
|
|
108
|
+
preparation.queues.hold();
|
|
109
|
+
measurement.queuesHeld = true;
|
|
106
110
|
if (keys) owner = await timed('owner', undefined, () => signOwnerIn(run, hosted, keys));
|
|
107
|
-
const database = await
|
|
111
|
+
const database = await preparation.database(run.binding);
|
|
108
112
|
const before = new Map();
|
|
109
113
|
await timed('readback', undefined, async () => { for (const { table } of fixture.tables) before.set(table, await count(database, table)); });
|
|
110
114
|
const ms = new Map(fixture.tables.map(({ table }) => [table, 0]));
|
|
@@ -126,8 +130,15 @@ export async function buildInstall(run, size, clock, measure) {
|
|
|
126
130
|
// A virtual table's shadow tables or a table SQLite cannot count are not rows the check made.
|
|
127
131
|
for (const name of names) totalRows += await count(database, name).catch(() => 0);
|
|
128
132
|
});
|
|
129
|
-
|
|
130
|
-
|
|
133
|
+
built = { size, tables, totalRows, phases, statements: fixture.statements.length };
|
|
134
|
+
if (measure) measured = await measure({ hosted, owner, meter, results: measurement.flows, timed: (phase, flow, work) => timed(phase, undefined, work, flow) });
|
|
135
|
+
return { ...built, measured };
|
|
136
|
+
} catch (error) {
|
|
137
|
+
// Freeze the partial evidence before disposal. Neither an aborted client nor the run deadline cancels D1.
|
|
138
|
+
meter?.stop();
|
|
139
|
+
for (const flow of measurement.flows) if (flow.incomplete) flow.ms = performance.now() - flow.startedAt;
|
|
140
|
+
Object.assign(error, { measurement: { ...measurement, flows: structuredClone(measurement.flows) }, installation: built });
|
|
141
|
+
throw error;
|
|
131
142
|
} finally {
|
|
132
143
|
clock.enter(size, 'closing the install');
|
|
133
144
|
// A timeout can leave the install still starting: close it as soon as it exists.
|
package/cli/size/measure.mjs
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { RerError } from '../errors.mjs';
|
|
1
2
|
import { signPersonasIn } from './personas.mjs';
|
|
2
3
|
import { runFlows } from './flows.mjs';
|
|
3
4
|
|
|
4
5
|
/** What runs on a built install, while it is still open: the declared personas sign in, then every flow runs through
|
|
5
6
|
* the meter in declared order. The result is `buildInstall`'s `measured`: the runFlows results of this size. */
|
|
6
|
-
export const measureInstall = run => async ({ hosted, owner, meter, timed }) => {
|
|
7
|
-
const personas = await timed('personas', undefined, () =>
|
|
8
|
-
|
|
7
|
+
export const measureInstall = run => async ({ hosted, owner, meter, results, timed }) => {
|
|
8
|
+
const personas = await timed('personas', undefined, async () => {
|
|
9
|
+
const signed = await signPersonasIn(hosted, run.declaration.personas, { ownerCookie: owner?.cookie });
|
|
10
|
+
// Bootstrap/persona waitUntil work belongs to setup, never the first declared flow.
|
|
11
|
+
const window = meter.open();
|
|
12
|
+
if ((await window.close()).unsettled) throw new RerError('size_setup_incomplete', 'Owner or persona work did not settle; no flows were measured.', 1);
|
|
13
|
+
return signed;
|
|
14
|
+
});
|
|
15
|
+
return runFlows(run.declaration.flows, { hosted, personas, meter, results, now: run.now }, (flow, work) => timed('flows', flow.name, work));
|
|
9
16
|
};
|
package/cli/size/meter.mjs
CHANGED
|
@@ -133,9 +133,10 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
|
|
133
133
|
* Work outside a window (the owner's sign-in, other personas) is not recorded.
|
|
134
134
|
*/
|
|
135
135
|
export function createMeter() {
|
|
136
|
-
let current = null, pending = 0, lastEvent = 0;
|
|
136
|
+
let current = null, pending = 0, lastEvent = 0, stopped = false;
|
|
137
137
|
const service = async request => {
|
|
138
138
|
const event = await request.json();
|
|
139
|
+
if (stopped) return new Response(null, { status: 204 });
|
|
139
140
|
lastEvent = performance.now();
|
|
140
141
|
if (event.kind === 'wait') pending = Math.max(0, pending + event.delta);
|
|
141
142
|
else if (current) current.statements.push({ binding: event.binding, sql: event.sql, params: event.params ?? [], rows_read: event.rows_read ?? 0, rows_written: event.rows_written ?? 0, ...(event.error ? { error: event.error } : {}), ...(event.exec ? { exec: true } : {}), ...(event.batch ? { batch: true } : {}) });
|
|
@@ -143,16 +144,20 @@ export function createMeter() {
|
|
|
143
144
|
};
|
|
144
145
|
return {
|
|
145
146
|
service,
|
|
147
|
+
stop() { stopped = true; current = null; },
|
|
146
148
|
/** Starts a window. The returned `close` ends it once the caller has read the response, its waitUntil work has
|
|
147
149
|
* settled and no statement has been recorded for `quietMs`; after `maxMs` it ends regardless and says so. */
|
|
148
150
|
open() {
|
|
151
|
+
if (stopped) throw new Error('This measurement session has stopped.');
|
|
149
152
|
if (current) throw new Error('A meter window is already open.');
|
|
150
153
|
const window = current = { statements: [] };
|
|
151
154
|
return {
|
|
155
|
+
statements: window.statements,
|
|
152
156
|
close: async ({ quietMs = 250, maxMs = 30_000 } = {}) => {
|
|
153
157
|
const readAt = performance.now();
|
|
154
158
|
let unsettled = false;
|
|
155
159
|
while (true) {
|
|
160
|
+
if (stopped) { unsettled = true; break; }
|
|
156
161
|
const now = performance.now(), quiet = now - Math.max(lastEvent, readAt) >= quietMs;
|
|
157
162
|
if (pending === 0 && quiet) break;
|
|
158
163
|
if (now - readAt >= maxMs) { unsettled = true; break; }
|
package/cli/size/verdict.mjs
CHANGED
|
@@ -41,7 +41,7 @@ function measureDistinct(schemas, flowResults) {
|
|
|
41
41
|
return measured;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
export const flowSummary = run => ({ rowsRead: run.executions.reduce((total, item) => total + item.rows_read, 0), rowsWritten: run.executions.reduce((total, item) => total + item.rows_written, 0), statements: run.executions.length, status: run.status, ms: Math.round(run.ms), ...(run.error ? { error: run.error } : {}), ...(run.detail ? { detail: run.detail } : {}), ...(run.unsettled ? { unsettled: true } : {}), top: topStatements(run.executions) });
|
|
45
45
|
|
|
46
46
|
// Only the measures at the failing line: a statement at depth 105 says so and not "0 FROM items".
|
|
47
47
|
function sizeText({ fromItems, depth }) {
|
|
@@ -91,7 +91,7 @@ export function judgeFlows(declaration, small, large, schemas) {
|
|
|
91
91
|
if (!record || record.ok) continue;
|
|
92
92
|
failures.push({ rule: 'statement-size', message: `statement size: ${record.error ?? sizeText(record)}`, sql, ...(record.error ? {} : { fromItems: record.fromItems, depth: record.depth }) });
|
|
93
93
|
}
|
|
94
|
-
return { name: flow.name, persona: flow.persona ?? null, kind: at.small.kind, label: at.small.label, callsInRow: flow.callsInRow, ceiling: flow.ceiling, ok: failures.length === 0, failures, growthAllowed: flow.growth?.why ?? null, small:
|
|
94
|
+
return { name: flow.name, persona: flow.persona ?? null, kind: at.small.kind, label: at.small.label, callsInRow: flow.callsInRow, ceiling: flow.ceiling, ok: failures.length === 0, failures, growthAllowed: flow.growth?.why ?? null, small: flowSummary(at.small), large: flowSummary(at.large) };
|
|
95
95
|
});
|
|
96
96
|
const checked = [...measured.values()].reduce((all, records) => all + records.size, 0);
|
|
97
97
|
return { ok: verdicts.every(verdict => verdict.ok), flows: verdicts, checked };
|
|
@@ -121,11 +121,12 @@ export function verdictLines(verdict, declaration) {
|
|
|
121
121
|
|
|
122
122
|
/** One size's statements in the fleet runner's format: { statements: [{ name: "<flow> #<i>", sql, params }] }, every
|
|
123
123
|
* statement each flow's last run executed, in order, with its parameters as bound. */
|
|
124
|
-
export function statementsFile(size, results) {
|
|
124
|
+
export function statementsFile(size, results, { complete = true, error, queueConsumersMeasured = null, unmeasuredFlows = [] } = {}) {
|
|
125
125
|
const statements = [];
|
|
126
126
|
for (const result of results) {
|
|
127
127
|
let index = 0;
|
|
128
128
|
for (const { sql, params, exec } of result.executions) if (!exec) statements.push({ name: `${result.name} #${++index}`, sql, params });
|
|
129
129
|
}
|
|
130
|
-
return { about: `rer size:
|
|
130
|
+
return { about: `rer size: statements observed at the ${size} size, in order, with their parameters as bound.`, statements, complete, queueConsumersMeasured,
|
|
131
|
+
...(!complete ? { error, unmeasuredFlows, flows: results.map(run => ({ name: run.name, runs: run.runs, incomplete: run.incomplete, ...flowSummary(run) })) } : {}) };
|
|
131
132
|
}
|
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.118
|
|
4
|
+
|
|
5
|
+
### Local diagnostics and Move in guidance
|
|
6
|
+
|
|
7
|
+
- After a clean `rer dev`, `rer doctor` treats required loops waiting only on deployment inputs as ready for local use and lists those inputs as optional locally and needed for deployment. It still checks local configuration, commands and required local inputs.
|
|
8
|
+
- Import and export help directs owners to the app's signed-in Move in page; `/app/import` is the Base reference path, and each project's own documentation names its path.
|
|
9
|
+
|
|
10
|
+
### Business device pairing only
|
|
11
|
+
|
|
12
|
+
- Removed `rer business connect --code` and its browser-created pairing flow, help and recovery guidance. Pair with `rer business connect --business ID`; the Business Connect page names the ID. Saved device pairings can still resume.
|
|
13
|
+
|
|
14
|
+
### Explicit outbound mail off
|
|
15
|
+
|
|
16
|
+
- Foundations accept an explicit `MAIL_PROVIDER=none` through declared environment-to-Worker bindings. Provider and sender bindings, and the mail key at the binding layer, are optional; mail off needs no sender or key and binds neither `MAIL_FROM` nor `MAIL_API_KEY`. An absent provider does not select off, and enabled providers still require their real sender and credentials. Conflicting mail-off credentials are refused.
|
|
17
|
+
- `rer deploy --dry-run` validates this choice, says outbound email is off and names `rer signin` for owner entry. Email sign-in links and invitations remain unavailable. A declared optional operations mail loop reports `optional-disabled`; a required delivery loop still fails when mail is off.
|
|
18
|
+
|
|
19
|
+
### Recorded app target for owner sign-in
|
|
20
|
+
|
|
21
|
+
- `rer signin` selects the app Worker from the held ownership record, preserving its recorded account, project, environment and origin instead of recomputing the default Worker name. The selected identity must match the caller and live deployment. Wrong account, project or environment, missing or replaced Worker or receipt, and substitution of a public-page Worker refuse without issuing an owner grant.
|
|
22
|
+
|
|
23
|
+
These changes become available to seeds after adopting the released package or refreshed source. This preparation establishes no seed adoption, provider delivery, deployment or production result. The actual diff adds no migrations and changes neither modules/import-kit nor modules/portability.
|
|
24
|
+
|
|
25
|
+
## 0.2.117
|
|
26
|
+
|
|
27
|
+
### Size queue isolation and timeout attribution
|
|
28
|
+
|
|
29
|
+
- `rer size` holds disposable queue consumers through the hosted preparation API before owner setup, fixture generation and persona sign-in. Producers can enqueue and declared scheduled handlers still run and are measured; queue consumer work is excluded, and closing the install discards held deliveries.
|
|
30
|
+
- Owner and persona work must settle before the first flow. A request failure, timeout or unsettled measurement stops the session before another repeat, flow or size, so outstanding work is not attributed to following routes. Client abort does not prove D1 cancellation; incomplete evidence produces no growth verdict.
|
|
31
|
+
- Failed measurements retain partial flow summaries and both `--write-statements` exports with completeness, queue-isolation and unmeasured-flow diagnostics. An unattempted size has no observed statements; that empty export is not evidence of zero cost.
|
|
32
|
+
|
|
33
|
+
This releases CLI support only. HH and Lamp own their query fixes and adoption; no seed query fix, adoption, deployed behavior or production result is established here. The actual diff adds no migrations and touches neither modules/import-kit nor modules/portability.
|
|
34
|
+
|
|
3
35
|
## 0.2.116
|
|
4
36
|
|
|
5
37
|
### Verification-only agent surfaces
|
package/global/README.md
CHANGED
|
@@ -531,12 +531,6 @@ different origin or Business: disconnect first or use a separate
|
|
|
531
531
|
`RER_BUSINESS_STATE_DIR`. It reports this computer's plain name, working folder,
|
|
532
532
|
agent and OS (including WSL) for the owner to recognise.
|
|
533
533
|
|
|
534
|
-
For older Business pages, `rer business connect --code ABCD-1234 --origin URL`
|
|
535
|
-
keeps the browser-created code and six-digit confirmation-number flow unchanged
|
|
536
|
-
in 0.2.98. It cannot be combined with `--business` or `--timeout`. Removal is
|
|
537
|
-
planned for a later release after the production rollback target uses device pairing.
|
|
538
|
-
The install.sh form still passes either connect command through unchanged.
|
|
539
|
-
|
|
540
534
|
The owner chooses three things on the computer's row in the browser: "Add rules
|
|
541
535
|
so Claude Code never reads your secret files" (Claude Code user Read deny
|
|
542
536
|
rules), "Keep this computer awake while it works" (recorded; nothing keeps the computer awake now that rer runs no exports) and "Install the background service" (a launchd or systemd user
|
|
@@ -9,7 +9,7 @@ import { assert, hexId } from './validation.mjs';
|
|
|
9
9
|
import { regularBytes } from './artifact.mjs';
|
|
10
10
|
import { packageBuild } from './prepare.mjs';
|
|
11
11
|
import { cloudflare } from './provider.mjs';
|
|
12
|
-
import { ownerTarget, ownerWorkerName, ownerPlan, ownerDeploy, ownerHealth, settleOwnerState, sameDeployment, localOnlyBinding, withStateLock, readOwnerState, writeOwnerState, workerSettings, withScopeHints } from './owner.mjs';
|
|
12
|
+
import { ownerTarget, recordedOwnerTarget, ownerWorkerName, ownerPlan, ownerDeploy, ownerHealth, settleOwnerState, sameDeployment, localOnlyBinding, withStateLock, readOwnerState, writeOwnerState, workerSettings, withScopeHints } from './owner.mjs';
|
|
13
13
|
import { activeWorker, secretBindings } from './worker.mjs';
|
|
14
14
|
import { ownerSecret } from './owner-secret.mjs';
|
|
15
15
|
import { ownerRemove } from './owner-remove.mjs';
|
|
@@ -97,11 +97,14 @@ export async function main(argv = process.argv.slice(2), env = process.env, {fet
|
|
|
97
97
|
};
|
|
98
98
|
// Transport must see the same outer signal when deciding whether to retry.
|
|
99
99
|
const api = deploymentDiagnostics(cloudflare({accountId:env.CLOUDFLARE_ACCOUNT_ID,token:env.CLOUDFLARE_API_TOKEN,fetch:guardedRequest,requestSignal,budgetMigrations:command === 'deploy',...(command === 'remove' ? {maxRequests:Infinity,removal:true} : {})}),{onCreated});
|
|
100
|
+
const statePath = values.state ? resolve(root,values.state) : join(root,'.rer','deploy',`${values.environment}.json`);
|
|
101
|
+
// Signin uses only the selected app record; never discover a sibling page Worker.
|
|
100
102
|
// Removal needs the recorded account/name identity, not a workers.dev route.
|
|
101
|
-
const target = command === '
|
|
103
|
+
const target = command === 'signin'
|
|
104
|
+
? await recordedOwnerTarget(api,{project:declaration.project,environment:values.environment,statePath})
|
|
105
|
+
: command === 'remove'
|
|
102
106
|
? {accountId:api.accountId,project:declaration.project,environment:values.environment,worker:ownerWorkerName(declaration.project,values.environment)}
|
|
103
107
|
: await ownerTarget(api,{project:declaration.project,environment:values.environment});
|
|
104
|
-
const statePath = values.state ? resolve(root,values.state) : join(root,'.rer','deploy',`${target.environment}.json`);
|
|
105
108
|
if (command === 'remove') return {ok:true,...await ownerRemove({api,target,statePath}).catch(error => { throw api.annotateFailure(error,'remove'); })};
|
|
106
109
|
if (command === 'rekey') return ownerRekey({api,target,statePath,declaration,env,notice});
|
|
107
110
|
if (command === 'secret') {
|
|
@@ -100,15 +100,33 @@ async function listedAfterCreate(api, kind, item, {windowMs = LIST_WINDOW_MS, cl
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
/** Reads the account's workers.dev subdomain; no other provider request. */
|
|
103
|
-
|
|
103
|
+
async function workerOrigin(provider, worker) {
|
|
104
104
|
const api = withScopeHints(provider);
|
|
105
|
-
const worker = ownerWorkerName(project, environment);
|
|
106
105
|
let result;
|
|
107
106
|
try { result = await api.request('/workers/subdomain'); }
|
|
108
107
|
catch (error) { if (error.status === 404) throw new Error('workers-subdomain-missing'); throw error; }
|
|
109
108
|
assert(typeof result?.subdomain === 'string' && result.subdomain, 'workers-subdomain-missing');
|
|
110
109
|
assert(/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(result.subdomain),'invalid-account-subdomain');
|
|
111
|
-
return
|
|
110
|
+
return `https://${worker}.${result.subdomain}.workers.dev`;
|
|
111
|
+
}
|
|
112
|
+
export async function ownerTarget(api, {project, environment}) {
|
|
113
|
+
const worker = ownerWorkerName(project, environment);
|
|
114
|
+
return {accountId:api.accountId,project,environment,worker,origin:await workerOrigin(api,worker)};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Signin follows the selected app record, including native uploaders' custom names.
|
|
118
|
+
* The caller still supplies the account, project and environment to validate it.
|
|
119
|
+
* Later state reads and the live provider check must corroborate this identity. */
|
|
120
|
+
export async function recordedOwnerTarget(api, {project, environment, statePath}) {
|
|
121
|
+
ownerWorkerName(project, environment); // Validate the caller's project and environment as usual.
|
|
122
|
+
let recorded;
|
|
123
|
+
try { recorded = JSON.parse(await regularBytes(statePath, 4 * 1024 * 1024)); }
|
|
124
|
+
catch (error) { throw new Error(error.code === 'ENOENT' ? 'missing-owner-receipt' : 'invalid-owner-state'); }
|
|
125
|
+
assert(resourceName(recorded?.worker), 'invalid-owner-state');
|
|
126
|
+
const target = {accountId:api.accountId,project,environment,worker:recorded.worker};
|
|
127
|
+
const state = await readOwnerState(statePath,target);
|
|
128
|
+
assert(state.receipt, 'missing-owner-receipt');
|
|
129
|
+
return {...target,origin:state.receipt.origin ?? await workerOrigin(api,target.worker)};
|
|
112
130
|
}
|
|
113
131
|
|
|
114
132
|
function entries(declaration, key) {
|
package/operations/README.md
CHANGED
|
@@ -194,7 +194,7 @@ exclusive. For example:
|
|
|
194
194
|
```
|
|
195
195
|
|
|
196
196
|
Every environment name must match `[A-Z][A-Z0-9_]*`. A nonempty `providers` map
|
|
197
|
-
supports `sendgrid`, `resend`, `cloudflare` and `
|
|
197
|
+
supports `sendgrid`, `resend`, `cloudflare`, `development` and explicit `none`. Every provider
|
|
198
198
|
entry declares `requiredEnvironment` (an empty array is allowed). Hosted entries
|
|
199
199
|
also require `apiKeyEnvironment`; Cloudflare additionally requires
|
|
200
200
|
`accountIdEnvironment`, checked as 32 hex characters. Those account declarations
|
|
@@ -204,6 +204,19 @@ configuration module remains responsible for its native sender and credential
|
|
|
204
204
|
validation. A required mail loop still fails when foundation-only configuration
|
|
205
205
|
is valid but mail has not been configured.
|
|
206
206
|
|
|
207
|
+
An optional mail loop may declare `"none": { "requiredEnvironment": [] }` in
|
|
208
|
+
its `binding.providers`. Only an explicit selector value of `none` turns that
|
|
209
|
+
loop off; its report says `optional-disabled` with `mailOff: true`, and the CLI
|
|
210
|
+
explains that no delivery is available and a declared provider must be configured
|
|
211
|
+
to enable it. A required loop selected to `none` still fails (`disabled-required`).
|
|
212
|
+
The off entry cannot declare credentials, sender requirements or development
|
|
213
|
+
settings, and cannot be a `whenUnset` default. The application's configuration
|
|
214
|
+
validator must honor the same deliberate off state. This inspection does not
|
|
215
|
+
send mail or verify a deployment; rer's deploy preflight independently checks
|
|
216
|
+
the mail-free sign-in declaration and rejects conflicting sending credentials.
|
|
217
|
+
|
|
218
|
+
— Codex, 2026-11-15T03:31:15Z
|
|
219
|
+
|
|
207
220
|
Optional `whenUnset` declares a hosted provider and its inputs with the same
|
|
208
221
|
shape. It applies only if the selector is absent (`undefined`), never for blank,
|
|
209
222
|
unknown or non-string selectors. It cannot select development. Without
|
|
@@ -126,6 +126,8 @@ async function checkSummary(result, descriptor, root) {
|
|
|
126
126
|
if (declaredInputs.size) lines.push(`Check the values you set for these declared input names: ${[...declaredInputs].sort().join(', ')}.`);
|
|
127
127
|
}
|
|
128
128
|
const blockedLoops = (result.loops ?? []).filter(loop => !['ready', 'optional-disabled'].includes(loop.status));
|
|
129
|
+
const mailOff = (result.loops ?? []).filter(loop => loop.mailOff);
|
|
130
|
+
if (mailOff.length) lines.push(`Outbound mail is off for ${mailOff.map(loop => loop.id).join(', ')}. No delivery is available; select and configure a declared mail provider to enable it.`);
|
|
129
131
|
if (blockedLoops.length) lines.push(`Loops needing attention: ${blockedLoops.map(loop => `${loop.id} (${loop.status})`).join(', ')}.`);
|
|
130
132
|
if (result.ok) lines.push('Remote deployment, provider access, and product acceptance remain unchecked.');
|
|
131
133
|
else {
|
|
@@ -18,6 +18,11 @@ function fields(value, allowed) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function mailInputs(provider, declaration, fallback = false) {
|
|
21
|
+
if (provider === 'none' && !fallback) {
|
|
22
|
+
fields(declaration, ['requiredEnvironment']);
|
|
23
|
+
if (!Array.isArray(declaration.requiredEnvironment) || declaration.requiredEnvironment.length) throw new Error('Mail off cannot require delivery inputs.');
|
|
24
|
+
return { provider, names: [] };
|
|
25
|
+
}
|
|
21
26
|
fields(declaration, ['apiKeyEnvironment', 'requiredEnvironment', 'accountIdEnvironment', 'development', ...(fallback ? ['provider'] : [])]);
|
|
22
27
|
if (![...hostedProviders, ...(fallback ? [] : ['development'])].includes(provider)
|
|
23
28
|
|| !Array.isArray(declaration.requiredEnvironment) || declaration.requiredEnvironment.some(name => !environmentName(name))) throw new Error('Invalid mail binding declaration.');
|
|
@@ -145,7 +150,9 @@ export function inspectRequiredLoops(descriptor, env) {
|
|
|
145
150
|
const { providerEnvironment, providers, whenUnset } = loop.binding;
|
|
146
151
|
const provider = env[providerEnvironment];
|
|
147
152
|
const selected = provider === undefined ? whenUnset : typeof provider === 'string' && has(providers, provider) ? providers[provider] : undefined;
|
|
148
|
-
result = selected
|
|
153
|
+
result = selected?.provider === 'none'
|
|
154
|
+
? { status: loop.required ? 'disabled-required' : 'optional-disabled', missingEnvironment: [], mailOff: true }
|
|
155
|
+
: selected ? inspectMailInputs(selected, env) : { status: 'invalid-mail-provider', missingEnvironment: [providerEnvironment] };
|
|
149
156
|
} else {
|
|
150
157
|
result = inspectMailInputs(loop.selected, env);
|
|
151
158
|
// Preserve the fixed-provider contract's truthy-selector mismatch behavior.
|