@runeditrun/rer 0.2.18 → 0.2.20

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 (113) 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 +6 -4
  6. package/cli/delivery-declarations.mjs +36 -0
  7. package/cli/demo-host.mjs +2 -2
  8. package/cli/demo.mjs +16 -5
  9. package/cli/deploy-command.mjs +4 -1
  10. package/cli/deploy.mjs +4 -1
  11. package/cli/detached-server.mjs +2 -2
  12. package/cli/dev-identity.mjs +1 -1
  13. package/cli/export.mjs +1 -1
  14. package/cli/inspect.mjs +17 -15
  15. package/cli/lifecycle.mjs +16 -49
  16. package/cli/listen.mjs +31 -0
  17. package/cli/local.mjs +12 -18
  18. package/cli/main.mjs +7 -0
  19. package/cli/managed-server.mjs +26 -44
  20. package/cli/output.mjs +1 -1
  21. package/cli/parse.mjs +8 -7
  22. package/cli/port.mjs +20 -20
  23. package/cli/production-auth.mjs +38 -0
  24. package/cli/server-proxy.mjs +2 -6
  25. package/cli/server-registry.mjs +7 -2
  26. package/cli/setup-input.mjs +3 -0
  27. package/cli/signin.mjs +41 -0
  28. package/global/CHANGELOG.md +18 -0
  29. package/global/README.md +7 -7
  30. package/global/cli/install.mjs +4 -28
  31. package/global/cli/path-link.mjs +25 -21
  32. package/global/launch/dev.mjs +1 -1
  33. package/global/launch/facts.mjs +11 -14
  34. package/global/launch/failure.mjs +20 -0
  35. package/global/launch/render.mjs +2 -6
  36. package/global/launch/worker.mjs +3 -3
  37. package/global/main.mjs +3 -3
  38. package/modules/container/build.mjs +2 -2
  39. package/modules/container/demo-egress.mjs +35 -0
  40. package/modules/container/worker-engine.mjs +3 -3
  41. package/modules/d1-transport/index.d.mts +9 -0
  42. package/modules/d1-transport/index.mjs +124 -0
  43. package/modules/delivery-producer/bindings.mjs +140 -0
  44. package/modules/delivery-producer/declarations.mjs +49 -0
  45. package/modules/demo/README.md +34 -0
  46. package/modules/demo/effects.mjs +73 -0
  47. package/modules/demo/index.d.mts +15 -0
  48. package/modules/demo/index.mjs +63 -0
  49. package/modules/demo/label.d.mts +2 -0
  50. package/modules/demo/label.mjs +24 -0
  51. package/modules/demo/responses.mjs +26 -0
  52. package/modules/demo/sockets.mjs +13 -0
  53. package/modules/demo/vite.d.mts +2 -0
  54. package/modules/demo/vite.mjs +19 -0
  55. package/modules/demo-host/README.md +5 -1
  56. package/modules/demo-host/container.mjs +4 -4
  57. package/modules/demo-host/pages.mjs +1 -1
  58. package/modules/demo-host/worker.mjs +1 -1
  59. package/modules/deploy-kit/README.md +2 -0
  60. package/modules/deploy-kit/owner-cli.mjs +5 -2
  61. package/modules/deploy-kit/owner-signin.mjs +34 -0
  62. package/modules/deploy-kit/owner.mjs +2 -2
  63. package/modules/deploy-kit/r2-objects.mjs +8 -5
  64. package/modules/job-queue/storage.mjs +4 -1
  65. package/modules/mail/README.md +62 -87
  66. package/modules/mail/src/adapters/rer/contract.mjs +22 -0
  67. package/modules/mail/src/adapters/rer/index.mjs +30 -0
  68. package/modules/mail/src/core/transport.mjs +1 -1
  69. package/modules/mail/src/core/validation.mjs +6 -3
  70. package/modules/mail/src/development/index.d.mts +1 -6
  71. package/modules/mail/src/development/index.mjs +3 -16
  72. package/modules/mail/src/sender.mjs +2 -1
  73. package/modules/operator-auth/README.md +53 -9
  74. package/modules/operator-auth/accounts/email-change.mjs +34 -0
  75. package/modules/operator-auth/accounts/owner-signin.mjs +50 -0
  76. package/modules/operator-auth/accounts/schema/owner-signin.sql +10 -0
  77. package/modules/operator-auth/csp.mjs +1 -2
  78. package/modules/operator-auth/dev/cli-session.mjs +32 -0
  79. package/modules/operator-auth/dev/index.mjs +18 -11
  80. package/modules/operator-auth/identity/email-link/confirmation.mjs +3 -3
  81. package/modules/operator-auth/identity/email-link/index.mjs +4 -1
  82. package/modules/operator-auth/index.d.mts +8 -2
  83. package/modules/operator-auth/owner-signin-grant.mjs +10 -0
  84. package/modules/operator-auth/page.mjs +1 -1
  85. package/modules/operator-auth/routes.mjs +11 -1
  86. package/modules/operator-auth/service.mjs +4 -0
  87. package/modules/operator-auth/signin/index.d.mts +1 -1
  88. package/modules/portability/README.md +6 -0
  89. package/modules/portability/catalogue.mjs +1 -1
  90. package/modules/portability/copies.mjs +17 -2
  91. package/modules/portability/index.mjs +2 -0
  92. package/modules/portability/provider-data.mjs +1 -1
  93. package/modules/portability/storage.mjs +5 -1
  94. package/onboarding/README.md +8 -11
  95. package/onboarding/adapter-auth.mjs +6 -38
  96. package/onboarding/adapter-labels.mjs +1 -1
  97. package/onboarding/adapter.mjs +8 -11
  98. package/onboarding/app-fetch.mjs +1 -1
  99. package/onboarding/dependency-approval.mjs +5 -15
  100. package/onboarding/dev-identity.mjs +1 -1
  101. package/onboarding/operator-install.mjs +6 -7
  102. package/onboarding/operator-installer.mjs +5 -5
  103. package/onboarding/operator-prerequisites.mjs +4 -5
  104. package/onboarding/port-probe.mjs +38 -0
  105. package/onboarding/process-diagnostics.mjs +36 -20
  106. package/onboarding/server.mjs +1 -1
  107. package/onboarding/ui/app.js +1 -1
  108. package/operations/README.md +3 -0
  109. package/package.json +4 -2
  110. package/scripts/publish-check/public_hygiene.py +31 -10
  111. package/modules/mail/src/development/viewer-html.mjs +0 -42
  112. package/modules/mail/src/development/viewer.mjs +0 -72
  113. package/modules/operator-auth/dev/badge.mjs +0 -44
package/README.md CHANGED
@@ -6,7 +6,7 @@ checkout always gets the behaviour it was built and tested with.
6
6
 
7
7
  ## Install
8
8
 
9
- Any one of these leaves `rer` on your PATH:
9
+ Install `rer` with one of these commands:
10
10
 
