@runeditrun/rer 0.2.19 → 0.2.21

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.
Files changed (104) hide show
  1. package/README.md +7 -7
  2. package/cli/README.md +22 -21
  3. package/cli/adapter.mjs +5 -0
  4. package/cli/container.mjs +7 -2
  5. package/cli/contract.mjs +3 -4
  6. package/cli/delivery-declarations.mjs +36 -0
  7. package/cli/demo-host.mjs +6 -5
  8. package/cli/demo-removal-provider.mjs +24 -0
  9. package/cli/demo.mjs +16 -5
  10. package/cli/deploy-command.mjs +11 -5
  11. package/cli/deploy-hook.mjs +10 -14
  12. package/cli/deploy.mjs +4 -1
  13. package/cli/detached-server.mjs +2 -2
  14. package/cli/dev-identity.mjs +1 -1
  15. package/cli/export.mjs +1 -1
  16. package/cli/inspect.mjs +13 -13
  17. package/cli/lifecycle.mjs +16 -49
  18. package/cli/listen.mjs +31 -0
  19. package/cli/local.mjs +12 -18
  20. package/cli/main.mjs +5 -0
  21. package/cli/managed-server.mjs +26 -44
  22. package/cli/output.mjs +1 -1
  23. package/cli/parse.mjs +3 -3
  24. package/cli/port.mjs +20 -20
  25. package/cli/production-auth.mjs +38 -0
  26. package/cli/server-proxy.mjs +2 -6
  27. package/cli/server-registry.mjs +7 -2
  28. package/cli/setup-input.mjs +3 -0
  29. package/global/CHANGELOG.md +15 -0
  30. package/global/README.md +7 -7
  31. package/global/cli/install.mjs +4 -28
  32. package/global/cli/path-link.mjs +25 -21
  33. package/global/launch/dev.mjs +1 -1
  34. package/global/launch/facts.mjs +11 -14
  35. package/global/launch/failure.mjs +20 -0
  36. package/global/launch/render.mjs +2 -6
  37. package/global/launch/worker.mjs +3 -3
  38. package/global/main.mjs +1 -1
  39. package/modules/container/build.mjs +5 -3
  40. package/modules/container/demo-egress.mjs +35 -0
  41. package/modules/container/worker-engine.mjs +3 -3
  42. package/modules/d1-transport/index.d.mts +9 -0
  43. package/modules/d1-transport/index.mjs +124 -0
  44. package/modules/delivery-producer/bindings.mjs +140 -0
  45. package/modules/delivery-producer/declarations.mjs +49 -0
  46. package/modules/demo/README.md +34 -0
  47. package/modules/demo/effects.mjs +73 -0
  48. package/modules/demo/index.d.mts +15 -0
  49. package/modules/demo/index.mjs +63 -0
  50. package/modules/demo/label.d.mts +2 -0
  51. package/modules/demo/label.mjs +24 -0
  52. package/modules/demo/responses.mjs +26 -0
  53. package/modules/demo/sockets.mjs +13 -0
  54. package/modules/demo/vite.d.mts +2 -0
  55. package/modules/demo/vite.mjs +19 -0
  56. package/modules/demo-host/README.md +14 -1
  57. package/modules/demo-host/container.mjs +17 -11
  58. package/modules/demo-host/diagnostics.mjs +1 -0
  59. package/modules/demo-host/pages.mjs +1 -1
  60. package/modules/demo-host/placement.mjs +23 -0
  61. package/modules/demo-host/plan.mjs +1 -1
  62. package/modules/demo-host/startup.mjs +1 -1
  63. package/modules/demo-host/worker.mjs +2 -2
  64. package/modules/deploy-kit/README.md +12 -0
  65. package/modules/deploy-kit/health-request.mjs +7 -5
  66. package/modules/deploy-kit/owner.mjs +2 -2
  67. package/modules/deploy-kit/r2-objects.mjs +8 -5
  68. package/modules/job-queue/storage.mjs +4 -1
  69. package/modules/mail/README.md +19 -86
  70. package/modules/mail/src/core/validation.mjs +0 -1
  71. package/modules/mail/src/development/index.d.mts +1 -6
  72. package/modules/mail/src/development/index.mjs +3 -16
  73. package/modules/operator-auth/README.md +10 -9
  74. package/modules/operator-auth/csp.mjs +1 -2
  75. package/modules/operator-auth/dev/cli-session.mjs +32 -0
  76. package/modules/operator-auth/dev/index.mjs +18 -11
  77. package/modules/operator-auth/identity/email-link/index.mjs +3 -0
  78. package/modules/operator-auth/page.mjs +1 -1
  79. package/modules/operator-auth/signin/index.d.mts +1 -1
  80. package/modules/portability/README.md +6 -0
  81. package/modules/portability/catalogue.mjs +1 -1
  82. package/modules/portability/copies.mjs +17 -2
  83. package/modules/portability/index.mjs +2 -0
  84. package/modules/portability/storage.mjs +5 -1
  85. package/onboarding/README.md +8 -11
  86. package/onboarding/adapter-auth.mjs +6 -38
  87. package/onboarding/adapter-labels.mjs +1 -1
  88. package/onboarding/adapter.mjs +8 -11
  89. package/onboarding/app-fetch.mjs +1 -1
  90. package/onboarding/dependency-approval.mjs +5 -15
  91. package/onboarding/dev-identity.mjs +1 -1
  92. package/onboarding/operator-install.mjs +6 -7
  93. package/onboarding/operator-installer.mjs +5 -5
  94. package/onboarding/operator-prerequisites.mjs +4 -5
  95. package/onboarding/port-probe.mjs +38 -0
  96. package/onboarding/process-diagnostics.mjs +36 -20
  97. package/onboarding/server.mjs +1 -1
  98. package/onboarding/ui/app.js +1 -1
  99. package/operations/README.md +3 -0
  100. package/package.json +4 -2
  101. package/scripts/publish-check/public_hygiene.py +31 -10
  102. package/modules/mail/src/development/viewer-html.mjs +0 -42
  103. package/modules/mail/src/development/viewer.mjs +0 -72
  104. package/modules/operator-auth/dev/badge.mjs +0 -44
@@ -3,12 +3,13 @@ import { claimKeys, signClaim } from './claim.mjs';
3
3
  import { bounded, boundedFetch, category, report } from './diagnostics.mjs';
4
4
  import { endedPage, clearCookie } from './pages.mjs';
5
5
  import { finishStart } from './startup.mjs';
6
+ import { placeContainer } from './placement.mjs';
6
7
 
7
8
  // One visitor's demo: a Durable Object (newUniqueId) and its container, the
