@niscorp/moss 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @niscorp/moss
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f834f3f: `evaluate` checks a config object once and only evaluates it after that; `prismTransform` is gone. **Breaking.**
8
+
9
+ BREAKING — approved by moccadroid, 2026-10-09: replace `prismTransform` with `evaluate` (`transform: evaluate`), and pass limits as `{ limits: … }`.
10
+
11
+ Prism had three ways to run a config, and the one a host was told to hand to its seam (`prismTransform`) was the one that reported worst, while the hosts on a hot path each wrapped `evaluate`, which checked the config on every call. There are two now, with one job each.
12
+
13
+ **`evaluate(config, source, options?)`** — for a config a program holds.
14
+ - The first time it is handed a config object it checks it and keeps its tree; the second time it prepares the tree as `compile` would; from then on a call only evaluates. Four fields picked and renamed, the same config object again: 3.5 µs before, 0.4 µs now. A nested choice on two fields: 18 µs before, 0.7 µs now. A config that is a new object on every call costs what it did.
15
+ - It is kept **by the object**: a config changed in place after its first call is not read again. Hand over a new object.
16
+ - Both arguments are `unknown`, so it is what a host's transform seam takes: `createTide({ transform: evaluate })`, `createUpgrader(grammars, { transform: evaluate })`.
17
+ - The third argument is `{ limits?, check? }`. Limits were the third argument themselves: `evaluate(config, source, { maxSteps: 100 })` is now `evaluate(config, source, { limits: { maxSteps: 100 } })`.
18
+ - `check: 'always'` is for writing a config, for tests and for tools: nothing is kept, the config is checked on every call, and the source must be plain JSON (a source holding `undefined`, a function, a `Date` or a non-finite number is refused with `E_TYPE`).
19
+ - An invalid config is a `PrismError` (`E_SCHEMA`) naming the part that is wrong, however deep the config. `prismTransform` threw zod's own error, and a `RangeError` for a config nested far past the limit.
20
+
21
+ `evaluateSafe` takes the same arguments.
22
+
23
+ **`compile` and `execute`** — for a config that is stored. Unchanged.
24
+
25
+ **`prismTransform` is removed**, from `@niscorp/prism` and from `@niscorp/prism/migrations`. What it added over `evaluate` was a check that the source is plain JSON; that check is now `check: 'always'`, and a seam's source is taken as it is.
26
+
27
+ **moss, nova, vex, loom, nisc, create-nisc and the cli move with it.** Each has Prism as a peer or a dependency, or has one of those that do, and a Prism at 0.3 is outside the range their last versions accept: an app takes them together. Nothing in vex, loom or the cli changed beyond that range.
28
+
29
+ moss's shell and nova's `$prism` binding called `evaluate` on every use and so paid the check each time: an endpoint's request and response under moss, and a `$prism` value on each draw and for each row of a list, are 8 to 45 times faster for the configs measured. tide's and strata's documentation name `evaluate` where they named `prismTransform`.
30
+
31
+ **What to change**
32
+ - `import { prismTransform } from '@niscorp/prism'` or `'@niscorp/prism/migrations'` → `import { evaluate } from '@niscorp/prism'`, and `transform: prismTransform` → `transform: evaluate`. Every app made by `create-nisc` has this in `src/dev/strata.ts`; the app's typecheck and `npm run strata` both stop on that line until it is changed.
33
+ - A third argument of limits becomes `{ limits: … }`.
34
+ - A wrapper that parsed the config before calling `evaluate` (`evaluate(ConfigSchema.parse(config), …)`) makes a new object on every call and so is checked on every call: hand `evaluate` the config itself.
35
+ - Code that changes a config object in place and evaluates it again must hand over a new object, or pass `{ check: 'always' }`.
36
+ - A host that relied on `prismTransform` refusing a source that is not plain JSON checks it itself, or passes `{ check: 'always' }`.
37
+
38
+ ### Patch Changes
39
+
40
+ - Updated dependencies [023bcf9]
41
+ - Updated dependencies [1db6df4]
42
+ - Updated dependencies [6d098e4]
43
+ - Updated dependencies [8b4d97e]
44
+ - Updated dependencies [f834f3f]
45
+ - Updated dependencies [b084e30]
46
+ - Updated dependencies [663d724]
47
+ - Updated dependencies [6512d91]
48
+ - Updated dependencies [7d682b9]
49
+ - Updated dependencies [d2e9d22]
50
+ - Updated dependencies [e0e8abc]
51
+ - Updated dependencies [7fe1135]
52
+ - @niscorp/prism@0.3.0
53
+ - @niscorp/nova@0.3.0
54
+ - @niscorp/vex@0.3.0
55
+
3
56
  ## 0.3.3