11
11
  ```sh
12
12
  npx -y @runeditrun/rer cli install # user install in ~/.local/share/rer, launcher ~/.local/bin/rer
@@ -23,9 +23,10 @@ the package's own `rer cli install`. A failed or refused download leaves the
23
23
  version you had selected.
24
24
 
25
25
  No installer edits shell profiles. The canonical launcher is `~/.local/bin/rer`.
26
- When that directory is absent from PATH, installation also links it into an
27
- existing writable, user-owned PATH directory if available, preserving foreign
28
- commands. Otherwise it prints one activation line to run in the current shell:
26
+ Installation creates that directory if needed and never writes into another
27
+ PATH directory. It names any existing `rer` elsewhere on PATH and leaves it
28
+ unchanged. If `~/.local/bin` is absent from PATH or another command shadows it,
29
+ it prints one activation line to run in the current shell:
29
30
  `export PATH="$HOME/.local/bin:$PATH"` (with fish syntax for fish). The launcher runs `node` from
30
31
  PATH, so a Node upgrade does not break it. A re-run with the same build changes
31
32
  nothing; a different build is installed beside the current one, the previous one
@@ -99,7 +100,6 @@ RER_SIGNED_IN owner@cradle.test
99
100
  RER_OPEN http://127.0.0.1:8787/__dev/key#...
100
101
  ```
101
102
 
102
- or `RER_SIGN_IN <outbox>` for a seed that signs in through its development outbox.
103
103
  A seed that declares a run site prints one more line after those,
104
104
  `RER_SITE http://127.0.0.1:8788`: a local preview of its static run site (its
105
105
  marketing homepage, `/run` and docs) on the first free port above the app's. It
@@ -262,7 +262,7 @@ line that still names it. A later refresh is a version bump:
262
262
  | `@runeditrun/rer/modules/portability`, `/catalogue`, `/cli`, `/cli-options`, `/files`, `/format`, `/http`, `/import`, `/journal`, `/legacy-safety`, `/migration-history`, `/storage` | portability module | `scripts/base-cli/modules/portability/*.mjs` |
263
263
  | `@runeditrun/rer/modules/release/export`, `/publication-scan`, `/source`, `/signature` | release export, publication scan and shared signature verifier | `scripts/base-cli/modules/release/*.mjs` |
264
264
  | `@runeditrun/rer/modules/deploy-kit/owner`, `/owner-cli`, `/prepare`, `/provider` | deploy kit | `scripts/base-cli/modules/deploy-kit/*.mjs` |
265
- | `@runeditrun/rer/modules/operator-auth`, `/dev`, `/dev/badge`, `/dev-admission`, `/accounts/native`, `/identity/email-link` | operator auth | `scripts/base-cli/modules/operator-auth/index.mjs`, `dev/index.mjs`, `dev/badge.mjs`, `dev-admission.mjs`, `accounts/native.mjs`, `identity/email-link/index.mjs` |
265
+ | `@runeditrun/rer/modules/operator-auth`, `/dev`, `/dev-admission`, `/accounts/native`, `/identity/email-link` | operator auth | `scripts/base-cli/modules/operator-auth/index.mjs`, `dev/index.mjs`, `dev-admission.mjs`, `accounts/native.mjs`, `identity/email-link/index.mjs` |
266
266
  | `@runeditrun/rer/modules/erasure/fence` | erasure fence statements | `scripts/base-cli/modules/erasure/fence.mjs` |
267
267
  | `@runeditrun/rer/modules/owner-claim`, `/modules/dependencies` | owner claim, dependency links | `scripts/base-cli/modules/owner-claim/index.mjs`, `dependencies/index.mjs` |
268
268
  | `@runeditrun/rer/internal/PATH` | any other package file, for tests | `scripts/base-cli/PATH`, and `scripts/base-onboarding/PATH` with PATH under `onboarding/` |
@@ -273,7 +273,7 @@ In a checkout, every verb runs that checkout's own pinned `rer`; `rer VERB --hel
273
273
  there lists its flags:
274
274
 
275
275
  `install`, `setup`, `dev`, `preview`, `build`, `verify`, `reset --yes`, `deploy`,
276
- `export`, `import`, `outbox`, `doctor`, `describe`, `check`, `release`,
276
+ `export`, `import`, `doctor`, `describe`, `check`, `release`,
277
277
  `release sign`, `release receipt` and `release keygen`.
278
278
 
279
279
  Anywhere: `rer list [DIR]`, `rer cli status|install|uninstall`, `rer update`,
package/cli/README.md CHANGED
@@ -85,7 +85,7 @@ included authority generation, so archive hashes may differ even when retained
85
85
  domain and identity rows are equal. The technical foundation currently has no
86
86
  product domain or background jobs; default-seed retains its durable jobs and
87
87
  schedule records while omitting transient queue delivery state, local runtime
88
- caches and logs, local outbox, transfer bookkeeping, provider credentials,
88
+ caches and logs, transfer bookkeeping, provider credentials,
89
89
  provider link keys and transient provider sessions. People, external identity
90
90
  bindings, the installation sector and the original owner claim are retained.
91
91
  Retained dependency links are marked as needing re-link, and provider sign-in
@@ -101,7 +101,9 @@ secret generation. `--owner-email` maps to its owner-claim email field; private
101
101
  `--answers` uses declared field names. Existing owner, settings and data are kept.
102
102
  The owner name is prompted or defaulted only when the installer model declares
103
103
  the adapter's name field (normally `displayName`). Nameless installers proceed
104
- without it and refuse `--owner-name`.
104
+ without it and refuse `--owner-name`. A custom `input.names.name` uses its declared
105
+ manifest default and receives `--owner-name`; it replaces the generated
106
+ `displayName` input while keeping the adapter's owner bootstrap hook.
105
107
 
106
108
  Run `node --test --test-concurrency=2 cli/*.test.mjs` from Base. Base's shared tests
107
109
  stay in Base; exported seeds carry runtime source and their own adopting tests.
@@ -114,8 +116,8 @@ lockfiles, tool versions and output bytes in a nonsecret `.rer/local` receipt;
114
116
  changed or incomplete output is rebuilt. Changes made while serving do not
115
117
  rebuild preview. A build that regenerates its own files declares them as
116
118
  `generatedOutputs` on the command adapter (see the seed command contract); those
117
- paths are not inputs, while any other file touched during the build is refused by name. Both use the same `.wrangler/state`, saved owner and ordinary
118
- fresh sign-in through the development outbox. Stop before changing modes.
119
+ paths are not inputs, while any other file touched during the build is refused by name. Both use the same `.wrangler/state` and saved owner. Dev opens signed in through `RER_OPEN`, including with the legacy
120
+ `--login` flag. Stop before changing modes.
119
121
  Stop dev or preview before build, verification or data transfer; use the
120
122
  documented `--stop` flag or Ctrl-C.
121
123
 
@@ -135,7 +137,7 @@ Both are managed servers. `--detach` returns after readiness, leaving the server
135
137
  running; `--foreground` keeps the invocation active while serving. Preview
136
138
  refreshes changed built assets and their ETags; source edits need a restart and