8
9
  // seed's image from `rer build --platform container` on the workerd engine.
9
- // The container starts with no internet and in demo mode, so withDemo and the
10
- // engine's egress worker refuse every send. The front signs the owner in
11
- // through the existing signed owner claim. The demo ends at its hour or after
10
+ // The container starts with public internet in demo mode. withDemo simulates
11
+ // external effects; the engine also refuses direct mail/SMS transports. The
12
+ // front signs the owner in through the existing signed owner claim. The demo ends at its hour or after
12
13
  // 15 idle minutes: the alarm destroys the container and deletes everything.
13
14
  // The platform stops a container about two minutes after its Durable Object's
14
15
  // last event, when the object is evicted, and the exit watcher goes with it.
@@ -70,19 +71,16 @@ export class DemoContainer extends DurableObject {
70
71
 
71
72
  /** Start the container, wait for /health, claim the owner; returns the claim's 303. */
72
73
  async start({ origin, originVar, ends, endsLocal, settings, correlation }) {
73
- this.correlation = correlation; this.started = Date.now(); this.stopped = false;
74
+ this.correlation = correlation; this.started = Date.now(); this.stopped = false; this.cancelled = false;
74
75
  const deadline = this.started + this.startTimeout;
75
76
  const id = this.ctx.id.toString(), keys = await claimKeys(), now = Date.now();
76
77
  await this.ctx.storage.put({ ends, seen: now, correlation, started: this.started, startDeadline: deadline });
77
78
  report(correlation, this.started, 'start');
78
79
  if (this.stopped) throw new Error('container-stopped');
79
- this.container.start({ enableInternet: false, env: { ...settings, RER_DEMO: '1', [originVar]: origin, RER_INGRESS_ORIGIN: origin,
80
+ await placeContainer(this, { enableInternet: true, env: { ...settings, RER_DEMO: '1', [originVar]: origin, RER_INGRESS_ORIGIN: origin,
80
81
  SESSION_SECRET: random(), SETUP_TOKEN: random(), OWNER_EMAIL: OWNER, RER_OWNER_CLAIM_ISSUER: origin, RER_OWNER_CLAIM_INSTALLATION_ID: id,
81
- RER_OWNER_CLAIM_PUBLIC_KEYS: JSON.stringify(keys.publicKeys), RER_DEMO_EXPIRES: endsLocal } });
82
- // A container that stops by itself ends the demo too.
83
- this.watch();
82
+ RER_OWNER_CLAIM_PUBLIC_KEYS: JSON.stringify(keys.publicKeys), RER_DEMO_EXPIRES: endsLocal } }, deadline);
84
83
  await this.ctx.storage.setAlarm(Date.now());
85
- await this.healthy(deadline);
86
84
  const token = await signClaim(keys, { origin, installationId: id, email: OWNER, now: Date.now() });
87
85
  const claimed = await boundedFetch(this.port(), 'http://container/auth/owner-claim', { method: 'POST', redirect: 'manual',
88
86
  headers: { origin, 'content-type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ token }) }, Math.max(1, Math.min(10_000, deadline - Date.now())));
@@ -112,6 +110,8 @@ export class DemoContainer extends DurableObject {
112
110
  }
113
111
 
114
112
  async exited(error) {
113
+ this.watching = false;
114
+ this.stopReason = error ? category(error) : 'container-stopped';
115
115
  this.stopped = true;
116
116
  this.record('exit', { outcome: error ? category(error) : 'exited', ...(Number.isInteger(error?.exitCode) ? { exitCode: error.exitCode } : {}) });
117
117
  if ((await this.ctx.storage.get('startup'))?.phase === 'starting') return;
@@ -140,7 +140,7 @@ export class DemoContainer extends DurableObject {
140
140
  async alarm() {
141
141
  const state = await this.ctx.storage.get(['ends', 'seen', 'startDeadline']), now = Date.now();
142
142
  if (await this.ctx.storage.get('stopping')) return this.end();
143
- if (!state.get('ends')) return;
143
+ if (!state.get('ends')) return this.ctx.storage.deleteAll();
144
144
  const due = Math.min(state.get('ends'), state.get('seen') + this.idle, state.get('startDeadline') ?? Infinity);
145
145
  if (now >= due || !this.container.running) {
146
146
  if ((await this.ctx.storage.get('startup'))?.phase === 'starting') { this.stopped = true; return; }
@@ -158,7 +158,8 @@ export class DemoContainer extends DurableObject {
158
158
  }
159
159
 
160
160
  async cleanup() {
161
- this.stopped = true; this.wake?.();
161
+ this.cancelled = true; this.stopped = true; this.wake?.();
162
+ const startup = await this.ctx.storage.get('startup');
162
163
  // Keep the alarm and capacity reservation if destruction fails; retry cleanup.
163
164
  await this.ctx.storage.put('stopping', true);
164
165
  await this.ctx.storage.setAlarm(Date.now() + this.cleanupRetry);
@@ -170,6 +171,11 @@ export class DemoContainer extends DurableObject {
170
171
  await bounded(this.env.CAPACITY.get(this.env.CAPACITY.idFromName('capacity')).release(this.ctx.id.toString()), 2000);
171
172
  await this.ctx.storage.deleteAlarm();
172
173
  await this.ctx.storage.deleteAll();
174
+ // Retain only the terminal answer briefly, so polling survives a fresh DO.
175
+ if (startup?.phase === 'failed') {
176
+ await this.ctx.storage.put({ startup, correlation: this.correlation, started: this.started });
177
+ await this.ctx.storage.setAlarm(Date.now() + 60_000);
178
+ }
173
179
  report(this.correlation, this.started, 'ended');
174
180
  }
175
181
  }
@@ -2,6 +2,7 @@
2
2
  // container response body, cookie, environment value or raw error is retained.
3
3
  export function category(error) {
4
4
  const message = String(error?.message ?? '');
5
+ if (message === 'placement-unavailable' || /there is no container instance that can be provided to this Durable Object, try again later/i.test(message)) return 'placement-unavailable';
5
6
  if (error?.name === 'TimeoutError' || error?.name === 'AbortError') return 'probe-timeout';
6
7
  if (/connection refused|not listening|port.*not.*ready/i.test(message)) return 'port-not-ready';
7
8
  if (/container.*not.*running|container.*stopped/i.test(message)) return 'container-stopped';
@@ -37,7 +37,7 @@ export function startPage(env, { status = 200, notice, pending = false, headers
37
37
  const name = escape(env.DEMO_NAME);
38
38
  return html(env, { page: 'start', title: `Try ${env.DEMO_NAME}`, status, headers, turnstile: true, refresh: pending, body: `<h1 id="title">Try ${name}</h1>
39
39
  <p class="intro">Your own copy of ${name}, signed in as its owner, with sample data.</p>
40
- <ul><li>Nothing is sent: mail stays in an outbox.</li><li>It ends after an hour, or 15 idle minutes.</li><li>Then it is deleted. Nobody else can see it.</li></ul>
40
+ <ul><li>Public checks run live. Messages and account changes are simulated.</li><li>It ends after an hour, or 15 idle minutes.</li><li>Then it is deleted. Nobody else can see it.</li></ul>
41
41
  <p class="notice" id="notice" role="alert"${notice ? '' : ' hidden'}>${notice ? escape(notice) : ''}</p><form id="start" method="post" action="/__demo/start" data-auto="${notice || pending ? '0' : '1'}"${pending ? ' data-resume="1" data-state="working"' : ''}><div class="cf-turnstile" data-sitekey="${escape(env.TURNSTILE_SITE_KEY)}" data-size="flexible" data-callback="rerDemoVerified" data-before-interactive-callback="rerDemoInteractive" data-after-interactive-callback="rerDemoChecking" data-expired-callback="rerDemoExpired" data-error-callback="rerDemoCheckFailed"></div>
42
42
  <button class="button" type="submit"${pending ? ' disabled' : ''}><span class="spinner" aria-hidden="true"></span><span class="label">${pending ? 'Starting your demo…' : 'Start the demo'}</span></button>
43
43
  <ol class="steps" aria-hidden="true"><li data-at="done">Checking you're human</li><li data-at="now">Starting a private copy</li><li data-at="next">Signing you in</li></ol>
@@ -0,0 +1,23 @@
1
+ // Cloudflare can exhaust its prepared instances before reaching max_instances.
2
+ // Keep this visitor's reservation while that pool grows. Only the provider's
3
+ // explicit no-instance response permits another placement attempt; boot, health
4
+ // and claim failures still terminate the start.
5
+ export async function placeContainer(demo, options, deadline) {
6
+ let attempt = 0;
7
+ while (Date.now() < deadline && !demo.cancelled) {
8
+ demo.stopped = false;
9
+ demo.stopReason = undefined;
10
+ demo.container.start(options);
11
+ demo.watch();
12
+ await demo.ctx.storage.setAlarm(deadline);
13
+ try {
14
+ await demo.healthy(deadline);
15
+ return;
16
+ } catch (error) {
17
+ if (demo.cancelled || demo.stopReason !== 'placement-unavailable') throw error;
18
+ demo.record('placement', { attempt: ++attempt, outcome: 'waiting' });
19
+ await new Promise(resolve => setTimeout(resolve, Math.min(1000, Math.max(0, deadline - Date.now()))));
20
+ }
21
+ }
22
+ throw new Error(demo.cancelled ? 'container-stopped' : 'placement-unavailable');
23
+ }
@@ -9,7 +9,7 @@ import { siteDeclaration } from '../deploy-kit/site.mjs';
9
9
  * running the seed's own image (`rer build --platform container`, workerd
10
10
  * engine), deployed by `wrangler deploy` with the image beside it. */
11
11
 
12
- export const DEMO_FILES = ['worker.mjs', 'container.mjs', 'startup.mjs', 'capacity.mjs', 'claim.mjs', 'pages.mjs', 'start-script.mjs', 'diagnostics.mjs', 'operator.mjs'];
12
+ export const DEMO_FILES = ['worker.mjs', 'container.mjs', 'startup.mjs', 'placement.mjs', 'capacity.mjs', 'claim.mjs', 'pages.mjs', 'start-script.mjs', 'diagnostics.mjs', 'operator.mjs'];
13
13
  const FRONT_SET = /^(?:RER_.*|SESSION_SECRET|SETUP_TOKEN|OWNER_EMAIL)$/;
14
14
  const SECRET = /SECRET|TOKEN|PASSWORD|_KEY$/;
15
15
  // Cloudflare Containers' predefined instance types, smallest first (developers.cloudflare.com/containers/platform-details/limits).
@@ -19,7 +19,7 @@ export async function finishStart(demo, options) {
19
19
  const diagnostic = await bounded(demo.diagnostic(), 3000);
20
20
  await bounded(demo.env.CAPACITY.get(demo.env.CAPACITY.idFromName('diagnostics')).record(correlation, { ...diagnostic, failure }), 3000);
21
21
  } catch (capture) { report(correlation, demo.started, 'diagnostic', { error: category(capture) }); }
22
- await demo.ctx.storage.put('startup', { phase: 'failed' });
22
+ await demo.ctx.storage.put('startup', { phase: 'failed', capacity: failure === 'placement-unavailable' });
23
23
  try { await demo.end(); } catch (cleanup) { report(correlation, demo.started, 'cleanup', { error: category(cleanup) }); }
24
24
  }
25
25
  }
@@ -22,7 +22,7 @@ function demoId(request, env) {
22
22
  try { return env.DEMO.idFromString(value); } catch { return null; }
23
23
  }
24
24
 
25
- // The demo's end in the visitor's time zone, as the Demo bar shows it (HH:MM).
25
+ // The demo's end in the visitor's time zone, retained in runtime settings.
26
26
  function localTime(time, timeZone = 'UTC') {
27
27
  const parts = Object.fromEntries(new Intl.DateTimeFormat('en-US', { timeZone, hourCycle: 'h23', year: 'numeric', month: '2-digit', day: '2-digit',
28
28
  hour: '2-digit', minute: '2-digit', second: '2-digit', timeZoneName: 'longOffset' }).formatToParts(time).map(part => [part.type, part.value]));
@@ -47,7 +47,7 @@ function refusal(request, env, status, notice, headers = {}) {
47
47
  function progress(request, env, id, state) {
48
48
  const headers = new Headers({ 'cache-control': 'no-store' });
49
49
  if (state.correlation) headers.set('x-rer-demo-correlation', state.correlation);
50
- if (state.phase === 'failed') return refusal(request, env, 502, 'The demo did not start. Try again.', { ...Object.fromEntries(headers), 'set-cookie': clearCookie(env) });
50
+ if (state.phase === 'failed') return refusal(request, env, state.capacity ? 503 : 502, state.capacity ? 'Every demo is in use right now. Try again in a few minutes.' : 'The demo did not start. Try again.', { ...Object.fromEntries(headers), 'set-cookie': clearCookie(env) });
51
51
  headers.append('set-cookie', demoCookie(env, id.toString()));
52
52
  if (state.phase === 'starting') {
53
53
  headers.set('retry-after', '1');
@@ -292,6 +292,18 @@ again, within 30 seconds. Library `verifyHealth`
292
292
  retains the existing window, retrying only 404, 503 and network failures for
293
293
  30 seconds by default.
294
294
 
295
+ Custom-hook `rer deploy` finalization gets a separate 90-second `/health` wait
296
+ after the hook returns, using the current recorded Worker version when available.
297
+ The hook can already have claimed the owner and retired its token, which creates
298
+ another version and can exhaust the original upload window. First hosted Slate
299
+ and Pencil deploys on 15 October 2026 failed this final gate even though health
300
+ named the right commit seconds later. Reusing the existing 90-second propagation
301
+ budget gives this final observation the same bounded allowance, without spending
302
+ it on the hook's earlier work. Transport failures and healthy identity mismatches wait;
303
+ permanent HTTP or malformed responses still fail. The deadline includes request
304
+ time and backoff; each request is capped at 30 seconds. Failure names the last
305
+ observed answer and the exact same-environment rerun.
306
+
295
307
  The returned receipt carries `health: {ok, versionId, attempts}`. Each attempt is
296
308
  `{offsetMs, status, cfRay, contentType, errorClass}`: `status` is null for
297
309
  a transport failure and `errorClass` is null for the passing attempt. The receipt
@@ -21,7 +21,7 @@ async function bodyPrefix(response) {
21
21
 
22
22
  /** One credential-free, bounded request. Retain only bounded response evidence. */
23
23
  /** `expected` holds the deploy identity fields the caller knows; each must match. */
24
- export async function healthRequest({origin, expected, request, timeoutMs, offsetMs}) {
24
+ export async function healthRequest({origin, expected, request, timeoutMs, offsetMs, retryIdentityMismatch = false}) {
25
25
  const attempt = {offsetMs,status:null,cfRay:null,contentType:null,body:'',errorClass:null};
26
26
  let response;
27
27
  try {
@@ -63,10 +63,12 @@ export async function healthRequest({origin, expected, request, timeoutMs, offse
63
63
  if (body?.ok !== true || Object.entries(expected).some(([key, value]) => body.deployment?.[key] !== value)) {
64
64
  attempt.errorClass = 'health-identity-mismatch';
65
65
  // Right after an upload the edge can still answer from another version: that
66
- // settles within the bound. The expected version answering wrongly does not.
66
+ // settles within the bound. Final source observation also waits out healthy
67
+ // identity mismatches; other callers reject a wrong identity from the
68
+ // expected version at once.
67
69
  const key = expected.versionId ? 'versionId' : 'sourceSha';
68
70
  const other = body?.ok === true && typeof body.deployment?.[key] === 'string' && body.deployment[key] !== expected[key];
69
- return {attempt,transient:other};
71
+ return {attempt,transient:other || retryIdentityMismatch && body?.ok === true};
70
72
  }
71
73
  return {attempt,transient:false};
72
74
  }
@@ -77,13 +79,13 @@ const MIN_DELAY_MS = 2000, MAX_DELAY_MS = 10000;
77
79
 
78
80
  /** The total bound includes requests, body reads and backoff; no request starts at the deadline.
79
81
  * Only a transient outcome is retried. Every attempt is recorded, in order, whatever the end. */
80
- export async function waitHealth({origin,receipt,versionId,expected={sourceSha:receipt.source.sha,fingerprint:receipt.fingerprint,versionId},request,timeoutMs=30000,totalMs=90000,clock=()=>performance.now(),sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms)),onAttempt=()=>{},single=false,freshUpload=false,window}) {
82
+ export async function waitHealth({origin,receipt,versionId,expected={sourceSha:receipt.source.sha,fingerprint:receipt.fingerprint,versionId},request,timeoutMs=30000,totalMs=90000,clock=()=>performance.now(),sleep=ms=>new Promise(resolve=>setTimeout(resolve,ms)),onAttempt=()=>{},single=false,freshUpload=false,window,retryIdentityMismatch=false}) {
81
83
  assert(Number.isFinite(totalMs) && totalMs > 0 && totalMs <= 90000 && Number.isFinite(timeoutMs) && timeoutMs > 0,'invalid-health-bound');
82
84
  const start = clock(); const attempts = []; let delay = 1000;
83
85
  while (true) {
84
86
  const remaining = Math.min(totalMs - (clock()-start), window?.remaining() ?? Infinity);
85
87
  if (remaining <= 0) break;
86
- const result = await healthRequest({origin,expected,request,timeoutMs:Math.max(1,Math.ceil(Math.min(timeoutMs,remaining))),offsetMs:Math.round(clock()-start)});
88
+ const result = await healthRequest({origin,expected,request,timeoutMs:Math.max(1,Math.ceil(Math.min(timeoutMs,remaining))),offsetMs:Math.round(clock()-start),retryIdentityMismatch});
87
89
  attempts.push(result.attempt); await onAttempt(result.attempt,attempts);
88
90
  if (!result.attempt.errorClass) return {ok:true,versionId,attempts};
89
91
  // A newly uploaded workers.dev route can briefly disappear even after its
@@ -101,8 +101,8 @@ function entries(declaration, key) {
101
101
  assert(Array.isArray(list) && list.every(item => item && typeof item === 'object' && !Array.isArray(item) && Object.keys(item).every(k => ENTRY_KEYS[key].includes(k))), 'invalid-owner-declaration');
102
102
  return list;
103
103
  }
104
- /* RER_DEV_KEY opens local dev identity and RER_DEMO turns on demo mode (nothing
105
- * sent, throwaway data); they and every key a seed adapter declares local-only
104
+ /* RER_DEV_KEY opens local dev identity and RER_DEMO turns on demo mode (mocked
105
+ * third-party effects, throwaway data); they and every key a seed adapter declares local-only
106
106
  * never become a deployed binding, secret or secret source. */
107
107
  export const LOCAL_ONLY_KEYS = Object.freeze(['RER_DEV_KEY', 'RER_DEMO', 'RER_MODELS_KEY', 'RER_MODELS_SERVICE', '.rer/local/models.json']);
108
108
  export function localOnlyBinding(declaration, localOnlyKeys = []) {
@@ -22,15 +22,18 @@ export async function* r2ObjectPages(api, bucket) {
22
22
  const data = await api.envelope(`/r2/buckets/${bucket}/objects?per_page=1000${cursor ? `&cursor=${encodeURIComponent(cursor)}` : ''}`);
23
23
  const rows = data.result, info = data.result_info;
24
24
  assert(Array.isArray(rows) && rows.length <= 1000 && rows.every(row => typeof row?.key === 'string' && row.key.length), 'invalid-r2-object-list');
25
- // Empty object listings may omit pagination or return null. Only that
26
- // shape proves completion without explicit pagination evidence.
27
- if (rows.length === 0 && info == null) { yield rows; return; }
28
- assert(info && typeof info.is_truncated === 'boolean' && (!info.delimited || Array.isArray(info.delimited) && !info.delimited.length), 'provider-incomplete-pagination');
29
25
  assert(new Set(rows.map(row => row.key)).size === rows.length, 'invalid-r2-object-list');
26
+ // Cloudflare may omit pagination (or return null) on any terminal page
27
+ // shorter than the requested limit. A full page cannot prove completion.
28
+ if (info == null) {
29
+ assert(rows.length < 1000, 'provider-incomplete-pagination');
30
+ yield rows; return;
31
+ }
32
+ assert(typeof info.is_truncated === 'boolean' && (!info.delimited || Array.isArray(info.delimited) && !info.delimited.length), 'provider-incomplete-pagination');
30
33
  if (info.is_truncated) {
31
34
  assert(rows.length > 0 && typeof info.cursor === 'string' && info.cursor.length > 0 && info.cursor.length <= 4096 && !seen.has(info.cursor), 'provider-invalid-cursor');
32
35
  cursor = info.cursor; seen.add(cursor);
33
- }
36
+ } else assert(info.cursor == null || info.cursor === '', 'provider-invalid-cursor');
34
37
  yield rows;
35
38
  if (!info.is_truncated) return;
36
39
  }
@@ -20,7 +20,7 @@ export async function readJson(path, fallback) {
20
20
  // Lamport's bakery lock: publish choosing before reading tickets, then wait for
21
21
  // every earlier (number,id). Unique records avoid the stale-unlink/new-lock race
22
22
  // of a single reclaimable lock file. Every publication is atomic and complete.
23
- export async function transaction(directory, owner, action) {
23
+ export async function transaction(directory, owner, action, { validateState } = {}) {
24
24
  const locks = join(directory, 'locks');
25
25
  await mkdir(locks, { recursive: true, mode: 0o700 });
26
26
  const id = randomUUID(), path = join(locks, `${id}.json`);
@@ -55,6 +55,9 @@ export async function transaction(directory, owner, action) {
55
55
  while ((await participants()).some(record => record.id !== id && (record.choosing
56
56
  || record.number < number || (record.number === number && record.id < id)))) await delay(20);
57
57
  const statePath = join(directory, 'state.json');
58
+ // Registry custody checks must share the writer's lock and precede any
59
+ // state read, so an atomic replacement cannot invalidate their inode.
60
+ await validateState?.(statePath);
58
61
  const state = await readJson(statePath, { version: 1, sequence: 0, queued: [], running: [] });
59
62
  if (state.version !== 1 || !Array.isArray(state.queued) || !Array.isArray(state.running)) throw Error('Invalid job queue state');
60
63
  const result = await action(state);
@@ -19,11 +19,11 @@ const result = await sender.send({
19
19
 
20
20
  ## Adopting
21
21
 
22
- A seed copies this module's runtime files byte for byte, to the same paths under its root, and records them in its source lock. Every seed copies the same one module: one SendGrid transport, and the development outbox. The same facade also supports optional signed Messaging links; unlinked sends and the local outbox keep their existing configuration.
22
+ A seed copies this module's runtime files byte for byte, to the same paths under its root, and records them in its source lock. Every seed copies the same one module: the remote transports and an explicit development suppression path. The same facade also supports optional signed Messaging links.
23
23
 
24
24
  ### Mail
25
25
 
26
- Every seed copies these files. `index.mjs` loads all of them, including the outbox below, so none can be left out.
26
+ Every seed copies these files. `index.mjs` loads all of them, including the development path below, so none can be left out.
27
27
 
28
28
  ```text
29
29
  modules/mail/LICENSE
@@ -71,9 +71,9 @@ modules/mail/src/doctor/receive.mjs
71
71
  modules/mail/src/doctor/records.mjs
72
72
  ```
73
73
 
74
- ### Local outbox
74
+ ### Development delivery
75
75
 
76
- Every seed copies this whole folder, every file in it. It is what lets a seed sign in locally without a real mail account. Apply `schema.sql` to the local database during local setup (see [Adopting the local outbox](#adopting-the-local-outbox)).
76
+ Copy the development entry with the facade. Its sender validates messages and silently suppresses them. Preserve the schema and storage reader when an installation has historical development mail.
77
77
 
78
78
  ```text
79
79
  modules/mail/src/development/
@@ -95,11 +95,10 @@ Sign-in mail is the seed's own wiring around the two things above, not a copy of
95
95
 
96
96
  ```text
97
97
  default-seed/src/core/platform/auth/mail.server.mjs
98
- default-seed/src/core/platform/auth/outbox.server.mjs
99
98
  default-seed/migrations/core/0004_development_outbox.sql
100
99
  ```
101
100
 
102
- `mail.server.mjs` builds the production sender from `MAIL_PROVIDER` (`resend`, `sendgrid` or `cloudflare`) and, only under explicit local configuration, the development sender. `outbox.server.mjs` serves the loopback-only viewer. The migration is the outbox table from `schema.sql`.
101
+ `mail.server.mjs` builds the production sender from `MAIL_PROVIDER` (`resend`, `sendgrid` or `cloudflare`). Explicit development and demo configuration suppress mail before selecting any configured remote sender. The migration preserves historical local messages.
103
102
 
104
103
  ### Former sendgrid-email API
105
104
 
@@ -121,7 +120,7 @@ These are for developing the module itself or documentation. A seed may keep any
121
120
  The provider is explicit: `sendgrid`, `resend`, `cloudflare`, `rer`, `messaging`, or `development`.
122
121
  `mode` is required (`production`, `development`, or `test`). Remote providers require `apiKey`; Cloudflare additionally requires a 32-hex `accountId`. A remote provider in test/development mode still makes a real provider request unless the caller explicitly supplies a test fetch. Missing credentials, validation errors, or provider failure never select another provider. Config and messages reject unknown fields so requested features cannot silently disappear.
123
122
 
124
- `createMailSender(config, dependencies?)` returns `{send(message)}`. Dependencies are optional standard `fetch`, an explicit asynchronous `outbox.put(message)`, `clock: () => epochMilliseconds`, and `timeoutMilliseconds` (a positive safe integer bounding each remote attempt; the default is 15,000). Production normally uses global fetch. Direct provider endpoints are fixed; `rer` uses its assigned relay URL. No retry or automatic replay exists. The sender snapshots configuration at construction and the message at submission.
123
+ `createMailSender(config, dependencies?)` returns `{send(message)}`. Dependencies are optional standard `fetch`, `clock: () => epochMilliseconds`, and `timeoutMilliseconds` (a positive safe integer bounding each remote attempt; the default is 15,000). Production normally uses global fetch. Direct provider endpoints are fixed; `rer` uses its assigned relay URL. No retry or automatic replay exists. The sender snapshots configuration at construction and the message at submission.
125
124
 
126
125
  ### Managed mail through RER
127
126
 
@@ -175,7 +174,7 @@ Resend checks a conservative 40,000,000-byte total email budget before Base64 or
175
174
  JSON encoding, including UTF-8 bodies, all recipients/headers, aggregate Base64
176
175
  attachments and MIME overhead. Its final JSON request is capped at 39,000,000
177
176
  UTF-8 bytes. Oversize input throws `MailValidationError` with fixed code
178
- `resend_message_too_large` before any send or outbox effect. See the precise
177
+ `resend_message_too_large` before dispatch. See the precise
179
178
  [Resend size budget](src/adapters/resend/README.md#outbound-size-budget); it is a
180
179
  local guard and may reject input below the provider's maximum.
181
180
 
@@ -191,58 +190,14 @@ Network loss, redirects, HTTP 408 and 5xx are conservatively `uncertain`; 429 is
191
190
 
192
191
  ## Development and unsubscribe
193
192
 
194
- Development requires all three: `provider:'development'`, `mode:'development'`, and explicit `dependencies.outbox.put`. It captures the prepared message with its raw attachment bytes and returns `development`, never remote acceptance. A storage failure throws `DevelopmentOutboxError` (`code: 'development_outbox_failed'`, `retryable: true`): the message is valid, so a queue consumer retries it. Invalid input throws `MailValidationError`, which is permanent and is dropped. Configure storage only in your development host; no route is mounted automatically and no network replay is provided. Treat captured messages and sign-in links as sensitive local data.
193
+ Development requires `provider:'development'` and `mode:'development'`.
194
+ It validates the prepared message and silently suppresses delivery, returning
195
+ `development` without contacting a provider or storing the message. Production
196
+ must never select development mode after missing credentials or a send failure.
195
197
 
196
- ### Adopting the local outbox
197
-
198
- The typed `src/development/index.mjs` subpath exports
199
- `createD1DevelopmentOutbox({db,maxMessages?,maxAgeMs?,clock?})` and
200
- `createDevelopmentOutboxHandler({local,origin,outbox,path?,theme?})`. The root facade's
201
- exports remain stable. `theme` is the seed's served theme stylesheet, a
202
- root-relative `.css` path such as `'/rer-theme.css'` (the same grammar as
203
- operator-auth `branding.theme`; any other value throws when the handler is
204
- created). With it the page links that file, reads its `--rer-*` tokens with
205
- readable fallbacks and a visible 3px focus ring, and its policy allows
206
- same-origin styles, fonts and images (still no script). Without it the page is
207
- unchanged. Apply the additive [schema](src/development/schema.sql)
208
- to your local D1 database during local setup, for example:
209
-
210
- ```sh
211
- pnpm exec wrangler d1 execute DB --local --file=../modules/mail/src/development/schema.sql
212
- ```
213
-
214
- Use the actual database binding and source path for your host. The table and
215
- index are namespaced `rer_mail_development_outbox`; the schema is repeatable and
216
- does not replace application tables. Keep the local D1 persistence directory
217
- between restarts. No provider credentials are needed for local capture.
218
-
219
- ```js
220
- import { createMailSender } from './modules/mail/index.mjs';
221
- import {
222
- createD1DevelopmentOutbox, createDevelopmentOutboxHandler,
223
- } from './modules/mail/src/development/index.mjs';
224
-
225
- // These values come from trusted, explicit local host configuration.
226
- const outbox = createD1DevelopmentOutbox({ db: env.DB });
227
- const sender = createMailSender(
228
- { provider: 'development', mode: 'development' }, { outbox },
229
- );
230
- const viewOutbox = createDevelopmentOutboxHandler({
231
- local: localConfiguration.enabled === true,
232
- origin: localConfiguration.origin, // e.g. 'http://localhost:8787'
233
- outbox,
234
- });
235
- // In the host's request handler, before the application catch-all:
236
- const response = await viewOutbox(request);
237
- if (response) return response;
238
- // Continue normal application routing otherwise.
239
- ```
240
-
241
- Wire the application's real sign-in mail call to `sender.send`; the regular
242
- message composition and unsubscribe assembly still run. Make this selection
243
- only in the explicit local configuration. Production keeps its configured
244
- remote sender, and does not mount the development viewer. Missing provider
245
- credentials or a delivery failure must never select development mode.
198
+ `createD1DevelopmentOutbox({db,maxMessages?,maxAgeMs?,clock?})` remains available
199
+ for reading and erasing mail retained by older local installations. There is no
200
+ outbox viewer or development sign-in mail flow. Keep applied migrations.
246
201
 
247
202
  `put(preparedMessage)` resolves without a receipt; `list()` returns captures
248
203
  newest first, and `get(id)` returns a capture or `null`. A capture is
@@ -255,31 +210,9 @@ D1 batch as the operation; a message expires exactly at `createdAt + maxAgeMs`.
255
210
  Equal timestamps retain the most recently inserted captures first. A failing
256
211
  batch fails the operation without a process-memory fallback.
257
212
 
258
- The viewer lives at `/__dev/outbox` (or the explicit `path`) and accepts GET and
259
- HEAD. It returns `null` unless `local === true`, the configured origin is an
260
- exact serialized HTTP(S) loopback origin, and the request URL and Host match
261
- its scheme and authority. `localhost`, canonical `127.x.x.x`, and `[::1]` are
262
- supported. Trailing slashes, credentials, paths, queries, fragments, whitespace
263
- and alternate URL spellings in the configured origin are refused. Host must
264
- include the configured non-default port. Forwarded headers never grant access;
265
- a different Origin or a cross-site fetch is also refused before any D1 read.
266
- The host must bind its development listener to loopback; these request checks
267
- do not replace that listener configuration.
268
-
269
- The listing shows subject, recipient and received time. A message detail shows
270
- escaped text (escaped source for HTML-only messages) and a large **Open this
271
- link** action for the first valid HTTP(S) link. It never renders live email
272
- HTML or attachment content. All viewer responses, including errors, carry
273
- no-store, noindex, nosniff and a strict CSP with an exact static-style hash and
274
- scripts disabled. The layout wraps long content on a 390px viewport.
275
-
276
- First-party seeds route local setup through `rer setup` and
277
- declare their actual mail, auth, database and migration behavior in the RER
278
- adapter. Base's default seed is the reference for loopback development mail and
279
- the private local outbox. Follow the runnable checkout's root
280
- `RUN-LOCALLY.md` for current command and state requirements; the outbox module does not
281
- replace a seed's owner setup, database bindings, migration directory or sign-in
282
- policy.
213
+ First-party seeds route local setup through `rer setup` and declare their actual
214
+ mail, auth, database and migration behavior in the RER adapter. Follow the
215
+ runnable checkout's root `RUN-LOCALLY.md` for its command and state requirements.
283
216
 
284
217
  `unsubscribe: {url, mailto?, oneClick?}` supplies an HTTPS unsubscribe URL and optional mailbox. One-click generates `List-Unsubscribe-Post: List-Unsubscribe=One-Click`. Insecure URLs, injection and contradictory custom unsubscribe headers fail before dispatch. `applyUnsubscribeHeaders(message)` returns a new prepared message with the `unsubscribe` request removed. Passing an already prepared message to the facade is safe. Direct adapters reject unconsumed requests before any effect; the facade performs assembly once before dispatch. Applications own unsubscribe authorization and processing. Confirm delivered headers and DKIM coverage with a real delivered message; local serialization is not one-click acceptance.
285
218
 
@@ -319,7 +252,7 @@ For a D1 application, copy `src/events/d1-schema.sql` into a **new** migration a
319
252
  use [the D1 event constructor](src/events/README.md). No migration, linking,
320
253
  provider switch or credential removal happens automatically. Self-hosted installs
321
254
  stay unlinked until the owner configures them; local development still uses the
322
- existing D1 outbox without a Messaging service.
255
+ explicit development suppression without a Messaging service.
323
256
 
324
257
  ## The former sendgrid-email API
325
258
 
@@ -373,6 +306,6 @@ pnpm --dir modules/mail test:workerd
373
306
 
374
307
  The root install is also required for the bundle regression, which uses the reference app's actual Vite dependency. The facade formerly re-exported the doctor while the doctor dynamically imported the facade, causing Vite's `INEFFECTIVE_DYNAMIC_IMPORT` warning. Both now import a private sender module; the existing facade exports and send behavior remain unchanged. `tests/development/bundle.test.mjs` builds the facade and doctor with Vite and fails on that warning.
375
308
 
376
- The module-local lock pins the Miniflare/workerd test runtime; production source has no npm dependencies. Unit suites cover core validation, adapters, events, inbound parsing, development, unsubscribe and doctor behaviour. The Messaging HTTP/service-binding smoke and real D1 intake race/rollback/restart suite join the existing area smokes. They check core portability, remote adapters, inbound hydration, durable event intake, the development outbox and doctor/facade assembly. The storage smokes retain real transaction rollback, namespace isolation, restart and sensitive viewer refusal coverage. `tests/all.test.ts` runs the nested suites serially through `pnpm verify:modules`; each worker is disposed after its run. Former SendGrid API tests remain while seed source still imports the deprecated module.
309
+ The module-local lock pins the Miniflare/workerd test runtime; production source has no npm dependencies. Unit suites cover core validation, adapters, events, inbound parsing, development, unsubscribe and doctor behaviour. The Messaging HTTP/service-binding smoke and real D1 intake race/rollback/restart suite join the existing area smokes. They check core portability, remote adapters, inbound hydration, durable event intake, historical development storage and doctor/facade assembly. The storage smokes retain real transaction rollback, namespace isolation, restart and suppression coverage. `tests/all.test.ts` runs the nested suites serially through `pnpm verify:modules`; each worker is disposed after its run. Former SendGrid API tests remain while seed source still imports the deprecated module.
377
310
 
378
311
  Local conformance does not establish provider configuration, DNS propagation, deployed webhook reachability, DKIM coverage or mailbox delivery. Live acceptance remains **PENDING** until an exact-SHA hosted run sends and receives on the owner's approved test domain with independently correlated mailbox evidence. Resend is the default test sender; SendGrid is selected where Inbound Parse is required. No live request is authorized by running local tests.
@@ -36,7 +36,6 @@ export function validateConfig(config, dependencies = {}) {
36
36
  if (config.provider === 'development') {
37
37
  if (config.mode !== 'development') fail('development_mode_required');
38
38
  if (config.apiKey !== undefined || config.accountId !== undefined) fail('unsupported_development_config');
39
- if (!dependencies.outbox || typeof dependencies.outbox.put !== 'function') fail('development_outbox_required');
40
39
  } else {
41
40
  if (typeof config.apiKey !== 'string' || !config.apiKey.trim()) fail('api_key_required');
42
41
  bounded(config.apiKey, 4096, 'invalid_api_key');
@@ -34,10 +34,5 @@ export class DevelopmentOutboxError extends Error {
34
34
  readonly retryable: true;
35
35
  }
36
36
  export function createD1DevelopmentOutbox(options: { db: DevelopmentD1Database; maxMessages?: number; maxAgeMs?: number; clock?: () => number }): DevelopmentOutbox;
37
- export function createDevelopmentOutboxHandler(options: {
38
- local: boolean; origin: string; outbox: Pick<DevelopmentOutbox, 'list' | 'get'>; path?: string;
39
- /** The seed's served theme stylesheet, a root-relative `.css` path such as '/rer-theme.css'; other values throw. */
40
- theme?: string;
41
- }): (request: Request) => Promise<Response | null>;
42
37
  export function sendDevelopment(config: { provider: 'development'; mode: 'development' }, message: DevelopmentMessage,
43
- dependencies: { outbox: Pick<DevelopmentOutbox, 'put'>; clock?: () => number }): Promise<{ provider: 'development'; status: 'development'; providerMessageId: null }>;
38
+ dependencies?: { clock?: () => number }): Promise<{ provider: 'development'; status: 'development'; providerMessageId: null }>;
@@ -1,9 +1,9 @@
1
- import { MailValidationError, DevelopmentOutboxError, fail } from '../core/errors.mjs';
1
+ import { MailValidationError, fail } from '../core/errors.mjs';
2
2
  import { validateConfig, validateMessage } from '../core/validation.mjs';
3
3
  import { sendResult } from '../core/transport.mjs';
4
4
 
5
+ // Retained for reading and erasing messages saved by older local installations.
5
6
  export { createD1DevelopmentOutbox } from './outbox.mjs';
6
- export { createDevelopmentOutboxHandler } from './viewer.mjs';
7
7
  export { DevelopmentOutboxError } from '../core/errors.mjs';
8
8
 
9
9
  function validate(operation, errorCode) {
@@ -15,24 +15,11 @@ function validate(operation, errorCode) {
15
15
  }
16
16
  }
17
17
 
18
- /** Store one explicitly selected development message without contacting a provider. */
18
+ /** Explicit development delivery validates the message and silently suppresses it. */
19
19
  export async function sendDevelopment(config, message, dependencies = {}) {
20
20
  validate(() => validateConfig(config, dependencies), 'invalid_config');
21
21
  if (validate(() => config.provider, 'invalid_config') !== 'development') fail('development_provider_required');
22
-
23
22
  validate(() => validateMessage(message, 'development'), 'invalid_message');
24
23
  if (validate(() => message.unsubscribe, 'invalid_message') !== undefined) fail('unsubscribe_not_assembled');
25
-
26
- const snapshot = validate(() => structuredClone(message), 'invalid_message');
27
- validate(() => validateMessage(snapshot, 'development'), 'invalid_message');
28
-
29
- try {
30
- await dependencies.outbox.put(snapshot);
31
- } catch (error) {
32
- // Input the outbox itself refuses stays permanent; a storage failure is worth a retry.
33
- if (error instanceof MailValidationError) throw error;
34
- throw new DevelopmentOutboxError();
35
- }
36
-
37
24
  return sendResult('development', 'development', null);
38
25
  }
@@ -63,7 +63,7 @@ Base's operator auth is the only staff sign-in, in three layers:
63
63
  | --- | --- | --- |
64
64
  | `identity/` | Proving who a person is: the email link (`identity/email-link/`), identity providers over OpenID Connect (`identity/oidc/`, see [its README](identity/oidc/README.md)), and the admission that turns a verified principal into a session (`identity/admission.mjs`). | Outputs a **verified principal** `{issuer, subject, provider?, email?, emailVerified?, emailVerifiedAt?, amr?}`; `identity/index.mjs`. |
65
65
  | `accounts/` | Who a person is in this app and what they may do: operators, roles, invitations, sessions, domain rules and step-up proofs in the `oa_` store (`accounts/store.mjs`, `accounts/schema/`). | The **accounts adapter interface** (`accounts/adapter.mjs`); Base's implementation over `oa_` is `accounts/oa.mjs`. |
66
- | `dev/` | Local-only dev sessions, personas and the badge, loaded only from a local-only Worker entry. | `dev/index.mjs`; see "Local dev identity" below. |
66
+ | `dev/` | Local-only dev sessions, personas and mode labels, loaded only from a local-only Worker entry. | `dev/index.mjs`; see "Local dev identity" below. |
67
67
 
68
68
  The files at the root are shared by all three: HTTP and input checks, crypto,
69
69
  configuration and branding, the shared page frame (`page.mjs`), the key gate
@@ -380,7 +380,7 @@ for other requests). It is server-rendered plain HTML with no script, so it work
380
380
  before hydration and without JavaScript, in the same hashed-style frame as the
381
381
  confirmation page (light and dark, the seed's `rer-theme.css` when declared).
382
382
  It shows "Continue with…" for each linked, reachable provider, then the email
383
- link, then optional seed links (the local outbox) and, while the first owner is
383
+ link, then optional seed links and, while the first owner is
384
384
  unclaimed, the setup form. A provider that has failed discovery or JWKS for 5
385
385
  minutes, or answered 404 or a DNS failure, is hidden, and a browser that still
386
386
  posts to it comes back to this page with a notice and the email link instead of
@@ -477,8 +477,7 @@ local mode. `admits(request)` accepts the `rer_dev_gate_<port>` cookie (an HMAC
477
477
  key, so a reset key refuses old cookies) or the key in `x-rer-dev-key` (the rer
478
478
  CLI and test harnesses). `exchange(request)` serves `GET /__dev/key` and trades
479
479
  the key from the URL fragment, through a same-origin POST, for a host-only
480
- `HttpOnly; SameSite=Strict; Path=/` cookie. Seeds gate their development outbox
481
- with it.
480
+ `HttpOnly; SameSite=Strict; Path=/` cookie.
482
481
 
483
482
  `dev/` is the dev layer: **server-only and local-only**. Import it only from a
484
483
  local-only Worker entry (a Vite-serve or local `wrangler dev` entry), never
@@ -489,19 +488,21 @@ the seed's Worker and serves, behind the gate only:
489
488
  | Path | Result |
490
489
  | --- | --- |
491
490
  | `/auth/dev/enter?as=owner\|signed-out\|PERSONA&returnTo=` | Creates or reuses a real `oa_sessions` row of kind `dev` for the configured owner or persona and 303s to `returnTo` (default `/app`); `signed-out` revokes the current session. |
491
+ | `POST /auth/local/cli-session` | Owner-side tooling proves possession of the session secret with `x-rer-local-cli`; exact loopback and origin checks precede issuing a native owner session and fresh local proof. This route exists only in the dev entry. |
492
492
  | `/__dev/personas` | `[{as,email,role?}]`, used by `rer dev` for `RER_SIGNED_IN`. |
493
493
 
494
494
  `personas()` returns the seed's `devPersonas()`: `[{as, role, displayName?}]`,
495
495
  real operators at `<as>@dev.localhost` created only by dev sign-in. Dev
496
496
  sessions pass the same version fences, revocation, deactivation and allow-list
497
- as every other session. The core admits a `dev` session, and any credential
497
+ as every other session. An admitted local dev session also confirms sensitive
498
+ actions directly, so dev never waits for an email step-up link. The core admits a `dev` session, and any credential
498
499
  minted while using one (`oa_dev_credentials`, today an invitation link, whose
499
500
  confirmation then yields a `dev` session), only when the dev layer's
500
501
  registered check passes for that request; a production Worker never registers
501
- one. HTML documents gain a dev-only badge for switching identity; the root
502
- document also gets the fragment exchange script. Both are added under the
503
- document's own CSP by hash. With `RER_DEV_IDENTITY=off` (`rer dev --login`)
504
- dev sign-in and personas answer 404 while the gate still opens the outbox. The
502
+ one. HTML documents gain the Dev suffix on product labels marked with
503
+ `data-rer-name` and document titles; a demo receives Demo instead. The dedicated
504
+ `/__dev/key` document exchanges the RER_OPEN fragment without placing the key in
505
+ request URLs. `RER_DEV_IDENTITY=off` disables dev sign-in and personas. The
505
506
  layer answers 503 to every request when `RER_INSTALLATION_ID` is set beside a
506
507
  non-loopback `RER_MANAGEMENT_ORIGIN`.
507
508
 
@@ -1,5 +1,4 @@
1
- // Inline additions to a document's Content-Security-Policy: the dev badge and
2
- // the demo bar each add one hashed style without loosening anything else.
1
+ // Inline product labels add exact CSP hashes without broadening other sources.
3
2
 
4
3
  /** The CSP source token for an exact inline text. */
5
4
  export async function sha256(text) {