4
57
 
5
58
  ### Patch Changes
@@ -14,7 +14,7 @@ import { AsyncLocalStorage } from 'async_hooks';
14
14
  import { Hono } from 'hono';
15
15
  import { vex, VEX_LIVE_ENV } from '@niscorp/vex/hono';
16
16
  import { NOVA_SEQUENCE } from '@niscorp/nova/migrations';
17
- import { prismTransform, PRISM_SEQUENCE } from '@niscorp/prism/migrations';
17
+ import { PRISM_SEQUENCE } from '@niscorp/prism/migrations';
18
18
  import { headOf, placeHead } from '@niscorp/nova/document';
19
19
 
20
20
  // src/runtime.ts
@@ -1909,11 +1909,9 @@ var createShellHost = (ctx) => {
1909
1909
  ...shellManifest.fragments !== void 0 ? { fragments: shellManifest.fragments } : {},
1910
1910
  // The same seam the client shell used: prism evaluates endpoint
1911
1911
  // request/response transforms; `$.userId` and `$.today` are ambient,
1912
- // never authorable by a request.
1913
- transform: (config, source) => evaluate(
1914
- config,
1915
- source !== null && typeof source === "object" && !Array.isArray(source) ? { ...source, userId, today: today() } : source
1916
- ),
1912
+ // never authorable by a request. The config is the action's own object
1913
+ // on every call, so evaluate checks it once (the source is new each time).
1914
+ transform: (config, source) => evaluate(config, source !== null && typeof source === "object" && !Array.isArray(source) ? { ...source, userId, today: today() } : source),
1917
1915
  fetch: wire,
1918
1916
  functions,
1919
1917
  ...ctx.runtime.endpointTimeoutMs === void 0 ? {} : { endpointTimeoutMs: ctx.runtime.endpointTimeoutMs },
@@ -2492,7 +2490,7 @@ var grammarsOf = (app) => [
2492
2490
  PRISM_SEQUENCE,
2493
2491
  ...app.grammars ?? []
2494
2492
  ];
2495
- var createGrammarUpgrader = (app) => createUpgrader(grammarsOf(app), { transform: prismTransform });
2493
+ var createGrammarUpgrader = (app) => createUpgrader(grammarsOf(app), { transform: evaluate });
2496
2494
  var secretsEqual = (a, b) => timingSafeEqual(createHash("sha256").update(a).digest(), createHash("sha256").update(b).digest());
2497
2495
  var guardOperator = (operator, opts) => {
2498
2496
  const gate = opts.gate;
@@ -3402,5 +3400,5 @@ var exportDocuments = async (config) => {
3402
3400
  };
3403
3401
 
3404
3402
  export { DEFAULT_GENERATION_POLL_MS, DEFAULT_IDENTITY_IDLE_MS, DEFAULT_IDENTITY_MAX, DEFAULT_IDLE_MS, GENERATION_DDL, MOSS_SEQUENCE, SESSIONS_SEQUENCE, SNAPSHOT_ELEMENT_ID, TIDE_DDL, TIDE_SEQUENCE, TIDE_TABLES, auditClosure, buildContract, callIntegrationWith, contractAsMarkdown, copyPress, createAssertionSigner, createDataLayer, createGeneration, createIdentityCache, createPageRouter, createServer, createShellHost, createTideStore, describePlacements, devSession, documentHeaders, embedSnapshot, exportDocuments, filterInstalled, hashIntegrationKey, initIntegrations, initSessions, integrationByKey, integrationOfAction, listAttachments, listIntegrations, listPlacements, loadIntegrationActions, memoKeyOf, migrateTables, mintDevToken, mintIntegrationKey, mintSession, mintWrites, renderDocument, resolveCatalog, resolveCatalogForRoles, resolvePolicy, resolvePolicyAtReach, resolvePolicyForRoles, resolveRoles, resolveVariants, resolveVariantsForRoles, revokeAllFor, revokeSession, runIntake, sessionOf, sessionVerifierOf, shellNeedOf, verifyAssertion, verifyVariants, wearableOf, wireFabric };
3405
- //# sourceMappingURL=chunk-AUZMT3GL.js.map
3406
- //# sourceMappingURL=chunk-AUZMT3GL.js.map
3403
+ //# sourceMappingURL=chunk-R3QMJ3JF.js.map
3404
+ //# sourceMappingURL=chunk-R3QMJ3JF.js.map