137
139
  rebuild. A compatible repeated invocation verifies the registered application,
138
- prints its safe ready/outbox URLs and exits without a new build or sign-in.
140
+ prints its readiness and automatic sign-in URLs and exits without a new build or sign-in.
139
141
  Explicit conflicting host, port or timeout, or the other mode, refuses with
140
142
  exit 4 and the correct stop command. `--stop` is idempotent;
141
143
  start-only flags cannot accompany it. It requires no setup or tool versions.
@@ -158,24 +160,23 @@ idle timeout, and they stop with `dev` (explicit stop, idle timeout, Ctrl-C or
158
160
  an application exit). `preview` does not run schedules. A seed that does not
159
161
  want this declares one adapter option: `commandAdapter(lifecycle, { scheduled: false, ... })`.
160
162
 
161
- ### The CLI's own sign-in requests
162
-
163
- `setup` and every `dev` start ask the local application for one ordinary
164
- sign-in message (and `setup` claims the first owner) so the outbox is ready.
165
- Those requests carry `x-rer-local-cli`, an HMAC-SHA256 of `local-cli\0sign-in`
166
- keyed by the installation's private session secret (the setting the adapter
167
- declares as `sessionSecretKey`, default `SESSION_SECRET`)
168
- (`onboarding/adapter-auth.mjs`; checked in
169
- `modules/operator-auth/local-cli.mjs`). A server in local (loopback) mode skips
170
- the sign-in and owner-claim rate limit for a request with a valid proof, so
171
- restarting `dev` any number of times never spends the owner's sign-in budget; a
172
- person's own sign-in requests, and every request to a non-local server, still
173
- count exactly as before. Seeds receive the change by refreshing their copies as
174
- described above.
163
+ ### Local and production sign-in
164
+
165
+ `setup` claims the local owner and stops its temporary runtime. `dev` prints
166
+ `RER_OPEN` to open automatically as that owner. It does not capture email or
167
+ request a sign-in message. Legacy `--login` uses this same automatic entry.
168
+
169
+ Production deployment requires outbound email configured in the actual declared
170
+ bindings (`MAIL_PROVIDER`, `MAIL_FROM`, `MAIL_API_KEY`, and `MAIL_ACCOUNT_ID` for
171
+ Cloudflare), or an Auth SSO dependency selected through the setup manifest and
172
+ approved through the existing link flow. A redeploy can retain existing mail
173
+ secrets after the provider verifies the owned deployment. Local setup and demo
174
+ do not require production mail credentials. Preview serves production output
175
+ and prints its ready address without a captured-mail sign-in flow.
175
176
 
176
177
  Idle timeout is `--idle-timeout SECONDS`, then `RER_SERVER_IDLE_SECONDS`, then
177
178
  43200 seconds (12 hours). Only positive integer seconds are accepted. HTTP requests,
178
- including assets/outbox, reset inactivity; a live request/stream prevents idle
179
+ including assets, reset inactivity; a live request/stream prevents idle
179
180
  shutdown. Internal health probes and Vite HMR control traffic do not prolong
180
181
  serving; application WebSocket data messages count. Explicit stop and idle
181
182
  expiry clean up owned descendants before releasing state and capacity.
@@ -218,7 +219,7 @@ membership and actual process ancestry before sharing the admitted slot.
218
219
  Direct documented browser/runtime entrypoints and indirect package scripts join
219
220
  the same executor. Original-caller `CI=true` skips admission; `CI=false` and unset CI queue.
220
221
  Heavy verbs alone accept `--no-queue`, only with `CI=true`. Synthesized install
221
- child CI does not change the original decision. Inspection/help/outbox URL,
222
+ child CI does not change the original decision. Inspection/help,
222
223
  stop and reset inventory/removal do not start a heavy job or application.
223
224
 
224
225
  After the seed's verification target, `verify` runs two checks on the production
package/cli/adapter.mjs CHANGED
@@ -4,6 +4,11 @@ import { verbs, releaseFlags } from './contract.mjs';
4
4
  // the existing onboarding kit. No adapter gets a second executor.
