@jskit-ai/agent-docs 0.1.340 → 0.1.342

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 (53) hide show
  1. package/guide/agent/app-setup/authentication.md +5 -5
  2. package/guide/agent/app-setup/database-layer.md +56 -6
  3. package/guide/agent/app-setup/multi-homing.md +3 -3
  4. package/guide/agent/app-setup/run-an-accounts-hub.md +9 -9
  5. package/guide/agent/app-setup/sign-in-through-oidc-issuer.md +8 -6
  6. package/guide/agent/app-setup/upgrading-jskit.md +52 -4
  7. package/guide/agent/framework/environments.md +21 -9
  8. package/guide/agent/framework/sanity-checks.md +11 -11
  9. package/guide/agent/framework/security-pass.md +12 -12
  10. package/package.json +1 -1
  11. package/patterns/feature-package/example/booking-engine/package.json +1 -1
  12. package/patterns/minimal-foundation/example/package.json +3 -3
  13. package/patterns/shell-foundation/example/package.json +4 -4
  14. package/patterns/shell-foundation/example/packages/main/package.json +1 -1
  15. package/reference/autogen/KERNEL_MAP.md +1 -1
  16. package/reference/autogen/PATTERN_INDEX.md +38 -38
  17. package/reference/autogen/packages/assistant-runtime.md +12 -0
  18. package/reference/autogen/packages/auth-provider-local-core.md +8 -8
  19. package/reference/autogen/packages/auth-provider-local-db-core.md +20 -0
  20. package/reference/autogen/packages/auth-provider-oidc-core.md +5 -1
  21. package/reference/autogen/packages/auth-provider-supabase-core.md +2 -2
  22. package/reference/autogen/packages/console-core.md +4 -0
  23. package/reference/autogen/packages/database-runtime.md +15 -0
  24. package/reference/autogen/packages/kernel.md +2 -1
  25. package/reference/autogen/packages/oidc-issuer-core.md +7 -3
  26. package/reference/autogen/packages/rewarded-core.md +16 -0
  27. package/reference/autogen/packages/users-core.md +4 -0
  28. package/reference/autogen/packages/workspaces-core.md +4 -0
  29. package/skills/jskit/references/database-layer.md +56 -6
  30. package/skills/jskit/references/environments.md +21 -9
  31. package/skills/jskit/references/multi-homing.md +3 -3
  32. package/skills/jskit/references/pattern-index.md +38 -38
  33. package/skills/jskit/references/patterns/app/minimal-foundation/example/package.json +3 -3
  34. package/skills/jskit/references/patterns/app/shell-foundation/example/package.json +4 -4
  35. package/skills/jskit/references/patterns/app/shell-foundation/example/packages/main/package.json +1 -1
  36. package/skills/jskit/references/patterns/auth/accounts-hub/PATTERN.md +2 -2
  37. package/skills/jskit/references/patterns/auth/accounts-hub/example/package.json +3 -3
  38. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/.env.example +1 -1
  39. package/skills/jskit/references/patterns/auth/oidc-sign-in/example/package.json +2 -2
  40. package/skills/jskit/references/patterns/auth/supabase-auth/example/package.json +1 -1
  41. package/skills/jskit/references/patterns/connectors/calendar-cli/example/package.json +5 -5
  42. package/skills/jskit/references/patterns/connectors/event-delivery/PATTERN.md +1 -1
  43. package/skills/jskit/references/patterns/crud/crud-feature-package/example/packages/books/package.json +3 -3
  44. package/skills/jskit/references/patterns/database/mysql-application/PATTERN.md +3 -3
  45. package/skills/jskit/references/patterns/database/mysql-application/example/package.json +2 -2
  46. package/skills/jskit/references/patterns/database/postgres-application/example/package.json +2 -2
  47. package/skills/jskit/references/patterns/realtime/realtime-application/PATTERN.md +2 -2
  48. package/skills/jskit/references/patterns/realtime/realtime-application/example/package.json +2 -2
  49. package/skills/jskit/references/patterns/server/feature-package/example/booking-engine/package.json +1 -1
  50. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users/package.json +3 -3
  51. package/skills/jskit/references/patterns/users/user-administration-server/example/packages/users-workspace/package.json +6 -6
  52. package/skills/jskit/references/sanity-checks.md +11 -11
  53. package/skills/jskit/references/security-pass.md +12 -12
@@ -327,7 +327,7 @@ Two registrations whose email is already proven sign in at once instead: one
327
327
  through an invitation that a feature's invitation context resolver (such as
328
328
  workspace invites) resolves, still pending, for the registering email (letter
329
329
  case aside) and before its `expiresAt`, since its link reached that address;
330
- and the first account a production server's setup code admits (see below). An
330
+ and the first account a staging or production server's setup code admits (see below). An
331
331
  invitation passed through as given, with no resolver installed, or whose
332
332
  context names no email, proves nothing. Any other registration keeps waiting,
333
333
  with no account, profile or session, and answers
@@ -525,7 +525,7 @@ and treat null as a refused link. Their types are `AuthLocalAccounts`,
525
525
  `AuthLocalSessions` and `AuthLocalRecovery` in
526
526
  `@jskit-ai/auth-provider-local-db-core/server/types`.
527
527
 
528
- ## The first account in production (local auth)
528
+ ## The first account in staging and production (local auth)
529
529
 
530
530
  The first account to register becomes the application's owner, so on a
531
531
  staging or production server (`APP_ENV`) whose local auth has no account yet,
