# Changelog

## Unreleased

- `createStaticInstalledRuntime` (`@jskit-ai/kernel/server/platform`) starts an application whose installed packages' providers were collected when it was built, such as a single-file release bundle with no `node_modules` to read: it takes `createInstalledRuntime`'s options and `installed`, the build's registry (`providers` in load order, `packageOrder`, `providerPackageOrder` and `globalUiPaths`), and runs `createInstalledRuntime`'s own body with that registry in place of reading the installed packages. So such a server checks APP_ENV and refuses to start where `createInstalledRuntime` refuses, sends the same security headers (`registerSecurityHeaders`) and environment page tag (`registerAppEnvironmentPage`), logs the same startup line, gives providers `runtime.health` and returns the same `health` and `diagnostics`. A bundle that started its own copy of the runtime's body sent none of the headers and checked no APP_ENV. Without `installed` it refuses: `createStaticInstalledRuntime requires installed: the providers, packageOrder and providerPackageOrder its build collected.` `createInstalledRuntime` is unchanged.
- The shell guard opens the application's Not found page at an address the guard evaluator answers `{ allow: false, notFound: true }`: the fallback route, by its name and its `pathMatch` param, with the address's query and hash, so the address stays as the person typed it; the Not found page itself is then allowed. `createShellRouter` marks its fallback route (`meta.jskit.notFound: true`), and `isNotFoundRoute(route)` (`@jskit-ai/kernel/client`) says whether a route is it. An application's own `fallbackRoute` keeps a name and a `:pathMatch` param, or `createShellRouter` throws naming the fix; `notFoundComponent`'s route has both. Other outcomes are unchanged.
- Every answer under `/api`, failures and 404s included, carries `Cache-Control: no-store, no-cache, must-revalidate` (no-store says it; the other two are for older caches and for scanners that ask for all three) unless its route set its own Cache-Control: API answers hold the signed-in person's data (the session and its CSRF token, a workspace's records), which no browser or proxy should keep, and had no Cache-Control at all, so a browser could keep them by its own heuristics and a scanner reports the missing header (OWASP ZAP rule 10015). `registerSecurityHeaders`, which `createInstalledRuntime` calls, adds it; `config.securityHeaders.apiCacheControl` gives another value, or `false` to leave it out, and an invalid one stops the server from starting as the other header settings do. Pages and other answers are unchanged.
- A staging server that real people use, because the application has no production yet, sends them its email and SMS: its host sets `STAGING_REACHES_REAL_PEOPLE=true` beside `APP_ENV=staging`, and `deliverMessage` then sends each message to its recipient, unmarked (`originalTo` is empty, so `markStagingEmail` changes nothing), logging `Staging: <summary> was sent to <recipient>, since real people use this staging (STAGING_REACHES_REAL_PEOPLE).`; `STAGING_EMAIL_TO` and `STAGING_SMS_TO` are not used, and everything else stays as staging has it (push notifications, webhooks and connector writes logged, payments in the sandbox, development shortcuts refused). `stagingReachesRealPeople(env)` and `STAGING_REACHES_REAL_PEOPLE_KEY` (`@jskit-ai/kernel/shared/support/appEnvironment`) read it: true only for `true` in staging, false when unset or empty, and a throw naming the fix otherwise. `assertAppEnvironment`, and so every server's start, refuses it outside staging (`STAGING_REACHES_REAL_PEOPLE is set and APP_ENV is production. It says real people use a staging server, so only APP_ENV=staging takes it: remove STAGING_REACHES_REAL_PEOPLE from the production environment.`) and any value but `true` (`STAGING_REACHES_REAL_PEOPLE is "yes". Set it to true when real people use this staging server, or leave it unset.`). The startup line says so (`APP_ENV is staging and real people use it (STAGING_REACHES_REAL_PEOPLE=true): email and SMS go to the people they are for; …`). Every page such a server or the Vite development server sends carries `<meta name="jskit-staging-reaches-real-people" content="true">` right after its `jskit-app-environment` tag (`withAppEnvironmentMeta(html, environment, { reachesRealPeople })`, `STAGING_REAL_PEOPLE_META_NAME`), which `pageStagingReachesRealPeople()` reads in the browser. Without the setting, nothing changes.
- **Breaking:** `isDeployed(env)` from `@jskit-ai/kernel/shared/support/appEnvironment` is `isStagingOrProduction(env)`, with the same answer (true in staging and production); the old name is gone. `assertNoRetiredVariables(env)` from `@jskit-ai/kernel/server/runtime/appEnvironment` throws, in any environment, while a variable JSKIT no longer reads is set, with the fix for each one set: `SIDE_EFFECTS` (replaced by `APP_ENV`), `PROD_DB_NAME` (replaced by `STAGING_DB_NAME` and `PRODUCTION_DB_NAME`: `PROD_DB_NAME is no longer read: name that database in STAGING_DB_NAME (your Staging database) or PRODUCTION_DB_NAME (your Production database).`) and `AUTH_LOCAL_FILE_PRODUCTION_ACK` (replaced by `AUTH_LOCAL_FILE_STAGING_OR_PRODUCTION_ACK`). `assertAppEnvironment`, and so every server's start, checks it first, where it refused only `SIDE_EFFECTS`.
- **Breaking: `APP_ENV` says where an application runs, replacing `SIDE_EFFECTS` and every decision `NODE_ENV` made.** It is exactly `development`, `test`, `staging` or `production`; `NODE_ENV` now only picks optimised builds. `@jskit-ai/kernel/shared/support/appEnvironment` gives `appEnvironment(env)` (the value; a missing or unknown one throws, naming the fix), `isDeployed(env)` (staging or production), `pageAppEnvironment()`, `withAppEnvironmentMeta(html, appEnv)` and `APP_ENVIRONMENTS`. `@jskit-ai/kernel/server/runtime/appEnvironment` gives `deliverMessage({ env, logger, channel, to, summary, details, send })`, which sends an email or SMS in production, sends it only to `STAGING_EMAIL_TO` or `STAGING_SMS_TO` in staging (calling `send(stagingAddress, { originalTo })`), and logs it in development, test and staging without that address; `markStagingEmail(message, originalTo)`, which adds the `X-Staging-Original-To` header and a first line `Staging: this email was for <address>.` to its text and HTML; `logSideEffect(logger, appEnv, { kind, summary, details, reason })` for any other effect logged outside production; `assertDevelopmentOnlySettings(env, names)`; and `assertAppEnvironment(env)`. `createInstalledRuntime` refuses to start when `APP_ENV` is missing or unknown, when `SIDE_EFFECTS` is set at all (`SIDE_EFFECTS was replaced by APP_ENV: remove SIDE_EFFECTS. …`), and when `APP_ENV` is staging or production without `NODE_ENV=production`; it logs once where it runs and what that means, and names the environment in every HTML page it sends (the `jskit-app-environment` meta tag, replacing `jskit-side-effects`). The security headers' HSTS and content security policy follow `APP_ENV` (staging and production), not `NODE_ENV`. The Vite plugin names `APP_ENV` in the development server's pages and refuses without one; a built page names none. Removed: `@jskit-ai/kernel/shared/support/sideEffects`, `@jskit-ai/kernel/server/runtime/sideEffects` and `@jskit-ai/kernel/server/runtime/runtimeMode` (`isProductionEnv`).
- `resolveApiErrorStatus(error)` from `@jskit-ai/kernel/server/runtime/errors` gives the HTTP status an error answers a client with: json-rest-api's refusals, which carry no status, by their code (`REST_API_VALIDATION` a 422, a `REST_API_RESOURCE` by its subtype: 404, 403, 409 or 400), any other error by its own status when that is 400 to 599, else 500. It is the HTTP error handler's own mapping, moved there so that anything else telling a client of a refusal, such as the assistant's tool results, answers with the same status; the HTTP error handler's answers are unchanged.
- `withoutExecutionLog(context)` from `@jskit-ai/kernel/server/actions` returns the same execution context marked so the action pipeline writes no `action.execution` log line for it, for a caller that keeps every trace of a call out of what it saves (an assistant's unsaved tool). `isExecutionLogged(context)` reads the mark, so an action or action policy can keep its own logs quiet too. The mark is a private symbol: it passes through `normalizeExecutionContext` and never reaches a serialized context.
- A feature or provider may declare **late requirements**, `late: { evidence: "evidence.files" }`, local names to capability ids as `requires` and `optional` are, for a ring that only a read at call time closes, such as a row policy that narrows through an owner which itself requires the policy's feature. A late requirement takes no part in the order providers start in nor in the cycle check, so the ring starts instead of failing with `Provider capability cycle detected`; `createCapabilityRuntime().start()` resolves it once, after every provider's `boot()`. Until then its local name is a getter that throws `Provider "audit" read its late requirement "evidence" (capability "evidence.files") before every provider booted: a late requirement can only be read at call time after boot, such as inside a row policy or a request handler, never in setup or boot, and never destructured in setup.`; after, it answers the capability. A capability nothing provides fails start() at the end of boot with `Provider "audit" late-requires missing capability "evidence.files": no provider or runtime input provides it.` (and the provider's hint for it, if any), and start() stops what started as for any startup failure. The value reaches everything a feature's dependencies reach: setup's dependencies, actions(), boot() and shutdown(), and each owned table's row policy as `requires`; defineFeature now copies dependencies by property descriptors, so a copy keeps the getter instead of reading it. Late local names must differ from the provider's requires, optional and provides names; a provider cannot late-require a capability it provides, or one it already requires or takes as optional; and defineFeature refuses the reserved local names and `runtime.resources` under `late` as under `requires`. A package's manifest drift counts late requirements as requirements, so its manifest lists them under `requires`.
- **Behaviour change: a route handler's returned value is now sent as the response; previously it was dropped and the answer was an empty 200.** This applies to every route registered through the kernel's router whose handler returns something other than `undefined` without replying. That includes every `actionRoute` of `createActionRouteScope` registered without an application's own `wrapHandler`: it returns its action's result, so until now it answered 200 with an empty body. The router sends the returned value unless the handler started a send itself, which only the router can tell, since a send can still be finishing after it returns (see the `FST_ERR_SEND_INSIDE_ONERR` entry below). A handler that sends its reply (`reply.send(...)`, `return reply.send(...)`, `return reply`, or a hijacked reply) keeps that reply, whatever it returns, and one that returns nothing without replying still answers an empty 200. **What an application should check:** every route handler that returns a value without replying, since that value now reaches the browser. Make sure each one returns only what the browser should see, never an internal object such as a service's result, a database row or a record with internal fields, and that a handler writing to `reply.raw` (a stream or server-sent events) hijacks the reply or returns nothing. A route with a response schema serializes the value through it, which writes only the properties the schema declares unless it allows others; a route without one sends the whole value as JSON. An application whose `wrapHandler` already sent the result keeps working unchanged, and can drop that send.
- A route may ask for a second factor: `secondFactor: true` for one done at any time in the request's session, or `secondFactor: { maxAgeSeconds }` for one done within that many seconds, for a dangerous action. The router checks it when the route is defined (anything else, or a route whose `auth` is not "required" or "own", stops startup with a `RouteDefinitionError` naming the route) and passes it to the route's policy config, where `@jskit-ai/auth-core`'s auth policy enforces it.
- A route with a body schema answers 400 `validation_failed` when the body is missing or is not a JSON object, instead of 500. A missing body is validated as an empty one: a body validated in `create` or `replace` mode names each required field (`Field is required`, code `kernel.validation.field.required`), and one in the default `patch` mode, or with no required fields, reaches the handler as `{}`; a body of `null`, an array, a string or a number answers `request: "must be object"` (code `kernel.validation.type`). The kernel's own body check replaces Fastify's, and json-rest-schema throws on anything but an object, so a DELETE sent without its body ended in a 500.
- **Side effects.** An application reads `SIDE_EFFECTS`: exactly `live` acts for real; anything else, including unset, simulates (a test copy). `@jskit-ai/kernel/shared/support/sideEffects` gives `resolveSideEffectsMode(env)`, `sideEffectsAreLive(env)` and the page's own `pageSideEffectsMode()`; `@jskit-ai/kernel/server/runtime/sideEffects` gives `logSimulatedSideEffect(logger, { kind, summary, details })`, which logs "Test copy: … was simulated, not sent". `createInstalledRuntime` names the setting in every HTML page the server sends (the `jskit-side-effects` meta tag, with the page's length corrected) and logs once at startup whether the server acts for real, as a warning when a production server simulates. The Vite plugin names the development server's setting in its pages; a built page carries none until its server sends it.
- An action definition may give `checkInput(input)`, a check of its input that its schema cannot make until the application runs, such as one that needs what boot resolved. The action pipeline runs it on the input as the schema validated it, before the policy and the action, and answers a refusal (an error with field errors, as `createValidationError` throws) exactly as it answers the schema's: 400 `ACTION_VALIDATION_FAILED`, "Validation failed.", with `details.fieldErrors` and their `fieldErrorCodes`, so an HTTP client and an assistant tool read both alike and the action never runs. Any other error it throws fails the action as it is. A `checkInput` that is not a function is refused at registration.
- `createCachedResponseSerializerFactory` compiles each union branch of a response schema that names nothing outside itself on its own, once for all the serializers it builds, instead of with the whole schema the branch sits in. fast-json-stringify chooses an `anyOf`, `oneOf` or `if`/`then` branch by validating the value with Ajv, and Ajv compiles the whole schema a branch sits in before the branch, so the first response of a big list compiled its entire response schema while every other request on the server waited: a JSON:API collection whose json-rest-schema attributes hold hundreds of nullable numbers, boolean-like enums, dates and nullable relationships, each a union (74,000 characters, 341 unions), took 2.1 s for its first 50 rows. It now takes 0.11 s, and each later response half as long (16 to 7.5 ms). The serializer is fast-json-stringify's own code, restored with the new validator, so what it writes, what it refuses and its error messages do not change; a branch that names another schema is validated as before, and an application that sets a fast-json-stringify `mode` keeps it.
- A response its serializer refuses, such as one that breaks its response schema, answers 500 and can no longer crash the process. A route handler that sent its reply returned nothing, so while an `onError` hook took a moment for the refused response, Fastify sent the reply again itself, which it refuses inside `onError` with `FST_ERR_SEND_INSIDE_ONERR`, and that rejection took the whole process down. A route that has started sending now returns its reply, so Fastify waits for the send, and middleware that started one ends the route as a finished one does. The HTTP error handler logs such a response as "Response serialization failed" with its `route` (`GET /path`).
- A refusal thrown inside a write's transaction reaches the client as itself. json-rest-api wraps what a write's hook (or a CRUD `afterCommit` hook) throws in its `RestApiWriteError`, which keeps the refusal as its `cause` and copies only its message, code, status and details, so the HTTP error handler answered the wrapper: the right status, code and message, but no `details` (a refused step's next step, say), no `params`, `messageCode` or `messageParams`, and none of the refusal's headers. The handler now answers an error whose cause chain holds an `AppError` (or an `ActionRuntimeError`) as that error, exactly as if the route had thrown it (an `ACTION_PERMISSION_DENIED` still shows no details, and a 5xx one is logged with the whole chain as "AppError 5xx"), with the wrapper's `transactionOutcome`. A route transport's error serializer receives that outcome as `transactionOutcome` beside `messageCode`. An error with no refusal in its chain is answered as before, and a database error before one still by its stand-in.
- `packageCapabilityDrift(packageEntry)` (`@jskit-ai/kernel/server/platform`) loads a package's declared server providers and says where its manifest (`jskit.capabilities`) and they disagree, by the rules start-up applies, without starting the app: what the providers provide that the manifest does not (`unlistedProvides`) and the reverse (`extraProvides`), what they require that it does not list (`unlistedRequires`) and what it requires that no provider does (`extraRequires`), each sorted; null for a package with no server providers. Plain `jskit check` reports it. Start-up's own check (`assertManifestMatchesProviders`) now reads the same comparison and refuses and logs as before.
- A feature that owns resources hands its dependencies (its `requires` and the optional capabilities present, by local name, as setup receives them) to the resource runtime's `own(featureId, owns, { requires })`, so each `owns` entry's `rowPolicy` receives them as `requires`. The `ResourceRuntime` type's `own` takes that third argument.
- A package manifest (`jskit.capabilities`) names a capability id in any case, as a provider does: the start-up check of a package's manifest against its server providers, and the check that every installed package's requirement has a provider, compare manifest ids trimmed and lower-cased with `capabilityKey`, as the capability runtime resolves provider ids. They only trimmed them, so a manifest listing a mixed-case id such as `assistant.personContext` stopped start-up with "manifest provides [assistant.personContext] but its providers provide [assistant.personcontext]", and a manifest requiring an id in another case than the manifest providing it was refused as having no provider.
- `request.callOptions({ input })` gives a route that runs no action (a provider's callback, a streamed download) the call options `{ context }` the same request's action would get: the action catalogue's new `contextFor({ input, context })` runs the same context contributors and normalizes the result as the action pipeline does, with the route's channel, surface, visibility and request, and `input` defaulting to the route's params, so the workspace is resolved from `workspaceSlug` as an action's is. Contributors are told no action, and no action permission is checked: the route's own `auth` and `permission` are its gate.
- **Security.** `defineFeature` refuses `runtime.resources` in `requires` or `optional` in any spelling the runtime resolves, such as `"Runtime.Resources"` or `" runtime.resources "`: capability ids are trimmed and lower-cased when they resolve, but the refusal compared the raw text, so another spelling handed a feature the whole resource runtime, whose `declareSystemScope` mints a system context.
- The action catalogue builds its registry once, when discovery or execution first reads it, instead of again at every registration: an app registering n contributors rebuilt its index n times at every composition. A contributor that repeats a registered action's id and version is still refused at its own registration, with the same message. An action input whose schema is frozen throughout, as a CRUD feature's are, is checked for `oneOf` once rather than at every registration of it; a schema that can still change is checked every time, as before.
- An action event whose scope is global (one written on a customer's or a public surface) carries the workspace the request resolved as its scope's `workspaceId`: the context's workspace, the resolved workspace context's, or the request's, when they agree, never one its input or payload names. Realtime reads the event's audience there, in place of a `workspaceId` the payload named.
- A database error never reaches a client. A driver's error carries the statement and its values (Knex starts its message with the SQL and its bindings; MySQL's `sqlMessage` and `sql`, Postgres's `detail`), and a wrapper that keeps one as its `cause`, such as json-rest-api's `RestApiWriteError`, copies its message and code. The HTTP error handler answered it 500 with the driver's code (`ER_CHECKREAD`, `ER_DUP_ENTRY`, `23505`). It now answers a stand-in: 409 with the code `kernel.database.concurrentWrite` ("Another request changed the same data at the same time. Try again.") when the database refused the transaction for a concurrent one (MySQL and MariaDB errno 1020 "Record has changed since last read", 1213 deadlock, 1205 lock wait timeout; Postgres `40001`, `40P01`, `55P03`; `SQLITE_BUSY`), so the client may send the request again, else 500 `internal_server_error`, with the wrapper's `transactionOutcome`; the whole error goes to the log as "Database error". An `AppError` keeps its own answer whatever it wraps, so a duplicate key a feature turns into a `ConflictError` answers as before. `hideDatabaseError(error)` (`@jskit-ai/kernel/server/runtime`) answers the stand-in, or the error itself when it is not a database error, for any other edge that answers a client. New message key: `jskit.kernel.database.concurrentWrite`.
- An action a system context or a job runs keeps that context's kind: `normalizeExecutionContext` now passes a context's symbol-keyed entries through with the rest, so the private markers of a json-rest-api system context and of a job context derived from one reach the action, and a handle call inside it reads as that system context or job, not as an anonymous request. The reserved fields are normalized as before, and a job done for one person is still signed in as no one: `actor` stays null, so an authenticated action and `requireAuth` refuse it.
- `resolveTrustedProxies(env)` (`@jskit-ai/kernel/server/http`) gives Fastify's `trustProxy` from one setting, `TRUSTED_PROXIES`: the addresses or ranges of the proxies in front of the server, comma-separated, in Fastify's `trustProxy` (proxy-addr) syntax, such as `TRUSTED_PROXIES=loopback,10.0.0.5` or `10.0.0.0/24`. Without it only `loopback` is believed. `true` and hop counts stop startup with a message saying why, because they believe an `X-Forwarded-For` any client can send. The foundations' `server.js` creates Fastify with `trustProxy: resolveTrustedProxies(runtimeEnv)`, so behind a named proxy `request.ip`, and every route rate limit and sign-in limit counted by it, is each client's own address; before, a server created with no `trustProxy` counted every client behind a proxy as the proxy, one shared limit for all. A client that sends `X-Forwarded-For` itself, directly or prepended through the proxy, still counts as the address the server or the proxy saw.
- `resolveClientIpAddress(request)` (`@jskit-ai/kernel/server/runtime/requestUrl`) is `request.ip`. It read the first `X-Forwarded-For` entry from any request, so a client could set the address it recorded; it now follows `TRUSTED_PROXIES` like the rest of the server.
- `shellScrollBehavior` waits for the page to draw a position it restores (Back/Forward's saved position, or the `state.restoreScroll` of shell-web's Up) and a hash target. vue-router calls it once the new route has rendered, before a page has drawn the content it loads, so a list still fetching its rows was too short: the position landed at the page's end (usually its top) and a hash target not drawn yet was skipped. It now answers with a promise when the page cannot reach the position yet, checks on every frame, and scrolls once the page is tall enough or the target exists, or after 1.5 s (as long as shell-web's Up waits to focus the record it opened) as far as the page goes; it does not scroll when the person wheels, touches, presses a key or clicks meanwhile. A position the page already reaches, and a new screen's top, scroll at once as before.
- `@jskit-ai/kernel/server/actions/actionContributorHelpers` exports `resolveAuditActorId(context, request)`, the user a write is made for, for audit fields: the signed-in user, else `context.onBehalfOf.id`, the user background work acts for. It never decides access; `resolveActor`, `resolveActorId` and every authentication check ignore `onBehalfOf`, so work done for someone is not signed in as them.
- `shouldRetryTransientQueryFailure` no longer retries a query whose request the transport already retried for a transient failure, so each failed request is retried by one layer. The HTTP client marks such an error with the new `markTransientRetriesSpent`. Before, a failed safe read was retried by the HTTP client (three attempts) and the whole retried call again by the query (three times), so one unreachable read made 9 requests and showed shell-web's recovery banner after 11 s; it now makes 3 and shows it after 3 s. Queries whose requests the client does not retry (other methods, custom fetches) keep their two transient retries.
- A provider or feature may give `hints`, keyed by the capability ids it requires, saying what to register when one is missing; the startup error "requires missing capability" adds it. A hint must name a required capability and be non-empty text. A feature that owns tables or declares a system scope hints that `runtime.resources` comes from `@jskit-ai/resource-runtime`.
- Routes share a response schema that is plain JSON, frozen all the way down and names every node's type, instead of each route getting its own copy, and `createCachedResponseSerializerFactory` keys such a schema once instead of checking it again for every route and status. In a large application's boot the 3,562 error-response compilations went from 2,396 schema objects to 4, and keying them from 72-84 ms to about 1 ms. A frozen schema that Fastify's own serializer would add a `type` to is still copied for each route.
- An event builder from `createEntityChangedActionEvent` carries the realtime part it was declared with as its `realtime` property (null without one), so realtime can check a declared audience when it boots.
- `tryAcquireExclusiveFileLock` runs one short `flock` process per acquisition and none while the lock is held, instead of a shell that stayed alive holding the lock and a `flock` it started. The lock always belonged to the caller's open file description, so it is still released when the handle closes or the process ends however it ends, and it still excludes `flock` on the same file from any other process. Release only closes the handle; it no longer waits for a holder process to exit. A `flock` failure other than a held lock is now an error instead of being reported as busy.
- `bootstrapClientShellApp` starts downloading the code of the page the tab opened on before it boots the client modules, so it arrives while they boot (shell-web's bootstrap and session requests among them) instead of after them and the router's guards. It calls the lazy component loaders of the route the address matches; the router later calls the same loaders and gets the modules from the browser's module map, and still reports a loader that fails. A guard that redirects, such as a signed-out visit to a signed-in page, leaves the download unused, and an address that matches only the fallback route, or a route the client modules add, is left to the router. Measured on the accounts starter with 60 ms of latency per request: the home page's code was requested at 704 ms instead of 1,082 ms, during the shell's requests instead of after the session, and its last request ended at 992 ms instead of 1,217 ms; cold loads showed the signed-in home page in 1,110 ms instead of 1,286 ms and the account settings page, whose code now loads with its route, in 1,265 ms instead of 1,612 ms.
- The client bootstrap imports a package's client providers through the subpath exports that name their files, instead of `import * as` its whole `./client`, whenever the providers are all it reads there: the package declares no UI routes, its `./client` file declares neither `routeComponents` nor `clientRoutes` and has no `export *`, and each provider's file has a subpath export of its own. The screens `./client` re-exports, and their libraries, then load with the routes that show them instead of on every page of every app. Measured on the accounts starter (users-web 0.2.21, whose `./client` re-exports the account settings screen): the JavaScript a page loads before it starts went from 1,302 KB (415 KB gzip) to 778 KB (259 KB gzip) and its stylesheets from 474 KB to 347 KB, and Uppy, cropperjs, exifr and compressorjs are no longer among them; with 60 ms of latency per request, a cold signed-in home page showed in 1,286 ms instead of 1,681 ms and the sign-in screen in 1,354 ms instead of 1,601 ms. Code at the top level of such a `./client` no longer runs at boot; JSKIT's packages register their messages through the bootstrap's catalogs, which still load. Development prebundles a provider subpath with its package's `./client`, and keeps it as source when the package excludes `./client` from `optimizeDeps`, as shell-web does. A package gets this by exporting each provider by its own subpath (the client guide's Provider subpaths rule), and `tooling/jskit-catalog/test/clientBootGraph.test.js` fails when a page of an app that installs every JSKIT client package would load any library beyond the bootstrap's own.
- `createCachedResponseSerializerFactory` compiles each response serializer when a response first uses it, in every environment, instead of compiling every route's response schemas at startup. Measured on a large application (203 distinct response schemas, desktop): a boot built 203 serializers in 0.9-1.1 s and now builds none, while the checks below take 55-96 ms (meta-schema 37-73 ms, references 18-23 ms); a smaller application built 66 in 0.24-0.27 s. Startup still runs fast-json-stringify's own checks of each schema before it would build: the JSON Schema draft-07 meta-schema check (for the external schemas too) and a check that every `$ref` the schema reaches resolves (a schema whose reference does not resolve is compiled at once, so the build's own error stops startup). What startup no longer catches: errors fast-json-stringify finds only while generating a serializer, and an invalid serializer option (`rounding`, say); they fail the first response that uses the schema, and its next use tries again. A serializer is built from the schema as it was registered. The factory now depends directly on `fast-json-stringify` and `json-schema-ref-resolver` (already installed with Fastify), loaded with the first factory, so importing `@jskit-ai/kernel/server/http` still loads neither.
- A feature can own tables and work across every workspace (data-access redesign). `defineFeature({ owns, systemScope })`:
  - `owns: [tableResource | { resource, ...serverOnlyExtras }]` makes the feature its tables' one owner. The kernel calls the `runtime.resources` capability's `own(featureId, owns)` before `setup`, and `setup` alone receives the handles as `resources`, by resource name; `actions()`, `boot` and `shutdown` do not.
  - `systemScope: "<why>"` gives `setup` a `systemContext(reason)` factory. Every call names its reason and throws without one; the factory comes from `runtime.resources.declareSystemScope(featureId, systemScope)`.
  - Either one makes the feature require `runtime.resources`; a feature without them does not. A feature may not require `runtime.resources` itself, and the local names `resourceRuntime`, `resources` and `systemContext` are reserved beside `actionCatalogue`.
  - The `ResourceRuntime` type in `@jskit-ai/kernel/server/types` is the contract a resource runtime provides.
- Routes that validate the same body, query, params or headers hand Fastify one shared, frozen schema object, so its Ajv compiles each distinct schema once per server instead of once per route: an app with 96 route validation schemas, 22 of them distinct, now compiles 22 (Ajv time per boot 644 ms -> 302 ms on a loaded host). A route's validation schema can no longer be changed after it is registered (in an `onRoute` hook, say), since routes share it.
- A process discovers an app's installed packages once instead of on every boot and every database preparation, and the first discovery probes the file system about half as often. `discoverInstalledPackages`, which `createInstalledRuntime`, database-runtime's migration configuration and the Vite client bootstrap call, reads the manifest of every installed package, npm's own included. It now keeps an app's result while npm's `node_modules/.package-lock.json` (rewritten by every install), the app's `package.json` and its local packages' manifests keep their size and modification time, so a second server boot or database preparation in one process, such as a test file's, reads no manifest; a change to any of those files is seen by the next call. A `node_modules` without that file (another package manager, one written by hand) is discovered afresh on every call, as before. The walk no longer checks a package's directory and manifest again after finding it, nor looks for `node_modules` inside a `node_modules` directory, which Node never does. Measured on an app with 446 installed packages: 3191 existence checks per discovery became 1663 and 0.5-1.0 s of CPU became 0.36 s; a repeated discovery takes under a millisecond (11 `stat` calls). The discovered entries are now frozen throughout, `packageMetadata` and `packageJson` included, since callers share them.
- `staysOnSamePage(to, from)`, and so `shellScrollBehavior`, counts a shared parent record as one page only when it draws a component: a layout hosting tabs or sub-views. The component-less records file routing creates for route folders (`/w`, `bookings/`) no longer make every page in the folder the same page, so a new page in a folder opens at the top instead of at the last page's scroll, and Up's `state.restoreScroll` is used instead of ignored. Tabs of a layout still keep their scroll.
- Production builds keep Vuetify's cascade layer order. A build links its shared component chunks' stylesheets, each opening with `@layer vuetify-components`, before the entry's `vuetify/styles`, which named that layer before `vuetify-core`: Vuetify's reset (`button, input, select, textarea { font: inherit }`) then beat its component styles, and every `<button>` `v-btn` showed a 16px/400 label instead of label-large. `createJskitClientBootstrapPlugin` now puts Vuetify's layer order (its `layers.css`) in a `<style>` first in every page's `<head>`, built or in development; apps need no change to their `index.html`. A production build also checks its own output: when a page's stylesheets, in page order and then those it loads later, would put Vuetify's layers in any other order (a layer a newer Vuetify adds included), the build fails and names both orders.
- `createShellRouter` throws when the `createRouter` it is given replaces the scroll behaviour it passes (a wrapper with a `scrollBehavior` of its own), instead of silently losing `shellScrollBehavior` and with it the position Up returns to. An app's own behaviour is `createShellRouter`'s `scrollBehavior` option, which may call `shellScrollBehavior`; `false` still leaves scrolling to the browser. Upgrading: move a wrapper's `scrollBehavior` into that option.
- `shellScrollBehavior` opens a hash target below its computed `scroll-margin-top`, as the browser's own scroll to an element does, so a target with a margin for a sticky bar stays clear of it without wrapping the behaviour.
- `shellScrollBehavior` opens a page at the position a navigation carries in `state.restoreScroll`, as shell-web's Up does when it returns to a page, and the client exports `staysOnSamePage(to, from)`, the check it uses for tabs and sub-views of one page.
- `createInstalledRuntime` adds security headers to every response its Fastify server sends: `X-Content-Type-Options: nosniff` and `Referrer-Policy: strict-origin-when-cross-origin` always, and in production (`NODE_ENV=production`) `Strict-Transport-Security: max-age=31536000`, `Content-Security-Policy: frame-ancestors 'self'` and a report-only content policy that JSKIT's client runs under. `config.securityHeaders` changes or switches each one off; a route's own header wins. `registerSecurityHeaders` (`@jskit-ai/kernel/server/http`) does the same for a server composed without `createInstalledRuntime`.
- `createInstalledRuntime` returns `health`, whose `check()` runs the checks providers register through the optional `runtime.health` capability, each within two seconds, and reports `{ ok, checks }` without error details.
- `@jskit-ai/kernel/server/runtime/runtimeMode` exports `isProductionEnv(env)`, the one check JSKIT packages make to decide production, the security headers included: `NODE_ENV` is `production`, in any letter case; anything else, unset included, is development, as before. It also exports `assertDevelopmentOnlySettings(env, names)`, which stops a production server's startup when any of the named development-only settings is set, saying which to remove.
- A route's `rateLimit: { max, timeWindow }` is enforced. The kernel registers `@fastify/rate-limit` (now its dependency) before the routes whenever one declares a limit, counts each client address on each limited route, and refuses a request over the limit with status 429, the code `kernel.http.rateLimited` (`params.count` is the seconds to wait) and a `Retry-After` header. Before, the router dropped `rateLimit`, so no declared limit applied. A malformed `rateLimit`, or one given as `config.rateLimit`, stops the route's definition. New message key: `jskit.kernel.http.rateLimited`.
- A package's route (`jskit.metadata.ui.routes`, or a client module's `clientRoutes`) no longer copies its `surface` into `meta.jskit`, where `surface` marks a surface's root record. The shell's Up stops at such a record before reading its parent, so every surface route a package declared was a surface root with no Up, and the `meta.jskit.parent` it declared was never read. The route keeps `surface` as its own field, which still chooses where it is served; `meta.jskit.surface` is now only what the route's meta declares. Upgrading: a package route that relied on that copy to be a top-level root declares no parent, as a top-level page does.
- An array field's `minItems` and `maxItems` (json-rest-schema 1.0.18) failures carry their field codes, `kernel.validation.field.minItems` ("Must have at least {min} items.") and `kernel.validation.field.maxItems` ("Must have no more than {max} items."), with the library's `{ min | max, actual }` params; a field's `messages.minItems` and `messages.maxItems` override their English. Before, they reached the form as English without a code. New message keys: `jskit.kernel.validation.field.minItems`, `jskit.kernel.validation.field.maxItems`.
- An action's input refuses a field, at any depth, that declares `oneOf`, when the action is defined (and when a policy returns its input): json-rest-schema validates no `oneOf`, so a field listing its allowed values with it accepted any value. The error names the field and `enum`, which does restrict the value. A resource's `searchSchema` keeps `oneOf` for the fields a search matches; action outputs are not checked.

### Upgrading

- A production server that another site frames, such as an editor's preview of a production build, lists that site in `config.securityHeaders.frameAncestors`.
- Move `/api/health` after `createInstalledRuntime` and answer `503` when `runtime.health.check()` is not ok, as the foundations do.
- An action input field that lists its allowed values with `oneOf: [...]` now stops the action's definition; write `enum: [...]` instead, and its value is checked.
- The client address is Fastify's `request.ip`. Add `trustProxy: resolveTrustedProxies(runtimeEnv)` to the `Fastify({ ... })` call in the app's `server.js` (import `resolveTrustedProxies` from `@jskit-ai/kernel/server/http`), as the foundations do, and set `TRUSTED_PROXIES` to the proxies in front of a production server, the narrowest addresses or ranges that are only those proxies (a private range shared with other machines lets each of them choose its address). An app with its own proxy setting deletes it: its environment variable, the code that turned it into `trustProxy`, and any `trustProxy: true` or hop count, which now stop startup if moved into `TRUSTED_PROXIES`. A Fastify test stub serving routes that declare a limit needs an `async register() {}`.

- `createServerI18n()` also returns `resolveLocale(preferences)`: from a person's preferred locales (most preferred first, such as `ui_locales` or `Accept-Language`) the first the app has translations for, exactly or by language, else `en`.

## 0.2.0 - 2026-10-29

- Translation ready: every user-visible text is a message key with its English in `locales/en.json`, so an app translates it by supplying translation files only. With no translations, texts and behaviour are unchanged. See the guide "Translating a JSKIT app".
- `AppError` takes `{ code, params, messageCode, messageParams }`; every error response carries `code` and `params` next to the English `message`.
- `createValidationError` accepts `{ field: { code, params, message } }`; responses keep `details.fieldErrors` (English) and add `details.fieldErrorCodes`.
- Request validation maps Fastify/Ajv issues to `kernel.validation.*` field codes; resource-schema messages may be `{ code, message, params }`.
- Client: `useJskitText()` (`t`, `text`, `serverMessage`, `fieldErrorMessages`, Intl formatting helpers), `createTextError`, `registerJskitMessages`, and `bootstrapClientShellApp({ i18n })` for the app's composition-mode vue-i18n instance (optional peer dependency `vue-i18n`).
- Server: `createServerI18n({ appRoot, catalogs })` renders messages in a recipient's language from the app's `src/locales/<code>/jskit.json`.
- Shared: `formatMessage`, `catalogMessage`, `mergeCatalogs`, `flattenCatalog`, `messageKeyForCode`, `messageParams`.
- `serverMessage(source, fallback)` returns the fallback when the source has no message, as `message || fallback` did.

### Upgrading

- Apps translate nothing until they pass a vue-i18n instance; screens and texts stay as they were.
- Tests that compare whole error payloads exactly: every error response now has `params` (often `{}`), and some have `messageCode`/`messageParams` (a hidden 5xx answer carries `messageCode: "internal_server_error"`). Match the fields you need instead.
- Tests or code that expect `APP_ERROR` for a JSKIT error: errors that used to fall back to `APP_ERROR` now have their own dotted codes (listed in each package's Codes table), and `createValidationError` answers `validation_failed`. Codes that already existed keep their values.
- A plain-JSON (non-JSON:API) request body that fails its schema now answers `validation_failed` with `details.fieldErrors`, instead of `request_failed`, so JSKIT forms show the error next to the field.

### New message keys (74)

All keys in `locales/en.json` (exported as `./locales/en.json`) are new in this version.

<details><summary>Key list</summary>

- `jskit.errors.internal_server_error`
- `jskit.errors.request_failed`
- `jskit.errors.validation_failed`
- `jskit.errors.FST_ERR_VALIDATION`
- `jskit.errors.not_found`
- `jskit.errors.conflict`
- `jskit.errors.domain_validation_failed`
- `jskit.errors.AUTHENTICATION_REQUIRED`
- `jskit.errors.PERMISSION_DENIED`
- `jskit.errors.ACTION_AUTHENTICATION_REQUIRED`
- `jskit.errors.ACTION_CHANNEL_FORBIDDEN`
- `jskit.errors.ACTION_PERMISSION_DENIED`
- `jskit.errors.ACTION_SURFACE_FORBIDDEN`
- `jskit.errors.ACTION_NOT_FOUND`
- `jskit.errors.ACTION_VALIDATION_FAILED`
- `jskit.errors.ACTION_IDEMPOTENCY_KEY_REQUIRED`
- `jskit.errors.ACTION_ID_REQUIRED`
- `jskit.errors.ACTION_STREAM_KIND_REQUIRED`
- `jskit.errors.ACTION_VERSION_INVALID`
- `jskit.errors.ACTION_OUTPUT_VALIDATION_FAILED`
- `jskit.errors.unsupported_media_type`
- `jskit.kernel.validation.required`
- `jskit.kernel.validation.type`
- `jskit.kernel.validation.minLength`
- `jskit.kernel.validation.maxLength`
- `jskit.kernel.validation.minimum`
- `jskit.kernel.validation.maximum`
- `jskit.kernel.validation.exclusiveMinimum`
- `jskit.kernel.validation.exclusiveMaximum`
- `jskit.kernel.validation.multipleOf`
- `jskit.kernel.validation.pattern`
- `jskit.kernel.validation.format`
- `jskit.kernel.validation.enum`
- `jskit.kernel.validation.const`
- `jskit.kernel.validation.minItems`
- `jskit.kernel.validation.maxItems`
- `jskit.kernel.validation.additionalItems`
- `jskit.kernel.validation.uniqueItems`
- `jskit.kernel.validation.minProperties`
- `jskit.kernel.validation.maxProperties`
- `jskit.kernel.validation.additionalProperties`
- `jskit.kernel.validation.propertyNames`
- `jskit.kernel.validation.oneOf`
- `jskit.kernel.validation.anyOf`
- `jskit.kernel.validation.not`
- `jskit.kernel.validation.if`
- `jskit.kernel.validation.invalid`
- `jskit.kernel.validation.schemaFailed`
- `jskit.kernel.validation.recordIdInvalid`
- `jskit.kernel.validation.field.required`
- `jskit.kernel.validation.field.typeCastFailed`
- `jskit.kernel.validation.field.notNullable`
- `jskit.kernel.validation.field.minLength`
- `jskit.kernel.validation.field.maxLength`
- `jskit.kernel.validation.field.minValue`
- `jskit.kernel.validation.field.maxValue`
- `jskit.kernel.validation.field.pattern`
- `jskit.kernel.validation.field.enumValue`
- `jskit.kernel.validation.field.notAllowed`
- `jskit.kernel.validation.field.strictBoolean`
- `jskit.kernel.validation.field.rangeExceeded`
- `jskit.kernel.validation.field.notEmpty`
- `jskit.kernel.action.versionInvalid`
- `jskit.kernel.action.idRequired`
- `jskit.kernel.action.idempotencyKeyRequired`
- `jskit.kernel.route.handlerUnavailable`
- `jskit.kernel.surface.pathNotServed`
- `jskit.kernel.moduleLoad.appModuleNotDownloaded`
- `jskit.kernel.moduleLoad.appModuleFailed`
- `jskit.kernel.moduleLoad.pageNotDownloaded`
- `jskit.kernel.moduleLoad.pageFailed`
- `jskit.kernel.moduleLoad.notDownloaded`
- `jskit.kernel.moduleLoad.failed`
- `jskit.kernel.moduleLoad.reloadUnavailable`

</details>

### Codes (73)

Error, field-error and message codes this package sends, with their English. Undotted codes kept their existing values and render from `jskit.errors.<code>`.

| Code | English |
| --- | --- |
| `internal_server_error` | Internal server error. |
| `request_failed` | Request failed. |
| `validation_failed` | Validation failed. |
| `not_found` | Not found. |
| `conflict` | Conflict. |
| `domain_validation_failed` | Domain validation failed. |
| `AUTHENTICATION_REQUIRED` | Authentication required. |
| `PERMISSION_DENIED` | Forbidden. |
| `ACTION_AUTHENTICATION_REQUIRED` | Authentication required. |
| `ACTION_CHANNEL_FORBIDDEN` | Forbidden. |
| `ACTION_PERMISSION_DENIED` | Forbidden. |
| `ACTION_SURFACE_FORBIDDEN` | Forbidden. |
| `ACTION_NOT_FOUND` | Not found. |
| `ACTION_VALIDATION_FAILED` | Validation failed. |
| `ACTION_IDEMPOTENCY_KEY_REQUIRED` | Validation failed. |
| `ACTION_ID_REQUIRED` | Validation failed. |
| `ACTION_STREAM_KIND_REQUIRED` | Validation failed. |
| `ACTION_VERSION_INVALID` | Validation failed. |
| `ACTION_OUTPUT_VALIDATION_FAILED` | Action output validation failed. |
| `unsupported_media_type` | Content-Type must be {contentType}. |
| `kernel.validation.required` | must have required property '{missingProperty}' |
| `kernel.validation.type` | must be {type} |
| `kernel.validation.minLength` | must NOT have fewer than {limit} characters |
| `kernel.validation.maxLength` | must NOT have more than {limit} characters |
| `kernel.validation.minimum` | must be >= {limit} |
| `kernel.validation.maximum` | must be <= {limit} |
| `kernel.validation.exclusiveMinimum` | must be > {limit} |
| `kernel.validation.exclusiveMaximum` | must be < {limit} |
| `kernel.validation.multipleOf` | must be multiple of {multipleOf} |
| `kernel.validation.pattern` | must match pattern "{pattern}" |
| `kernel.validation.format` | must match format "{format}" |
| `kernel.validation.enum` | must be equal to one of the allowed values |
| `kernel.validation.const` | must be equal to constant |
| `kernel.validation.minItems` | must NOT have fewer than {limit} items |
| `kernel.validation.maxItems` | must NOT have more than {limit} items |
| `kernel.validation.additionalItems` | must NOT have more than {limit} items |
| `kernel.validation.uniqueItems` | must NOT have duplicate items (items ## {j} and {i} are identical) |
| `kernel.validation.minProperties` | must NOT have fewer than {limit} properties |
| `kernel.validation.maxProperties` | must NOT have more than {limit} properties |
| `kernel.validation.additionalProperties` | must NOT have additional properties |
| `kernel.validation.propertyNames` | property name must be valid |
| `kernel.validation.oneOf` | must match exactly one schema in oneOf |
| `kernel.validation.anyOf` | must match a schema in anyOf |
| `kernel.validation.not` | must NOT be valid |
| `kernel.validation.if` | must match "{failingKeyword}" schema |
| `kernel.validation.invalid` | Invalid value. |
| `kernel.validation.schemaFailed` | Schema validation failed. |
| `kernel.validation.recordIdInvalid` | Record id must be a canonical positive integer string. |
| `kernel.validation.field.required` | Field is required |
| `kernel.validation.field.typeCastFailed` | Value could not be cast to the required type. |
| `kernel.validation.field.notNullable` | Field cannot be null |
| `kernel.validation.field.minLength` | Length must be at least {min} characters. |
| `kernel.validation.field.maxLength` | Length must be no more than {max} characters. |
| `kernel.validation.field.minValue` | Value must be at least {min}. |
| `kernel.validation.field.maxValue` | Value must be no more than {max}. |
| `kernel.validation.field.pattern` | Value does not match the required pattern. |
| `kernel.validation.field.enumValue` | Value must match one of the allowed enum values. |
| `kernel.validation.field.notAllowed` | Field not allowed |
| `kernel.validation.field.strictBoolean` | Value must be a boolean. |
| `kernel.validation.field.rangeExceeded` | Numeric value is out of the allowed character range. |
| `kernel.validation.field.notEmpty` | Field cannot be empty. |
| `kernel.action.versionInvalid` | version must be an integer >= 1. |
| `kernel.action.idRequired` | actionId is required. |
| `kernel.action.idempotencyKeyRequired` | Idempotency key is required for this action. |
| `kernel.route.handlerUnavailable` | Route handler is not available in this runtime profile. |
| `kernel.surface.pathNotServed` | Path {path} is not served by {surface} surface server. |
| `kernel.moduleLoad.appModuleNotDownloaded` | App module did not download. The app may have been updated, or the network request failed. |
| `kernel.moduleLoad.appModuleFailed` | App module could not load. |
| `kernel.moduleLoad.pageNotDownloaded` | Page did not download. The app may have been updated, or the network request failed. |
| `kernel.moduleLoad.pageFailed` | Page could not load. |
| `kernel.moduleLoad.notDownloaded` | {label} did not download. The app may have been updated, or the network request failed. |
| `kernel.moduleLoad.failed` | {label} could not load. |
| `kernel.moduleLoad.reloadUnavailable` | The app cannot reload because the app server is not reachable. Restart the server, then click Retry or Reload. |