5
5
  export function commandAdapter(lifecycle, options) {
6
6
  const result = { version: 1, ...lifecycle, ...options, state: '.wrangler/state', settings: options.settings ?? ['.dev.vars', '.dev.vars.previous'] };
7
+ // ownerBootstrap adds the generic displayName input to the installer model.
8
+ // A declared custom name uses manifest validation instead; the lifecycle's
9
+ // owner hook still performs the bootstrap with that input.
10
+ const ownerName = result.input?.names?.name;
11
+ if (typeof ownerName === 'string' && ownerName.trim() && ownerName !== 'displayName') result.ownerBootstrap = false;
7
12
  result.verbs = Object.fromEntries(Object.entries(verbs).filter(([verb]) => !['export', 'import'].includes(verb) || typeof result.portability?.[verb] === 'function').map(([verb, definition]) => [verb, { flags: [...definition.flags] }]));
8
13
  result.verbs.release = { flags: [...releaseFlags] };
9
14
  return result;
package/cli/container.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { requireProductionAuth } from './production-auth.mjs';
1
2
  import { spawn, execFile } from 'node:child_process';
2
3
  import { promisify } from 'node:util';
3
4
  import { readFile, mkdir, writeFile } from 'node:fs/promises';
@@ -25,7 +26,7 @@ export async function imageFolder(project,operation,config,{output,engine}={}) {
25
26
  const declared=Array.isArray(declaration.env)?declaration.env.map(item=>item.name):Object.keys(declaration.env??{});
26
27
  await withoutLocalVariables(root,async()=>{
27
28
  const builder=fileURLToPath(new URL('../modules/container/build.mjs',import.meta.url));
28
- await run(process.execPath,[builder,root,JSON.stringify({output,engine})],{cwd:root,env:buildEnvironment([...declared,...(config.secrets??[]).flatMap(item=>[item.binding,item.environment])])});
29
+ await run(process.execPath,[builder,root,JSON.stringify({output,engine,declaration:config})],{cwd:root,env:buildEnvironment([...declared,...(config.secrets??[]).flatMap(item=>[item.binding,item.environment])])});
29
30
  },{nested:operation.token,settings:[...(project.adapter?.settings??[]),...(project.privateInputs??[])]});
30
31
  }
31
32
  export async function containerCommand(project,options,out) {
@@ -36,13 +37,17 @@ export async function containerCommand(project,options,out) {
36
37
  }
37
38
  async function runContainer(project,options,out,operation) {
38
39
  const {root}=project;
40
+ if(['build','deploy'].includes(options.verb)&&process.env.RER_DEMO)throw refuse('Production build and deploy refuse the local-only RER_DEMO environment binding. Unset it before retrying.');
39
41
  if(options.verb==='deploy'){try{await refuseLocalModels(root);}catch{throw refuse('Deploy refuses the local-only key file .rer/local/models.json. Remove live-dev credentials before deployment.');}}
40
42
  const config=JSON.parse(await readFile(join(root,'deploy.json'),'utf8'));
41
43
  if(!(config.platforms??['workers']).includes('container'))throw refuse('This seed does not declare container support.');
42
44
  const name='rer-local-'+createHash('sha256').update(root).digest('hex').slice(0,16),image=name+':candidate';
43
45
  if(options.stop){await execute('docker',['stop','-t','10',name]);return{stopped:true};}
44
46
  if(['build','deploy'].includes(options.verb)){
45
- if(options.verb==='deploy'){if(!options.host)throw missing('Container deploy requires --host ssh://user@host.');sshTarget(options.host);await deployInputs({root,envFile:options.envFile,localOnlyKeys:project.adapter?.localOnlyKeys});}
47
+ if(options.verb==='deploy'){if(!options.host)throw missing('Container deploy requires --host ssh://user@host.');sshTarget(options.host);const production=await deployInputs({root,envFile:options.envFile,localOnlyKeys:project.adapter?.localOnlyKeys});
48
+ const {loadInstallerSeed}=await shared('setup-manifest.mjs');
49
+ const setupSeed=project.adapter?.setup?await loadInstallerSeed(root,project.adapter):undefined;
50
+ await requireProductionAuth({root,declaration:config,env:production.settings,setupManifest:setupSeed?.manifest,setupSeed,adapter:project.adapter,options});}
46
51
  const ingress={...(options.bindAddress?{address:options.bindAddress}:{}),...(options.httpPort?{httpPort:options.httpPort}:{}),...(options.httpsPort?{httpsPort:options.httpsPort}:{})};
47
52
  ingressBindings({...config.container?.ingress,...ingress});
48
53
  if(!options.image){await imageFolder(project,operation,config);await run('docker',['build','--tag',image,join(root,'.rer/container/image')],{cwd:root});}
package/cli/contract.mjs CHANGED
@@ -6,15 +6,14 @@ export const commonFlags = ['--help', '--cwd', '--non-interactive', '--json'];
6
6
  const definitions = {
7
7
  install: [[], 'Frozen dependency installation; no setup or global tool changes.'],
8
8
  setup: [['--owner-email', '--owner-name', '--port', '--host', '--answers', '--door'], 'Build, migrate, prepare private settings and first owner; stop the temporary app. --door sets a fresh checkout up at its front-door origin http://NAME.localhost:PORT (after rer door enable).'],
9
- dev: [['--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--as', '--login', '--models', '--models-service', '--door', '--direct', '--demo'], 'Development with assets, HMR and the declared scheduled triggers run locally on their schedule. --detach returns once ready; --foreground keeps this command serving. With devIdentity it opens signed in as the owner (--as PERSONA picks another start, --login uses the outbox sign-in instead); otherwise ordinary owner sign-in through the outbox. --door moves this checkout to its front-door origin http://NAME.localhost:PORT, keeping its data; --direct moves it back; --port and --host serve directly. --demo (or rer demo) serves a throwaway demo: fresh data in .rer/demo/START (deleted when it stops: --stop, Ctrl-C or its end, one hour by default or --idle-timeout), the saved owner signed in, the seed\'s demo data, a Demo bar, and nothing sent (RER_DEMO=1; the checkout\'s own data is never touched).'],
9
+ dev: [['--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--as', '--login', '--models', '--models-service', '--door', '--direct', '--demo'], 'Development with assets, HMR and the declared scheduled triggers run locally on their schedule. --detach returns once ready; --foreground keeps this command serving. With devIdentity it opens signed in as the owner; --as PERSONA picks another start. The legacy --login flag is accepted and uses the same automatic sign-in. --door moves this checkout to its front-door origin http://NAME.localhost:PORT, keeping its data; --direct moves it back; --port and --host serve directly. --demo (or rer demo) serves a throwaway demo: fresh data in .rer/demo/START (deleted when it stops: --stop, Ctrl-C or its end, one hour by default or --idle-timeout), the saved owner signed in, the seed\'s demo data, Demo in the app name and title, real public reads/checks and simulated external writes (RER_DEMO=1; the checkout\'s own data is never touched).'],
10
10
  preview: [['--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground'], 'Production output; --detach returns once ready, --foreground keeps this command serving. Reuse intact build, refresh changed assets, preserve owner/state, idle timeout and explicit stop.'],
11
11
  build: [['--site'], 'Production build with private local settings excluded and restored. --site instead writes the static run site (homepage, /run, docs) to its declared folder and prints that folder.'],
12
12
  verify: [[], 'Run the complete internal verification target.'],
13
13
  reset: [['--yes'], 'Confirmed removal of the declared local inventory only.'],
14
- deploy: [['--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret'], 'Owner-account deployment and health; dry run performs local validation/build only. 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. After a healthy deploy rer claims the setup owner on the hosted app with the one-time setup token, then removes the token. --set-secret NAME (value from the environment or --env-file) and --unset-secret NAME change one secret of the deployed Worker without a build and record its new version. --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 container of this seed that can send nothing; --dry-run writes it to .rer/demo-host with no provider request; --demo --remove --yes deletes that demo (its Worker, demo.<domain> Custom Domain and Container application, 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.'],
14
+ deploy: [['--environment', '--dry-run', '--site', '--demo', '--host', '--env-file', '--image', '--bind-address', '--http-port', '--https-port', '--remove', '--yes', '--set-secret', '--unset-secret'], 'Owner-account deployment and health; dry run performs local validation/build only. 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. After a healthy deploy rer claims the setup owner on the hosted app with the one-time setup token, then removes the token. --set-secret NAME (value from the environment or --env-file) and --unset-secret NAME change one secret of the deployed Worker without a build and record its new version. --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 container 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 and Container application, 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
15
  export: [['--target', '--output', '--origin', '--session-file'], 'Complete supported installation archive with integrity and exclusions.'],
16
16
  import: [['--target', '--input', '--journal', '--origin', '--session-file', '--yes', '--legacy-v1', '--acknowledge-unverified-metadata', '--output'], '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.'],
17
- outbox: [['--port', '--host', '--owner-email', '--open'], 'Credential-free local outbox URL; optional ordinary sign-in request and explicit browser opening.'],
18
17
  doctor: [[], 'Read-only installed tool, configuration and state diagnostics.'],
19
18
  describe: [[], 'Read-only description of actual command capabilities.'],
20
19
  check: [['--profile'], 'Read-only structural command contract and operations validation.'],
@@ -22,7 +21,10 @@ const definitions = {
22
21
  export const verbs = Object.fromEntries(Object.entries(definitions).map(([name, [flags, effects]]) => [name, { flags: [...commonFlags, ...flags, ...(['build','deploy','dev','preview','export','import'].includes(name)?['--platform']:[]), ...(['install','setup','dev','preview','build','verify','deploy','export','import'].includes(name)?['--no-queue']:[])], effects }]));
23
22
  // `rer demo` is `rer dev --demo`; describe lists it as a verb with the dev
24
23
  // flags a demo takes whenever the seed's dev takes --demo.
25
- export const demoVerb = Object.freeze({ flags: [...commonFlags, '--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--no-queue'], effects: 'A throwaway demo of this seed (rer dev --demo): fresh data in .rer/demo/START (deleted when it stops: --stop, Ctrl-C or its end, one hour by default or --idle-timeout), the saved owner signed in, the seed\'s demo data, a Demo bar, and nothing sent (RER_DEMO=1; the checkout\'s own data is never touched).' });
24
+ export const demoVerb = Object.freeze({ flags: [...commonFlags, '--port', '--host', '--idle-timeout', '--stop', '--detach', '--foreground', '--no-queue'], effects: 'A throwaway demo of this seed (rer dev --demo): fresh data in .rer/demo/START (deleted when it stops: --stop, Ctrl-C or its end, one hour by default or --idle-timeout), the saved owner signed in, the seed\'s demo data, Demo in the app name and title, real public reads/checks and simulated external writes (RER_DEMO=1; the checkout\'s own data is never touched).' });
25
+ // `rer signin` is rer's own, not a seed operation: any seed rer deploys, it can
26
+ // sign the owner in to, so no seed declares it and check does not ask for it.
27
+ export const signinVerb = Object.freeze({ flags: [...commonFlags, '--environment', '--env-file'], effects: 'A one-time sign-in link for the hosted owner, without mail. Uses the Cloudflare credentials that deployed --environment (default production; from the environment or --env-file) to write a single-use grant for the recorded owner into that deployment\'s auth database, then prints the link once to this terminal; it is never saved. The link works once, only for that owner, expires within 15 minutes, and its use is recorded in the owner\'s audit log. Signed in this way, the owner can correct a wrong email in settings.' });
26
28
  export const aliases = Object.fromEntries([...Object.keys(verbs).filter(v => v !== 'install'), 'release', 'deps', 'rer'].map(name => [name, name === 'deps' ? 'install' : name === 'rer' ? null : name]));
27
29
  export const releaseFlags = ['--repo', '--project', '--repository', '--output', '--ref', '--dry-run', '--tag', '--clean-history', '--onto', '--env-file', '--no-queue'];
28
30
  export const requiredHooks = ['preview', 'dependencies', 'build', 'migrate', 'start', 'health', 'owner', 'signIn', 'verify', 'deploy', 'portability', 'state', 'settings', 'input'];
@@ -0,0 +1,36 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { validateDeclarations } from '../modules/delivery-producer/declarations.mjs';
3
+ import { contained } from './project.mjs';
4
+
5
+ // Source policy and its committed integration projection. Inspect declarations
6
+ // without requiring a build or executing the seed's packaging code.
7
+ const sources = [
8
+ ['rer-packaging.json', value => value?.artifact?.specInputs],
9
+ ['packaging.json', value => value?.artifact?.specInputs],
10
+ ['scripts/delivery/base/packaging.json', value => value?.artifact?.specInputs],
11
+ ['management/integration/deployment-spec.json', value => value],
12
+ ];
13
+
14
+ export async function deliveryDeclarationClauses(root) {
15
+ const clauses = [];
16
+ for (const [path, select] of sources) {
17
+ let text;
18
+ try { text = await readFile(await contained(root, path, { optional: true }), 'utf8'); }
19
+ catch (error) {
20
+ if (error.code === 'ENOENT') continue;
21
+ clauses.push({ id: `delivery.declarations.${path}`, ok: false, message: `Restore a readable contained declaration at ${path}.` });
22
+ continue;
23
+ }
24
+ const clause = { id: `delivery.declarations.${path}`, ok: true };
25
+ let value;
26
+ try { value = JSON.parse(text); }
27
+ catch { clause.ok = false; clause.message = `${path}: invalid JSON declaration.`; }
28
+ if (clause.ok) {
29
+ const spec = select(value);
30
+ if (spec !== undefined) try { validateDeclarations(spec); }
31
+ catch (error) { clause.ok = false; clause.message = `${path}: ${error.message}`; }
32
+ }
33
+ clauses.push(clause);
34
+ }
35
+ return clauses;
36
+ }
package/cli/demo-host.mjs CHANGED
@@ -31,9 +31,9 @@ export async function demoHostCommand(project, options, store, signal, out, oper
31
31
  await prepareDemoImage(join(folder, 'image'));
32
32
  for (const file of DEMO_FILES) await cp(new URL(`../modules/demo-host/${file}`, import.meta.url), join(folder, file));
33
33
  await writeFile(join(folder, 'wrangler.json'), JSON.stringify(plan.wrangler, null, 2) + '\n');
34
- const summary = { worker: plan.worker, origin: plan.origin, hostname: plan.hostname, folder: '.rer/demo-host', maxInstances: plan.maxInstances, settings: plan.settings, instanceType: plan.instanceType, startsPerIpPerMinute: 3, minutes: 60, idleMinutes: 15, enableInternet: false };
34
+ const summary = { worker: plan.worker, origin: plan.origin, hostname: plan.hostname, folder: '.rer/demo-host', maxInstances: plan.maxInstances, settings: plan.settings, instanceType: plan.instanceType, startsPerIpPerMinute: 3, minutes: 60, idleMinutes: 15, enableInternet: true };
35
35
  const human = [`Demo plan: Worker ${summary.worker} on ${summary.hostname} (custom domain; workers.dev off), written to ${summary.folder}`,
36
- ` one container per visitor (${summary.instanceType}, at most ${summary.maxInstances} at once, no internet, RER_DEMO=1), 3 starts per IP per minute behind Turnstile`,
36
+ ` one container per visitor (${summary.instanceType}, at most ${summary.maxInstances} at once, public internet, RER_DEMO=1), 3 starts per IP per minute behind Turnstile`,
37
37
  ` each demo ends after 60 minutes or 15 idle minutes; its container is destroyed and its state deleted`];
38
38
  if (options.dryRun) {
39
39
  if (options.json) out.event('demo', summary); else for (const line of human) out.human(line);
package/cli/demo.mjs CHANGED
@@ -1,12 +1,23 @@
1
1
  import { readdir, readFile, rm } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { DatabaseSync } from 'node:sqlite';
4
- import { refuse } from './errors.mjs';
4
+ import { missing, refuse } from './errors.mjs';
5
5
  import { shared } from './shared.mjs';
6
+ import { requiredLocalSettings } from './settings.mjs';
6
7
 
7
8
  // `rer demo` (dev --demo) state and its two adoption checks (export/DEMO.md).
8
9
  const adopt = 'See DEMO.md: a seed adopts demo mode with src/demo.ts, withDemo as the first import of its Worker entry, and three vite.config changes.';
9
10
 
11
+ // Owner-data prerequisites belong to dev/preview. Older adapters ignore a demo
12
+ // flag and open the owner's SQLite even for a refused start (rewriting -shm).
13
+ // Check only saved configuration here; migrations and owner bootstrap are
14
+ // verified by starting the application against its fresh demo state.
15
+ export async function demoPreflight(project, vars, seconds) {
16
+ if (requiredLocalSettings(project, vars).length) throw missing('Private owner settings are missing. Run rer setup first.');
17
+ await demoAdopted(project.root);
18
+ return demoState(project.root, seconds);
19
+ }
20
+
10
21
  // Before anything starts: the seed's Vite persists where rer says, so the
11
22
  // checkout's own .wrangler/state is never opened by a demo, and hands the
12
23
  // Worker's cloudflare:sockets imports demo mode's guarded connect.
@@ -16,12 +27,12 @@ export async function demoAdopted(root) {
16
27
  try { text = await readFile(join(root, name), 'utf8'); break; } catch (error) { if (error.code !== 'ENOENT') throw error; }
17
28
  }
18
29
  if (!text.includes('RER_STATE_DIR')) throw refuse(`This seed's vite.config does not persist to RER_STATE_DIR, so a demo would run on this checkout's own data. ${adopt}`);
19
- if (!text.includes('demoSockets(')) throw refuse(`This seed's vite.config does not list demoSockets(), so a demo's cloudflare:sockets connections could leave this computer. ${adopt}`);
30
+ if (!text.includes('demoSockets(')) throw refuse(`This seed's vite.config does not list demoSockets(), so direct mail transports would not pass through the demo effect guard. ${adopt}`);
20
31
  }
21
32
 
22
33
  // A demo's data lives in .rer/demo/START. Only one server runs per checkout, so
23
34
  // any other demo folder is a stopped demo's leftover (a hard kill) and goes now.
24
- // The end is local ISO time with its offset: the Demo bar shows its HH:MM as written.
35
+ // The end is local ISO time with its offset, also returned in readiness metadata.
25
36
  export async function demoState(root, seconds) {
26
37
  const { privateDirectory } = await shared('private-files.mjs');
27
38
  const started = new Date(), stamp = started.toISOString().replace(/[-:]|\.\d+/g, '');
@@ -34,7 +45,7 @@ export async function demoState(root, seconds) {
34
45
  }
35
46
 
36
47
  // After start: a request has passed withDemo, which creates rer_demo in the
37
- // demo's own database. Without it nothing is blocked, so the demo stops.
48
+ // demo's own database. Without it effect simulation is unproved, so the demo stops.
38
49
  export async function demoGuarded(url, state, signal) {
39
50
  const { appFetch } = await shared('app-fetch.mjs');
40
51
  await (await appFetch(url + '/health', { signal })).body?.cancel();
@@ -43,5 +54,5 @@ export async function demoGuarded(url, state, signal) {
43
54
  const db = new DatabaseSync(join(directory, file), { readOnly: true });
44
55
  try { if (db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'rer_demo'").get()) return; } finally { db.close(); }
45
56
  }
46
- throw refuse(`The app did not start in demo mode (no withDemo guard answered), so it could send. The demo was stopped and its data deleted. ${adopt}`);
57
+ throw refuse(`The app did not start in demo mode (no withDemo guard answered), so external writes might run for real. The demo was stopped and its data deleted. ${adopt}`);
47
58
  }
@@ -1,3 +1,4 @@
1
+ import { requireProductionAuth } from './production-auth.mjs';
1
2
  import { observedReadiness } from '../modules/deploy-kit/readiness-window.mjs';
2
3
  import { readFile, readdir } from 'node:fs/promises';
3
4
  import { contained } from './project.mjs';
@@ -25,7 +26,7 @@ export function validateDeployOptions(options) {
25
26
 
26
27
  // An explicit adapter declaration wins. Older hooks use a conventional root
27
28
  // declaration; discover it by its schema, never by seed identity or hook source.
28
- async function declarationFor(root, adapter) {
29
+ export async function declarationFor(root, adapter) {
29
30
  const declared = adapter.deployDeclaration ?? adapter.deploy?.declaration;
30
31
  const paths = declared ? [declared] : (await readdir(root)).filter(path => path.endsWith('.json') && path !== adapter.site?.declaration);
31
32
  const matches = [];
@@ -62,6 +63,8 @@ export async function deployCommand(context) {
62
63
  // may perform them; neither a build nor a custom upload runs here.
63
64
  if (options.remove || options.setSecret || options.unsetSecret) return ownerDeploy(path, adapter)(context);
64
65
  if (adapter.deploy.managesHostedOwner) return adapter.deploy(context);
66
+ const production = await deployEnvironment({ root, options, declaration, setupManifest, settings: adapter.settings, localOnlyKeys });
67
+ await requireProductionAuth({ root, declaration, env: production.env, setupManifest, setupSeed: context.setupSeed, adapter, declarationPath: path, options });
65
68
  const sourceSha = options.dryRun ? undefined : committedSource(root, options);
66
69
  const { env, supplied } = await deployEnvironment({ root, options, declaration, setupManifest, settings: adapter.settings, localOnlyKeys });
67
70
  const { createRedaction, credentialValues } = await shared('redaction.mjs');
package/cli/deploy.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { requireProductionAuth } from './production-auth.mjs';
1
2
  import { readFile } from 'node:fs/promises';
2
3
  import { deployDiagnostic } from '../modules/deploy-kit/diagnostics.mjs';
3
4
  import { shared } from './shared.mjs';
@@ -15,7 +16,7 @@ import { hookState, forgetHookState } from './deploy-hook-record.mjs';
15
16
 
16
17
  export function ownerDeploy(declarationPath, lifecycle) {
17
18
  // rer verify serves the build with this declaration's vars and secrets.
18
- return Object.assign(async ({ root, options, store, signal, operationToken, localOnlyKeys = [], checkBuild = async () => {}, setupManifest, linkDependencies }) => {
19
+ return Object.assign(async ({ root, options, store, signal, operationToken, localOnlyKeys = [], checkBuild = async () => {}, setupManifest, setupSeed, linkDependencies }) => {
19
20
  try { await refuseLocalModels(root); } catch { throw refuse('Deploy refuses the local-only key file .rer/local/models.json. Remove live-dev credentials before deployment.'); }
20
21
  const path = await contained(root, declarationPath);
21
22
  let declaration; try { declaration = JSON.parse(await readFile(path, 'utf8')); } catch { throw invalid('Malformed owner-account deploy declaration.'); }
@@ -31,6 +32,8 @@ export function ownerDeploy(declarationPath, lifecycle) {
31
32
  // A dry run reads the settings file too, so a refused key fails here and not only on the real deploy.
32
33
  if (options.dryRun && options.envFile) await deployEnvironment({ root, options, declaration, localOnlyKeys });
33
34
  if (!change.length) {
35
+ const production = await deployEnvironment({ root, options, declaration, setupManifest, settings: lifecycle.settings, localOnlyKeys });
36
+ await requireProductionAuth({ root, declaration, env: production.env, setupManifest, setupSeed, adapter: lifecycle, declarationPath, options });
34
37
  if (!options.dryRun) committedSource(root, options);
35
38
  await lifecycle.run(root, {}, store, () => {}, signal, { verb: 'build', operationToken });
36
39
  await checkBuild();
@@ -34,8 +34,8 @@ export async function detachedServer(options, argv, out) {
34
34
  if (event.event==='error') failure=event;
35
35
  if (event.event==='ready') {
36
36
  keep=true;child.unref();
37
- const dev = event.openUrl ? {openUrl:event.openUrl,identity:options.verb === 'dev' && !options.login,signedInAs:event.signedInAs,ownerLeft:options.verb === 'dev' && !options.login && event.signedInAs === null} : undefined;
38
- ready(out,event.url,dev,options.json,Boolean(event.signInUrl),event.siteUrl,event.demo);
37
+ const dev = event.openUrl ? {openUrl:event.openUrl,identity:options.verb === 'dev',signedInAs:event.signedInAs,ownerLeft:options.verb === 'dev' && event.signedInAs === null} : undefined;
38
+ ready(out,event.url,dev,options.json,event.siteUrl,event.demo);
39
39
  return 0;
40
40
  }
41
41
  if (event.event==='waiting' || event.event==='warning') out.event(event.event,event);
@@ -52,7 +52,7 @@ export function refuseManagedInstallation(...sources) {
52
52
  for (const vars of sources) {
53
53
  if (!vars?.RER_INSTALLATION_ID || !vars.RER_MANAGEMENT_ORIGIN) continue;
54
54
  let host; try { host = new URL(vars.RER_MANAGEMENT_ORIGIN).hostname.replace(/^\[|\]$/g, ''); } catch {}
55
- if (!loopback(host)) throw refuse('Dev identity refuses to start beside RER_INSTALLATION_ID with a non-loopback RER_MANAGEMENT_ORIGIN. Remove them from local settings or run rer dev --login.');
55
+ if (!loopback(host)) throw refuse('Dev identity refuses to start beside RER_INSTALLATION_ID with a non-loopback RER_MANAGEMENT_ORIGIN. Remove them from local settings before starting local dev identity.');
56
56
  }
57
57
  }
58
58
 
package/cli/export.mjs CHANGED
@@ -6,7 +6,7 @@ import { cliVersion } from './version.mjs';
6
6
 
7
7
  // Copy whole maintained source/tooling directories. Python publication scans
8
8
  // load sibling modules and data dynamically; they belong in the inventory too.
9
- export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
9
+ export const sourceRoots = ['bin/rer.mjs', 'cli', 'modules/delivery-producer/declarations.mjs', 'modules/delivery-producer/bindings.mjs', 'modules/job-queue', 'modules/release', 'modules/deploy-kit', 'modules/container', 'modules/demo-host', 'modules/demo', 'modules/integrations/core', 'modules/mail', 'modules/ai', 'modules/portability', 'modules/d1-transport', 'modules/erasure', 'modules/dependencies', 'modules/operator-auth', 'modules/owner-claim', 'operations', 'scripts/publish-check', 'scripts/publish-check.mjs', 'composition/git-source.mjs', 'edition-authoring/manifest.mjs', 'edition-authoring/files.mjs'];
10
10
  export async function inventory(base, roots = sourceRoots) {
11
11
  const files = [];
12
12
  async function walk(path) {
package/cli/inspect.mjs CHANGED
@@ -3,7 +3,7 @@ import { inventory } from './export.mjs';
3
3
  import { lstat, readFile } from 'node:fs/promises';
4
4
  import { createHash } from 'node:crypto';
5
5
  import { delimiter, dirname, resolve } from 'node:path';
6
- import { aliases, demoVerb, pins, requiredHooks, serverDefaults, verbs, releaseFlags } from './contract.mjs';
6
+ import { aliases, demoVerb, pins, requiredHooks, serverDefaults, signinVerb, verbs, releaseFlags } from './contract.mjs';
7
7
  import { runningVersion } from './version.mjs';
8
8
  import { contained, readPackage } from './project.mjs';
9
9
  import { shared } from './shared.mjs';
@@ -19,6 +19,7 @@ import { vendoredCalls } from './package-calls.mjs';
19
19
  import { doorProtocol } from './door.mjs';
20
20
  import { savedOrigin } from './door-mode.mjs';
21
21
  import { probePnpm } from './pnpm-probe.mjs';
22
+ import { deliveryDeclarationClauses } from './delivery-declarations.mjs';
22
23
 
23
24
  // cliVersion: the rer version of the code answering (absent for a vendored copy
24
25
  // too old to record one). defaults: what a server start applies when the person
@@ -41,9 +42,11 @@ export async function describe(project) {
41
42
  ? operationsEffects
42
43
  : verbs[verb]?.effects ?? 'Produce releases; keygen writes a public anchor and, on success, its private key to non-terminal stdout; sign writes a detached signature and prints (but does not execute) the GitHub upload command; receipt verifies against local anchors offline.';
43
44
  return [verb, { flags: (verbs[verb]?.flags ?? releaseFlags).filter(flag => capability.flags?.includes(flag)), effects }];
44
- }).concat(capabilities.dev?.flags?.includes('--demo') ? [['demo', { flags: demoVerb.flags.filter(flag => capabilities.dev.flags.includes(flag)), effects: demoVerb.effects }]] : [])),
45
+ }).concat(capabilities.dev?.flags?.includes('--demo') ? [['demo', { flags: demoVerb.flags.filter(flag => capabilities.dev.flags.includes(flag)), effects: demoVerb.effects }]] : [])
46
+ // rer signin is rer's own: any seed it can deploy, it can sign the owner in to.
47
+ .concat(capabilities.deploy ? [['signin', { flags: signinVerb.flags, effects: signinVerb.effects }]] : [])),
45
48
  aliases: Object.fromEntries(Object.entries(aliases).filter(([alias, verb]) => pkg.scripts?.[alias] === commandLine(verb, declaredPackage(pkg) !== undefined))),
46
- local: { state: project.adapter?.state, settings: project.adapter?.settings ?? [], installerState: '.seed/installer', outbox: '/__dev/outbox', ...await localState(project), origin: await savedOrigin(project), ...(project.adapter?.devIdentity ? { devIdentity: true, devKey: '.rer/local/dev-key.env' } : {}) },
49
+ local: { state: project.adapter?.state, settings: project.adapter?.settings ?? [], installerState: '.seed/installer', ...await localState(project), origin: await savedOrigin(project), ...(project.adapter?.devIdentity ? { devIdentity: true, devKey: '.rer/local/dev-key.env' } : {}) },
47
50
  // This pin serves a checkout through the machine's front door (rer door).
48
51
  door: { protocol: doorProtocol },
49
52
  };
@@ -69,6 +72,7 @@ async function localState(project) {
69
72
 
70
73
  export async function check(project, explicitProfile) {
71
74
  const clauses = [], add = (id, ok, message) => clauses.push({ id, ok: Boolean(ok), ...(!ok ? { message } : {}) });
75
+ clauses.push(...await deliveryDeclarationClauses(project.root));
72
76
  for (const command of project.commands) add('SC-10.inputs.' + command.name, command.available, `Restore the declared inputs for ${command.name}.`);
73
77
  for (const loop of project.descriptor.loops ?? []) add('SC-10.loop.' + loop.id, !loop.required || loop.enabled, `Enable the required ${loop.id} loop or correct its declaration.`);
74
78
  if (project.profile === 'first-party' || explicitProfile === 'first-party') {
@@ -156,14 +160,15 @@ export async function doctor(project, store, signal) {
156
160
  const { inspectOperations } = await import('../operations/operations.mjs');
157
161
  const diagnostic = await inspectOperations(project.root);
158
162
  const { localVariables } = await shared('local/environment.mjs');
159
- let values = {}, pnpm, expectedPnpm, pnpmIssue, stateValid = true;
163
+ let values = {}, pnpm, expectedPnpm, stateIssue, stateValid = true;
164
+ const pnpmIssues = [];
160
165
  if (project.profile === 'first-party') {
161
166
  try { expectedPnpm = await (await import('./project-pnpm.mjs')).projectPnpmPin(project.root); }
162
- catch (error) { pnpmIssue = error.message; }
167
+ catch (error) { pnpmIssues.push(store.redact(error.message)); }
163
168
  }
164
169
  if (project.profile === 'first-party') {
165
170
  const { selectLocalState } = await shared('local/state.mjs');
166
- try { await selectLocalState(project.root, project.adapter.state); } catch { stateValid = false; }
171
+ try { await selectLocalState(project.root, project.adapter.state); } catch (error) { stateValid = false; stateIssue = store.redact(error.message); }
167
172
  }
168
173
  if (project.profile === 'first-party') {
169
174
  try {
@@ -173,30 +178,29 @@ export async function doctor(project, store, signal) {
173
178
  const parsed = settings.format === 'json' ? JSON.parse(text) : localVariables(text);
174
179
  if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) values = parsed;
175
180
  } catch {}
176
- try { pnpm = await probePnpm(project.root, store, signal); } catch (error) { if (signal?.aborted) throw error; }
181
+ try { pnpm = await probePnpm(project.root, store, signal); } catch (error) { if (signal?.aborted) throw error; pnpmIssues.push(store.redact(error.message)); }
177
182
  // A pnpm rer already provides counts; doctor never fetches one.
178
183
  if (expectedPnpm && pnpm !== expectedPnpm) {
179
184
  const directory = await (await import('./pnpm-runtime.mjs')).cachedPnpm(expectedPnpm).catch(() => undefined);
180
- if (directory) { usePnpm(directory); try { pnpm = await probePnpm(project.root, store, signal); } catch (error) { if (signal?.aborted) throw error; } }
185
+ if (directory) { usePnpm(directory); try { pnpm = await probePnpm(project.root, store, signal); pnpmIssues.length = 0; } catch (error) { if (signal?.aborted) throw error; pnpmIssues.push(store.redact(error.message)); } }
181
186
  }
182
187
  }
183
188
  const aiIssues = await localAiDiagnostics(project,process.env);
184
189
  const dependencies=project.profile==='first-party'?await dependencyDoctor(project.root):[];
185
190
  const expectedNode = await projectNodePin(project.root);
186
- const keys = localSettingKeys(project);
187
191
  const inputs = project.profile === 'first-party' ? requiredLocalSettings(project, values) : [];
188
192
  const warnings = project.profile === 'first-party' ? await cacheWarnings(project.root) : [];
189
- return { dependencies, warnings, ok: !aiIssues.length && dependencies.every(d=>d.ok) && diagnostic.ok && stateValid && !inputs.length && (project.profile !== 'first-party' || (Boolean(expectedPnpm) && process.versions.node === expectedNode && pnpm === expectedPnpm)),
193
+ return { dependencies, warnings, operations: diagnostic, ok: !aiIssues.length && dependencies.every(d=>d.ok) && diagnostic.ok && stateValid && !inputs.length && (project.profile !== 'first-party' || (Boolean(expectedPnpm) && process.versions.node === expectedNode && pnpm === expectedPnpm)),
190
194
  node: { actual: process.versions.node, expected: expectedNode },
191
- pnpm: project.profile === 'first-party' ? { actual: pnpm, expected: expectedPnpm ?? null, ...(pnpmIssue ? { issue: pnpmIssue } : {}) } : undefined,
195
+ pnpm: project.profile === 'first-party' ? { actual: pnpm, expected: expectedPnpm ?? null, ...(pnpmIssues.length ? { issue: [...new Set(pnpmIssues)].join('\n') } : {}) } : undefined,
192
196
  ai: { issues: aiIssues },
193
197
  missingInputs: [...new Set([...diagnostic.missingEnvironment, ...inputs])],
194
- sources: project.descriptor.environmentSources ?? {}, state: { path: project.adapter?.state, safe: stateValid }, scope: 'local-inputs-only' };
198
+ sources: project.descriptor.environmentSources ?? {}, state: { path: project.adapter?.state, safe: stateValid, ...(stateIssue ? { issue: stateIssue } : {}) }, scope: 'local-inputs-only' };
195
199
  }
196
200
 
197
201
  // SC-05: a seed declaring devIdentity loads the dev layer only from a local-only
198
202
  // entry that its dev configuration names, never from the deployed main, lets
199
- // rer build scan its output, and keeps one end-to-end email-link test.
203
+ // rer build scan its output.
200
204
  async function devIdentityClauses(root, adapter) {
201
205
  const declaration = adapter.devIdentity;
202
206
  const text = async path => { try { return await readFile(await contained(root, path), 'utf8'); } catch { return null; } };
@@ -204,10 +208,8 @@ async function devIdentityClauses(root, adapter) {
204
208
  const main = await deployedMain(root, adapter);
205
209
  const production = main ? await text(main) : null;
206
210
  const configs = (await Promise.all(['vite.config.ts', 'vite.config.mts', 'vite.config.js', 'vite.config.mjs', 'wrangler.local.jsonc', 'wrangler.local.json', 'wrangler.local.toml'].map(text))).filter(Boolean);
207
- const test = typeof declaration.emailLinkTest === 'string' ? await text(declaration.emailLinkTest) : null;
208
211
  return [
209
212
  ['SC-05.dev-identity.entry', entry && await text(entry) !== null && entry !== main && configs.some(config => config.includes(entry)), 'Declare devIdentity.entry as an existing local-only Worker entry that the local Vite or wrangler configuration loads and that is not the deployed main.'],
210
213
  ['SC-05.dev-identity.exclusion', production !== null && !/operator-auth\/dev\//.test(production) && !production.includes(entry.replace(/\.[a-z]+$/, '')) && Array.isArray(declaration.output) && declaration.output.length > 0, 'Keep the deployed main free of the dev layer and its local entry, and declare devIdentity.output so rer build refuses output containing the dev layer.'],
211
- ['SC-05.dev-identity.email-link-test', test !== null && /outbox/i.test(test), 'Keep one end-to-end email-link test through the outbox and declare it as devIdentity.emailLinkTest.'],
212
214
  ];
213
215
  }