@@ -558,7 +558,7 @@ account is set up, since each server makes its own code.
558
558
 
559
559
  A hosting tool that shows the code to the operator itself supplies it in
560
560
  `AUTH_LOCAL_SETUP_CODE`, at least 20 letters and digits, for example a
561
- generated production secret. The server then asks for that code at every start
561
+ secret it generates for that server. The server then asks for that code at every start
562
562
  and on every server, writes no `first-account-setup-code` file, and logs only
563
563
  that the code is in `AUTH_LOCAL_SETUP_CODE`, never the code itself. In
564
564
  development and test the variable is ignored.
@@ -742,7 +742,7 @@ For direct library composition, pass the same function as `recoverySender` to
742
742
 
743
743
  Set `APP_PUBLIC_URL` to the application's actual public URL. When a sender is
744
744
  configured, auth requires this value and does not return or log the recovery
745
- URL. Without a sender, production recovery is disabled; explicit development
745
+ URL. Without a sender, staging and production have no recovery; explicit development
746
746
  output remains available for local testing. A sender failure never falls back
747
747
  to development output. The generic recovery delivery capability is `email`.
748
748
 
@@ -863,7 +863,7 @@ Security behavior:
863
863
  - The authorization-code flow uses PKCE (`S256`) and `state`, plus `nonce` for
864
864
  OpenID Connect. The attempt is stored server-side, in the file store or the
865
865
  `auth_local_oauth_attempts` table, under the hash of a random httpOnly
866
- `jskit_local_oauth_attempt` cookie (`__Host-` in production, SameSite from
866
+ `jskit_local_oauth_attempt` cookie (`__Host-` in staging and production, SameSite from
867
867
  `AUTH_COOKIE_SAME_SITE`; see
868
868
  [Sign-in cookies and SameSite](#sign-in-cookies-and-samesite)), so it
869
869
  completes only in the starting browser and works across several servers. It
@@ -99,9 +99,9 @@ The application owns normal npm scripts:
99
99
  application and installed-package migration directories, connects using the
100
100
  environment, and applies pending migrations.
101
101
 
102
- Deployment or a managed development environment may invoke this app-owned
103
- script as a release step. JSKIT itself does not maintain a background migration
104
- service.
102
+ A staging or production server's release, or a managed development
103
+ environment, may run this app-owned script as a release step. JSKIT itself does
104
+ not maintain a background migration service.
105
105
 
106
106
  ## Authoring schema changes
107
107
 
@@ -244,6 +244,54 @@ relocation must retain its basename and be checked against both fresh and
244
244
  existing ledgers. Never drop valuable data or delete ledger entries to force
245
245
  a replay.
246
246
 
247
+ ### A new table takes the collation of the tables already there
248
+
249
+ MySQL and MariaDB create a table that names no character set or collation in
250
+ the database's default. A dump restored onto a server with another default
251
+ keeps each table's collation but takes the new database default, so a later
252
+ migration's new table no longer matches the tables it joins: comparing their
253
+ text fails with "Illegal mix of collations", and a foreign key between them is
254
+ refused (errno 150, "Foreign key constraint is incorrectly formed"). Up to
255
+ `@jskit-ai/jskit-catalog` 0.2.93, `auth_local_db_users_second_factors.cjs` failed
256
+ that way on such a database: it left an empty, unrecorded
257
+ `auth_local_second_factors` behind, and the migrations before it had recorded
258
+ their new tables in the new default, such as `auth_local_used_passes`.
259
+
260
+ Every JSKIT package migration that creates a table now creates it in the
261
+ collation of the existing tables, read from `information_schema`. Released
262
+ migrations stay as they are: each has a companion, the same name with
263
+ `-collation` before `.cjs`, which Knex sorts just before it (a `-` sorts before
264
+ `.`), so it runs first on every database that has not run it. The companion
265
+ calls `migrateInExistingCollation()` from
266
+ `@jskit-ai/database-runtime/server/tableCollationMigrations`, which runs the
267
+ released migration with each table it creates in the collation of the first
268
+ existing table of its list (the package's first table, then `users`, then
269
+ `auth_local_users`), and the released migration then finds its tables in place.
270
+ On PostgreSQL and SQLite, or before any of those tables exists, it does
271
+ nothing and the released migration runs as it did.
272
+
273
+ It also repairs what the database's default left, each only in the state it
274
+ measures, and changes nothing on a database whose tables are all in place, in
275
+ that collation, with their keys:
276
+
277
+ - an empty table of a migration Knex has not recorded, without the foreign key
278
+ that migration creates with it, is what a refused key left: it is dropped
279
+ and created again; with rows, the migration stops and changes nothing;
280
+ - a table of a recorded migration in another collation is converted when no
281
+ stored character can be lost (its text is in the same character set, or one
282
+ the target holds every character of, or it has no row), and otherwise the
283
+ migration stops and changes nothing; it then gains a missing key, unless rows
284
+ have no parent.
285
+
286
+ A new migration that creates a table calls `migrateInExistingCollation()` itself,
287
+ with its own file name and its table-creating `up`, so it needs no companion.
288
+ `tooling/jskit-catalog/test/tableCollationCompanions.test.js` fails for a table
289
+ migration that does neither, and names the released ones a companion cannot
290
+ serve: `payments_core_initial.cjs` and `connectors_core_initial.cjs` create
291
+ their tables without checking whether they exist, and `agent_initial.cjs` runs
292
+ on PostgreSQL only. Never change a database's default (`ALTER DATABASE`) to
293
+ make a migration pass: an application's own tables keep theirs.
294
+
247
295
  ## Seed data is not a migration
248
296
 
249
297
  Migrations establish schema and invariant framework data. Product fixtures,
@@ -328,8 +376,10 @@ the application's `knexfile.js`:
328
376
  as many as the database user may create. With no usable `TEST_DB_NAME`
329
377
  (unset, the connected database itself, or one the database user may not
330
378
  prepare), the files run one at a time on the connected database. A copy
331
- named like the application's database or `PROD_DB_NAME`, or a server that
332
- cannot be reached, fails the run instead.
379
+ named like the application's database, `STAGING_DB_NAME` or
380
+ `PRODUCTION_DB_NAME`, or a server that cannot be reached, fails the run
381
+ instead. So does a run while `PROD_DB_NAME`, which those two replaced, is
382
+ set.
333
383
  Every file starts from the snapshot, rows included: a copy an earlier file of
334
384
  the run used is restored before the next file takes it, so no file sees what
335
385
  another wrote.
@@ -395,7 +445,7 @@ the app's `knexfile.js`) reaches that worker's copy. The copies (`<name>`, `<nam
395
445
  ([Integration test databases](#integration-test-databases)), then seeded in one
396
446
  transaction each, so stale rows never survive a run and the migrations are
397
447
  replayed only when one changes. It refuses the application's database,
398
- `PROD_DB_NAME`, `TEST_DB_NAME` and their copies.
448
+ `STAGING_DB_NAME`, `PRODUCTION_DB_NAME`, `TEST_DB_NAME` and their copies.
399
449
 
400
450
  Give disposable integration and migration tests their own `TEST_DB_NAME`;
401
451
  the two names, and their copies, must differ, and the application account
@@ -358,9 +358,9 @@ something in the application requires:
358
358
  When the server starts, JSKIT compares each role's own grants with the
359
359
  permissions the registered actions, the routes' `permission` and the surface
360
360
  access policies require. A grant that covers none of them stops the server
361
- outside production, for example `Role "member" grants "crud.labels.patch",
362
- which no action requires; did you mean "crud.labels.update"?`; in production
363
- the server starts and logs it as a warning. List a permission the application
361
+ in development and test, for example `Role "member" grants "crud.labels.patch",
362
+ which no action requires; did you mean "crud.labels.update"?`; in staging and
363
+ production the server starts and logs it as a warning. List a permission the application
364
364
  checks itself, in a service, a row policy or the browser (`access.can()`), in
365
365
  `roleCatalog.customPermissions`:
366
366
 
@@ -25,8 +25,8 @@ Use the `auth/accounts-hub` pattern for the composition rules. Apps connect with
25
25
  `OIDC_HUB_REGISTRATION_TOKEN` and, if the database is shared or kept,
26
26
  `OIDC_HUB_SECRET`. Start it, create the owner account and confirm it (the
27
27
  link is in the server log without a sender). Run the tests.
28
- 3. Production: choose the hub's own domain and set `APP_PUBLIC_URL`, a new
29
- `OIDC_HUB_SECRET`, the same registration token the apps will use, the owner
28
+ 3. Staging and production: choose each server's own hub domain and set
29
+ `APP_PUBLIC_URL`, a new `OIDC_HUB_SECRET`, the same registration token the apps will use, the owner
30
30
  email, an email sender and `OIDC_HUB_DEV_ORIGIN_PATTERNS` for the apps'
31
31
  development previews.
32
32
  4. Deploy, then sign in as the owner and follow **Setup** until every item is
@@ -58,12 +58,12 @@ ready.
58
58
 
59
59
  | Name | Required | Meaning |
60
60
  |---|---|---|
61
- | `APP_PUBLIC_URL` | production | The hub's origin, which is its issuer. https outside this computer, no path. |
62
- | `OIDC_HUB_SECRET` | production | At least 32 random bytes. Protects cookies and the stored signing keys; never change it once set. Development generates one in `.jskit/oidc-hub/secret`, so set it explicitly whenever the database outlives that folder (a hosted editor, several checkouts sharing one database). |
61
+ | `APP_PUBLIC_URL` | staging and production | The hub's origin, which is its issuer. https outside this computer, no path. |
62
+ | `OIDC_HUB_SECRET` | staging and production | At least 32 random bytes. Protects cookies and the stored signing keys; never change it once set. Development generates one in `.jskit/oidc-hub/secret`, so set it explicitly whenever the database outlives that folder (a hosted editor, several checkouts sharing one database). |
63
63
  | `OIDC_HUB_REGISTRATION_TOKEN` | yes | At least 24 characters. Apps present it to register. Give the same value to each app as `AUTH_OIDC_REGISTRATION_TOKEN`. |
64
64
  | `OIDC_HUB_OWNER_EMAIL` | yes | The owner's email. That account, once its email is confirmed, opens the admin pages. |
65
65
  | `OIDC_HUB_DEV_ORIGIN_PATTERNS` | no | Comma-separated `https://` origin globs approved automatically, for example `https://preview-*.acme.example.dev`. `*` matches inside one DNS label. Loopback is always approved. |
66
- | `OIDC_HUB_EMAIL_FROM` with `RESEND_API_KEY` or `SMTP_URL` | production | The owner's own sender. In development, without a sender, emails are written to the server log. |
66
+ | `OIDC_HUB_EMAIL_FROM` with `RESEND_API_KEY` or `SMTP_URL` | staging and production | The owner's own sender. In development, without a sender, emails are written to the server log. |
67
67
  | `OIDC_HUB_GOOGLE_CLIENT_ID` and `OIDC_HUB_GOOGLE_CLIENT_SECRET` | no | Turn on "Continue with Google". The Google redirect URI is `{APP_PUBLIC_URL}/hub/google/callback`. |
68
68
 
69
69
  Each problem stops the hub with one sentence that names the variable to fix.
@@ -133,7 +133,7 @@ npx jskit-oidc-issuer import-accounts --in accounts.jsonl --apply
133
133
  editor's preview can sign in as an existing hub account. Pass the preview
134
134
  host's protocol id with `--protocol` and each hostname pattern, besides
135
135
  loopback, that the host serves the hub on with `--local-hostname`. It works
136
- only outside production, from loopback, with
136
+ only in development and test, from loopback, with
137
137
  `AUTH_DEV_BYPASS_ENABLED` and `AUTH_DEV_BYPASS_SECRET`.
138
138
 
139
139
  ## Connecting an app
@@ -141,9 +141,9 @@ npx jskit-oidc-issuer import-accounts --in accounts.jsonl --apply
141
141
  1. Install `@jskit-ai/auth-provider-oidc-core` in the app.
142
142
  2. Give the app `AUTH_OIDC_ISSUER` (the hub's `APP_PUBLIC_URL`) and
143
143
  `AUTH_OIDC_REGISTRATION_TOKEN` (the hub's `OIDC_HUB_REGISTRATION_TOKEN`).
144
- 3. Sign in once from the app. A development address works straight away. After
145
- the app is deployed, open the hub's Apps page and approve it at its full
146
- address.
144
+ 3. Sign in once from the app. A development address works straight away. Once
145
+ the app runs on its staging or production server, open the hub's Apps page
146
+ and approve it at its full address.
147
147
 
148
148
  ## Verify
149
149
 
@@ -15,7 +15,7 @@ The pattern is `auth/oidc-sign-in`.
15
15
  1. Have the issuer's address and either a registration token (an accounts hub)
16
16
  or a client id and secret (any other issuer). Ask the person; never invent them.
17
17
  2. Install the provider and run the migration (below).
18
- 3. Set or link the Env values (below) for development and production.
18
+ 3. Set or link the Env values (below) for development, staging and production.
19
19
  4. Sign in once in development. Against a hub, a development address works at
20
20
  once when it is on this computer or matches the hub's development patterns.
21
21
  5. Deploy, then ask the hub's owner to approve the app on the hub's Apps page at
@@ -43,8 +43,8 @@ accounts first (below) if the app already has people.
43
43
  | `AUTH_OIDC_REGISTRATION_TOKEN` | Preferred. The app registers itself with the issuer, once per address. |
44
44
  | `AUTH_OIDC_CLIENT_ID` / `AUTH_OIDC_CLIENT_SECRET` | For issuers without self-registration. Use these **instead of** the token, never both. |
45
45
  | `AUTH_OIDC_LABEL` | Button label. Default "Continue with your account". |
46
- | `AUTH_OIDC_SESSION_SECRET` | Required in production, at least 32 characters. In development it is generated in `.jskit/auth/oidc-session.secret`. |
47
- | `APP_PUBLIC_URL` | The address people use. With it the app registers at start; without it, on the first sign-in from a new address. Required in production behind a proxy that is not on the same machine. |
46
+ | `AUTH_OIDC_SESSION_SECRET` | Required in staging and production, at least 32 characters. In development it is generated in `.jskit/auth/oidc-session.secret`. |
47
+ | `APP_PUBLIC_URL` | The address people use. With it the app registers at start; without it, on the first sign-in from a new address. Required in staging and production behind a proxy that is not on the same machine. |
48
48
 
49
49
  Addresses must be `https`, or `http` on `localhost`/loopback. Without
50
50
  `AUTH_OIDC_ISSUER` the app still starts; pressing the button brings the person
@@ -54,11 +54,12 @@ missing." Every sign-in that cannot start is explained there the same way.
54
54
  Never invent either value or copy it into source. If the host keeps saved
55
55
  values (an editor's saved keys, a deployment secret store), link these two
56
56
  variables to the hub's saved address and token instead of pasting them, in
57
- development and in production.
57
+ development, staging and production.
58
58
 
59
59
  The issuer must be reachable from the app's server and from the person's
60
60
  browser. A hub that runs only on another computer's `localhost` (for example in
61
- another project's development preview) is not; connect apps to the deployed hub.
61
+ another project's development preview) is not; connect apps to the hub's
62
+ staging or production server.
62
63
 
63
64
  ## What the issuer is told
64
65
 
@@ -76,7 +77,8 @@ Scopes are `openid email profile`. A static client must be registered with the
76
77
  same redirect URI.
77
78
 
78
79
  An accounts hub decides what a new address may do. Development addresses work
79
- at once. A production address waits until the hub's owner approves it on the
80
+ at once. Any other address, such as a staging or production one, waits until
81
+ the hub's owner approves it on the
80
82
  hub's Apps page; until then, signing in shows the hub's own waiting page. A
81
83
  blocked address cannot register, and the login page says "Your accounts hub has
82
84
  blocked this app's address."
@@ -258,8 +258,9 @@ application:
258
258
  seeded copy of `BROWSER_TEST_DB_NAME`. Server settings for tests only (a
259
259
  simulated email or payment driver) go in `browserTestConfig({ env })`.
260
260
  4. Runs Node tests with `"test": "jskit test --databases"`, with
261
- `TEST_DB_NAME` distinct from `DB_NAME`, `BROWSER_TEST_DB_NAME` and
262
- `PROD_DB_NAME`, and a database user that may create its numbered copies
261
+ `TEST_DB_NAME` distinct from `DB_NAME`, `BROWSER_TEST_DB_NAME`,
262
+ `STAGING_DB_NAME` and `PRODUCTION_DB_NAME`, and a database user that may
263
+ create its numbered copies
263
264
  (`CREATEDB` on PostgreSQL). Test files read `DB_NAME`/`TEST_DB_NAME` as
264
265
  given rather than naming the test database themselves, and no longer
265
266
  create, migrate or drop it: the run hands each file a restored copy.
@@ -383,7 +384,8 @@ without a known `APP_ENV` refuses to start, naming the fix.
383
384
  `APP_ENV=development vite`; an older application adds the same.
384
385
  - Staging: set `APP_ENV=staging` and `NODE_ENV=production`, plus
385
386
  `STAGING_EMAIL_TO` and `STAGING_SMS_TO` for the testers' inbox and phone
386
- (unset, email and SMS are logged). Staging needs production's secrets.
387
+ (unset, email and SMS are logged). Staging needs secrets of its own, as
388
+ production does.
387
389
  - Production: set `APP_ENV=production` and `NODE_ENV=production`, and remove
388
390
  `SIDE_EFFECTS`.
389
391
  - Tests: `jskit test` and the browser test servers set `APP_ENV=test`. A test
@@ -397,7 +399,7 @@ without a known `APP_ENV` refuses to start, naming the fix.
397
399
  `@jskit-ai/kernel/server/runtime/sideEffects` and
398
400
  `@jskit-ai/kernel/server/runtime/runtimeMode` are gone: read
399
401
  `@jskit-ai/kernel/shared/support/appEnvironment` (`appEnvironment`,
400
- `isDeployed`) and `@jskit-ai/kernel/server/runtime/appEnvironment`
402
+ `isStagingOrProduction`) and `@jskit-ai/kernel/server/runtime/appEnvironment`
401
403
  (`deliverMessage`, `markStagingEmail`, `logSideEffect`,
402
404
  `assertDevelopmentOnlySettings`). The page's meta tag is
403
405
  `jskit-app-environment` and the banner's test id
@@ -405,3 +407,49 @@ without a known `APP_ENV` refuses to start, naming the fix.
405
407
  - An installed `auth.local.confirmation-sender` or `auth.local.recovery-sender`
406
408
  receives `originalEmail` in staging; show it in the email
407
409
  (`markStagingEmail`).
410
+
411
+ ## Name staging and production apart
412
+
413
+ JSKIT's names say staging or production where they mean both, and nothing
414
+ reads the old ones. A server refuses to start while an old variable is set,
415
+ naming the new one, and so does a preparation of test databases
416
+ ([Environments](/guide/framework/environments#starting-refuses-what-is-not-clear)).
417
+
418
+ - Code: `isDeployed(env)` from `@jskit-ai/kernel/shared/support/appEnvironment`
419
+ is `isStagingOrProduction(env)`, with the same answer: true in staging and
420
+ production. An import of the old name fails as the module loads.
421
+ - Configuration fields: the dev auth policy (`resolveDevAuthPolicy`,
422
+ `resolveDevAuthPolicyFromEnv`), local auth's, OIDC sign-in's, Supabase's and
423
+ the accounts hub's resolved configuration name it `isStagingOrProduction`, in
424
+ place of `isDeployed`. A read of the old field is `undefined`, which reads as
425
+ development, so rename every read.
426
+ - `PROD_DB_NAME` is gone. Name the database a server shares with your test
427
+ databases in `STAGING_DB_NAME` (your Staging database) or
428
+ `PRODUCTION_DB_NAME` (your Production database); a test database, or one of
429
+ its copies, named like either is refused.
430
+ - `AUTH_LOCAL_FILE_PRODUCTION_ACK` is `AUTH_LOCAL_FILE_STAGING_OR_PRODUCTION_ACK`:
431
+ the local file auth backend needs it set to `true` in staging and in
432
+ production.
433
+
434
+ ## New tables in the collation of the existing ones
435
+
436
+ A MySQL or MariaDB database whose default collation differs from its tables',
437
+ such as a dump restored onto a server with another default, made JSKIT's
438
+ migrations up to the 0.2.93 catalog create each new table in that default.
439
+ `auth_local_db_users_second_factors` then failed (errno 150, "Foreign key
440
+ constraint is incorrectly formed") and left the database half-migrated: the
441
+ migrations before it recorded, `auth_local_used_passes` among them in the
442
+ database's default, and an empty, unrecorded `auth_local_second_factors`.
443
+
444
+ Update to the catalog after 0.2.93 and run `npm run db:migrate`; no repair by
445
+ hand. Each released migration that creates a table has a new companion,
446
+ `<name>-collation.cjs`, which runs first and creates its tables in the
447
+ collation of the existing tables, and repairs that state: the empty, unrecorded
448
+ `auth_local_second_factors` is created again with its key, a table recorded in
449
+ the database's default (`auth_local_used_passes`) is converted, keeping its
450
+ rows, and a second factors table that a second try recorded without its key
451
+ gets it. A database whose tables already match its default records the
452
+ companions and changes nothing. A table holding rows that a conversion could
453
+ not keep whole stops the migration and changes nothing, naming the table
454
+ ([Database layer](./database-layer.md#a-new-table-takes-the-collation-of-the-tables-already-there)).
455
+ Do not change the database's default to get past the failure.
@@ -17,7 +17,7 @@ builds, and staging and production set it to `production`.
17
17
  | --- | --- | --- | --- | --- | --- | --- |
18
18
  | `development` | a developer's machine, a session, a preview | logged | logged | sandbox only | allowed | "Development" |
19
19
  | `test` | automated test runs | logged | logged | sandbox only | allowed | "Test" |
20
- | `staging` | a deployed copy for checking the application | only to `STAGING_EMAIL_TO` and `STAGING_SMS_TO`; logged when unset | logged | sandbox only | refused | "Staging" |
20
+ | `staging` | a copy on a server for checking the application before production | only to `STAGING_EMAIL_TO` and `STAGING_SMS_TO`; logged when unset | logged | sandbox only | refused | "Staging" |
21
21
  | `production` | the application serving real people | sent | sent | live | refused | none |
22
22
 
23
23
  The development shortcuts are dev sign-in (`AUTH_DEV_BYPASS_ENABLED`), cookies
@@ -25,8 +25,8 @@ without `Secure`, links in answers (`AUTH_LOCAL_RECOVERY_DEV_OUTPUT`), a first
25
25
  account without a setup code, test databases, and a server that refuses to
26
26
  start over a role grant no action requires (staging and production log it
27
27
  instead). Staging and production add HSTS and the content security policy, and
28
- need production's secrets, such as `AUTH_LOCAL_SESSION_SECRET` and a sender for
29
- the emails they send.
28
+ each needs secrets of its own, such as `AUTH_LOCAL_SESSION_SECRET` and a sender
29
+ for the emails it sends.
30
30
 
31
31
  ## Who sets what
32
32
 
@@ -36,7 +36,7 @@ it where they own the run.
36
36
  | Who | `APP_ENV` | `NODE_ENV` | `STAGING_EMAIL_TO`, `STAGING_SMS_TO` |
37
37
  | --- | --- | --- | --- |
38
38
  | `npm run develop`, `npm run dev` on a developer's machine | `development`, set by the scripts | unset | unset |
39
- | A hosted session or preview | `development` | unset | unset |
39
+ | A session or preview in an editor | `development` | unset | unset |
40
40
  | `jskit test` and the browser test servers | `test`, set by JSKIT | anything | unset |
41
41
  | A build-check machine that starts the packaged build to see it start and answer health | `staging` | `production` | unset, so everything is logged |
42
42
  | A staging server | `staging` | `production` | the testers' inbox and phone |
@@ -67,10 +67,21 @@ A server stops at startup, saying what to do, when:
67
67
  `APP_ENV is staging, so NODE_ENV must be production, and it is not set. Set
68
68
  NODE_ENV=production: it only picks optimised builds, and APP_ENV decides
69
69
  everything else.`
70
- - `SIDE_EFFECTS`, which `APP_ENV` replaced, is set: `SIDE_EFFECTS was replaced
71
- by APP_ENV: remove SIDE_EFFECTS. APP_ENV=production acts for real; staging
72
- sends email and SMS only to STAGING_EMAIL_TO and STAGING_SMS_TO; development
73
- and test only log.`
70
+ - A variable JSKIT no longer reads is set, in any environment (test database
71
+ preparation refuses it too), each with its fix:
72
+ - `SIDE_EFFECTS`, which `APP_ENV` replaced: `SIDE_EFFECTS was replaced by
73
+ APP_ENV: remove SIDE_EFFECTS. APP_ENV=production acts for real; staging
74
+ sends email and SMS only to STAGING_EMAIL_TO and STAGING_SMS_TO;
75
+ development and test only log.`
76
+ - `PROD_DB_NAME`, which `STAGING_DB_NAME` and `PRODUCTION_DB_NAME` replaced:
77
+ `PROD_DB_NAME is no longer read: name that database in STAGING_DB_NAME
78
+ (your Staging database) or PRODUCTION_DB_NAME (your Production
79
+ database).`
80
+ - `AUTH_LOCAL_FILE_PRODUCTION_ACK`, which
81
+ `AUTH_LOCAL_FILE_STAGING_OR_PRODUCTION_ACK` replaced:
82
+ `AUTH_LOCAL_FILE_PRODUCTION_ACK is no longer read: set
83
+ AUTH_LOCAL_FILE_STAGING_OR_PRODUCTION_ACK=true instead, which the local
84
+ file auth backend needs in staging and production.`
74
85
  - A development-only setting is set in staging or production, for example
75
86
  `AUTH_LOCAL_RECOVERY_DEV_OUTPUT is for development only and APP_ENV is
76
87
  staging. Remove it from the staging environment.`
@@ -81,7 +92,8 @@ is logged (STAGING_SMS_TO is not set); …`.
81
92
 
82
93
  ## Staging's test addresses
83
94
 
84
- Staging is production's code and settings with nobody real at the other end.
95
+ Staging runs the code production will run, with settings of its own and nobody
96
+ real at the other end.
85
97
  `STAGING_EMAIL_TO` is one address, such as the testers' shared inbox; every
86
98
  email goes there instead of to its recipient. The email's first line, in its
87
99
  text and HTML, says `Staging: this email was for ada@example.com.`, it carries
@@ -165,22 +165,22 @@ A consolidation drops behaviour there without a failing build.
165
165
  `router.back()` and hand-made back controls, so Up lands inside the app
166
166
  even on a page opened from a link.
167
167
 
168
- ### Production settings
169
-
170
- - A deployed server sets `APP_ENV=staging` or `production` and
171
- `NODE_ENV=production` ([Environments](/guide/framework/environments)); only
172
- then does local auth ask for a setup code and refuse development settings.
173
- - On an empty production database, local auth asks for the first account's
174
- setup code, so whoever reaches a new deployment first cannot own it ([The
175
- first account in
176
- production](/guide/app-setup/authentication#the-first-account-in-production-local-auth)).
168
+ ### Staging and production settings
169
+
170
+ - A server sets `APP_ENV=staging` or `production` and `NODE_ENV=production`
171
+ ([Environments](/guide/framework/environments)); only then does local auth
172
+ ask for a setup code and refuse development settings.
173
+ - On an empty database there, local auth asks for the first account's setup
174
+ code, so whoever reaches a new server first cannot own it ([The first account
175
+ in staging and
176
+ production](/guide/app-setup/authentication#the-first-account-in-staging-and-production-local-auth)).
177
177
  Give any registration of your own the same protection.
178
178
  - `config.securityHeaders` sends the security headers, with the content
179
179
  security policy reported, not enforced, by default; read them on a
180
180
  production build ([Security
181
181
  headers](/guide/app-setup/initial-scaffolding#security-headers)).
182
- - Email confirmation needs `auth.local.confirmation-sender` in production, or
183
- the server refuses to start while anyone may register ([Email
182
+ - Email confirmation needs `auth.local.confirmation-sender` there, or the
183
+ server refuses to start while anyone may register ([Email
184
184
  confirmation](/guide/app-setup/authentication#email-confirmation-local-auth)).
185
185
  - Changing the assistant's instructions needs `assistant.settings.update` or
186
186
  the surface's own permission ([Who may change the
@@ -9,7 +9,7 @@ description: Where a JSKIT app decides who may do what, scopes rows to a workspa
9
9
 
10
10
  A security pass makes an app refuse what it should. Genesis's security pass
11
11
  skill (`genesis-security-pass`) holds the method: map every way in, work
12
- through authorization, sign-in, input, secrets, production settings and
12
+ through authorization, sign-in, input, secrets, staging and production settings and
13
13
  dependencies, prove each finding by sending the input that breaks it, and keep
14
14
  a test that fails without each fix. This page says where each of those lives in
15
15
  a JSKIT app. The rules it applies are already in [Typed features](/guide/framework/typed-features),
@@ -80,7 +80,7 @@ a JSKIT app. The rules it applies are already in [Typed features](/guide/framewo
80
80
  invitations, costly reads, calls to a paid service) declares
81
81
  `rateLimit: { max, timeWindow }`, refused with 429 `kernel.http.rateLimited`.
82
82
  Each limit gets a test expecting the 429.
83
- - Sign-in cookies are httpOnly, and in production `Secure` with the `__Host-`
83
+ - Sign-in cookies are httpOnly, and in staging and production `Secure` with the `__Host-`
84
84
  prefix; `AUTH_COOKIE_SAME_SITE` is `lax` or `strict`
85
85
  ([Sign-in cookies and SameSite](/guide/app-setup/authentication#sign-in-cookies-and-samesite)).
86
86
  Every unsafe `/api` method checks its CSRF token unless the route sets
@@ -94,20 +94,20 @@ a JSKIT app. The rules it applies are already in [Typed features](/guide/framewo
94
94
  an account exists. Give the app's own invitation, lookup and sign-up routes
95
95
  the same answer.
96
96
 
97
- ## Production settings and secrets
97
+ ## Staging and production settings and secrets
98
98
 
99
99
  - `APP_ENV=staging` or `APP_ENV=production`, with `NODE_ENV=production`, set by
100
- the Deployment's Serve step, makes a server deployed
100
+ the Deployment's Serve step, makes a server a staging or production server
101
101
  ([Environments](/guide/framework/environments)). There local auth requires
102
102
  `AUTH_LOCAL_SESSION_SECRET`, refuses `AUTH_DEV_BYPASS_ENABLED` and
103
103
  `AUTH_LOCAL_RECOVERY_DEV_OUTPUT`, and refuses to start without a confirmation
104
104
  sender while anyone may register
105
- ([Production settings](/guide/framework/sanity-checks#production-settings)).
106
- - On an empty production database the first account needs the setup code
107
- (403 `auth.local.setup.codeRequired`), so whoever reaches a new deployment
108
- first cannot own it. A registration or admin bootstrap of the app's own
105
+ ([Staging and production settings](/guide/framework/sanity-checks#staging-and-production-settings)).
106
+ - On an empty staging or production database the first account needs the
107
+ setup code (403 `auth.local.setup.codeRequired`), so whoever reaches a new
108
+ staging or production server first cannot own it. A registration or admin bootstrap of the app's own
109
109
  needs the same protection
110
- ([The first account in production](/guide/app-setup/authentication#the-first-account-in-production-local-auth)).
110
+ ([The first account in staging and production](/guide/app-setup/authentication#the-first-account-in-staging-and-production-local-auth)).
111
111
  - `AUTH_LOCAL_SESSION_SECRET` and every other secret live in private Env, read
112
112
  on the server, and the Deployment generates the session secret. Nothing
113
113
  secret goes in `config/public.js`, which the browser imports, or in a
@@ -116,8 +116,8 @@ a JSKIT app. The rules it applies are already in [Typed features](/guide/framewo
116
116
  server error."; an `AppError`'s message is shown at any status, so it never
117
117
  carries internals
118
118
  ([Internal failures are plain errors](/guide/framework/typed-features#internal-failures-are-plain-errors)).
119
- - `config.securityHeaders` sets the security headers. Production adds
120
- transport security, framing protection and a content security policy that is
119
+ - `config.securityHeaders` sets the security headers. Staging and production
120
+ add transport security, framing protection and a content security policy that is
121
121
  reported, not enforced, by default; enforce it once the pages run without
122
122
  violations, and read the headers on a production build
123
123
  ([Security headers](/guide/app-setup/initial-scaffolding#security-headers)).
@@ -134,7 +134,7 @@ a JSKIT app. The rules it applies are already in [Typed features](/guide/framewo
134
134
  workspace), a write without `csrf-token`, and one request past each
135
135
  `rateLimit` (429). A body that does not validate, sent without a session,
136
136
  must get the refusal, not field errors.
137
- - Production settings: start the server with `APP_ENV=staging`, `NODE_ENV=production` and the
137
+ - Staging and production settings: start the server with `APP_ENV=staging`, `NODE_ENV=production` and the
138
138
  test database, and check that it stops without `AUTH_LOCAL_SESSION_SECRET`,
139
139
  that registering asks for the setup code, and the response headers.
140
140
  - Run `npm audit` and `npm run verify`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/agent-docs",
3
- "version": "0.1.340",
3
+ "version": "0.1.342",
4
4
  "description": "Distributed JSKIT agent references, prompts, guides, and generated reference maps.",
5
5
  "type": "module",
6
6
  "files": [
@@ -5,7 +5,7 @@
5
5
  "private": true,
6
6
  "type": "module",
7
7
  "dependencies": {
8
- "@jskit-ai/kernel": "0.2.27",
8
+ "@jskit-ai/kernel": "0.2.28",
9
9
  "json-rest-schema": "^1.0.20"
10
10
  },
11
11
  "exports": {
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
- "@jskit-ai/kernel": "0.2.27",
37
+ "@jskit-ai/kernel": "0.2.28",
38
38
  "@jskit-ai/material-web": "0.1.9",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
@@ -44,13 +44,13 @@
44
44
  "vue": "^3.5.44",
45
45
  "vue-router": "^5.3.1",
46
46
  "vuetify": "^4.3.0",
47
- "@jskit-ai/http-runtime": "0.2.27",
47
+ "@jskit-ai/http-runtime": "0.2.28",
48
48
  "@fastify/fast-json-stringify-compiler": "^5.1.0",
49
49
  "@vue/devtools-api": "^8.2.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@jskit-ai/config-eslint": "0.1.252",
53
- "@jskit-ai/jskit-catalog": "0.2.92",
53
+ "@jskit-ai/jskit-catalog": "0.2.94",
54
54
  "@playwright/test": "1.61.1",
55
55
  "@vitejs/plugin-vue": "^6.0.7",
56
56
  "eslint": "^10.8.0",
@@ -34,7 +34,7 @@
34
34
  "dependencies": {
35
35
  "@local/main": "0.1.0",
36
36
  "@fastify/static": "^10.1.3",
37
- "@jskit-ai/kernel": "0.2.27",
37
+ "@jskit-ai/kernel": "0.2.28",
38
38
  "@jskit-ai/material-web": "0.1.9",
39
39
  "@tanstack/vue-query": "^5.101.0",
40
40
  "fastify": "^5.12.7",
@@ -44,14 +44,14 @@
44
44
  "vue": "^3.5.44",
45
45
  "vue-router": "^5.3.1",
46
46
  "vuetify": "^4.3.0",
47
- "@jskit-ai/http-runtime": "0.2.27",
48
- "@jskit-ai/shell-web": "0.2.43",
47
+ "@jskit-ai/http-runtime": "0.2.28",
48
+ "@jskit-ai/shell-web": "0.2.44",
49
49
  "@fastify/fast-json-stringify-compiler": "^5.1.0",
50
50
  "@vue/devtools-api": "^8.2.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@jskit-ai/config-eslint": "0.1.252",
54
- "@jskit-ai/jskit-catalog": "0.2.92",
54
+ "@jskit-ai/jskit-catalog": "0.2.94",
55
55
  "@playwright/test": "1.61.1",
56
56
  "@vitejs/plugin-vue": "^6.0.7",
57
57
  "eslint": "^10.8.0",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "description": "App-local runtime composition and lightweight glue.",
11
11
  "dependencies": {
12
- "@jskit-ai/kernel": "0.2.27"
12
+ "@jskit-ai/kernel": "0.2.28"
13
13
  },
14
14
  "jskit": {
15
15
  "kind": "runtime",
@@ -25,7 +25,7 @@ Exports
25
25
  - `APP_ENVIRONMENTS`
26
26
  - `APP_ENVIRONMENT_META_NAME`
27
27
  - `appEnvironment(env)`
28
- - `isDeployed(env)`
28
+ - `isStagingOrProduction(env)`
29
29
  - `pageAppEnvironment(documentObject = globalThis.document)`
30
30
  - `withAppEnvironmentMeta(html, environment)`
31
31