@niscorp/moss 0.8.0 → 0.8.2

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 (39) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/DOCS.md +57 -15
  3. package/dist/{chunk-YZILOVCR.js → chunk-4M2MALV7.js} +18 -8
  4. package/dist/chunk-4M2MALV7.js.map +1 -0
  5. package/dist/{chunk-3DCTQKPQ.cjs → chunk-E6YAYR7G.cjs} +22 -5
  6. package/dist/chunk-E6YAYR7G.cjs.map +1 -0
  7. package/dist/{chunk-I4UOWER3.cjs → chunk-KLZYTSR2.cjs} +5 -5
  8. package/dist/{chunk-I4UOWER3.cjs.map → chunk-KLZYTSR2.cjs.map} +1 -1
  9. package/dist/{chunk-TMDKNZYL.cjs → chunk-QB7U2JDQ.cjs} +73 -63
  10. package/dist/chunk-QB7U2JDQ.cjs.map +1 -0
  11. package/dist/{chunk-3T422CCN.js → chunk-S4JSTWAE.js} +3 -3
  12. package/dist/{chunk-3T422CCN.js.map → chunk-S4JSTWAE.js.map} +1 -1
  13. package/dist/{chunk-6XC2MD7S.js → chunk-WTWRLOPK.js} +22 -5
  14. package/dist/chunk-WTWRLOPK.js.map +1 -0
  15. package/dist/{document-BYAY-Qle.d.ts → document-C3aS9uiW.d.ts} +2 -1
  16. package/dist/{document-DAE71J27.d.cts → document-deAs7Dre.d.cts} +2 -1
  17. package/dist/index.cjs +13 -13
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +2 -2
  21. package/dist/integrations.cjs +12 -5
  22. package/dist/integrations.cjs.map +1 -1
  23. package/dist/integrations.js +12 -5
  24. package/dist/integrations.js.map +1 -1
  25. package/dist/node.cjs +7 -7
  26. package/dist/node.d.cts +1 -1
  27. package/dist/node.d.ts +1 -1
  28. package/dist/node.js +3 -3
  29. package/dist/unverified.cjs +2 -2
  30. package/dist/unverified.js +1 -1
  31. package/dist/vite.cjs +8 -8
  32. package/dist/vite.d.cts +1 -1
  33. package/dist/vite.d.ts +1 -1
  34. package/dist/vite.js +3 -3
  35. package/package.json +7 -7
  36. package/dist/chunk-3DCTQKPQ.cjs.map +0 -1
  37. package/dist/chunk-6XC2MD7S.js.map +0 -1
  38. package/dist/chunk-TMDKNZYL.cjs.map +0 -1
  39. package/dist/chunk-YZILOVCR.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @niscorp/moss
2
2
 
3
+ ## 0.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 5e07fbb: An app can hand moss the functions that reconcile its canvases: `NiscApp.reconcilers`, nova `Reconciler`s by name, and a canvas's `reconcile` naming one — in the app's shell and in a page's. Every shell moss builds holds them (the app's and each page's, the one a document is drawn from and the socket's), and a reconciler is handed the shell `session.shell` is, which refuses what would change what the shell is made of. The boot is refused where a canvas names a reconciler the app does not hand over. A manifest without `reconcilers`, and a canvas without `reconcile`, are read and served as before.
8
+ - 98695fb: Resets of a shell that arrive while another waits for its turn are answered by that one: a burst of `reset` messages costs two builds at most, the one under way and one more. A reset is still never answered by the build already under way.
9
+
10
+ Before, every `reset` message from any terminal, signed in or not, queued a whole build of its own: 200 messages were 200 builds, each asking who the person is and what they hold, and running the app's `inputs`, `phrases`, `functions` and `seeds`.
11
+
12
+ - b43afd8: Integration intake holds an endpoint's URL to where it is routed. A path under `/integrations/<id>/` is refused when it resolves anywhere else (`..`, `.`, `%2e`, `\`) or holds a `{{…}}` template before its `?`, and a call to the app is refused unless it is one of the app's vex routes (`/api/vex`, `/api/<resource>/vex`).
13
+
14
+ Before, intake read only the start of the URL as written, while the in-process wire resolves it before routing: an approved integration could reach another integration's proxy, or any route of the app, as the signed-in person. An integration whose bundle has such an endpoint is refused, with a sentence for each, when it is next registered; one imported before this release keeps the endpoints it was imported with until then.
15
+
16
+ - 6ba0eeb: `server.invalidateTag(tag)` has every living shell adopt, in this process and in every other one the fabric reaches, as `refresh` does: a function or an action the new roles do not grant is no longer held, and no shell is reset.
17
+
18
+ Before, it only forgot the identity records, so after a role change applied through it a connected person kept calling the `fn:` endpoints their shell was built with until they disconnected. Each call now asks the app's `identity` again for every signed-in person with a living shell whose record is not held.
19
+
20
+ ## 0.8.1
21
+
22
+ ### Patch Changes
23
+
24
+ - 8eaea60: The docs say where `server.checkFunctions()` goes: after every route of the app's own, before it listens.
25
+
26
+ Nobody's shell makes its reads in-process, and the server takes no route once it has answered one: a route mounted after the check throws `Can not add a route since the matcher is already built.` moss's DOCS, nisc's AGENTS and the cli README say so.
27
+
3
28
  ## 0.8.0
4
29
 
5
30
  ### Minor Changes
package/DOCS.md CHANGED
@@ -67,6 +67,7 @@ type NiscApp = {
67
67
  functions?: (session: FunctionSession) => readonly FunctionDefinition[] | Record<string, FunctionHandler>;
68
68
  onSession?: (session: FunctionSession) => void;
69
69
  runs?: RunSink;
70
+ reconcilers?: Record<string, Reconciler>; // what reconciles a canvas that names one
70
71
  reactions?: readonly { table; op?; run }[]; // see "Reacting to writes"
71
72
  // what is added to moss that is not its core (see "Features"); `Feature` is not exported
72
73
  features?: readonly Feature[];
@@ -74,8 +75,8 @@ type NiscApp = {
74
75
  ```
75
76
 
76
77
  Every field is an artifact (authored data) except the code seams — `scope`,
77
- `identity`, `phrases`, `functions`, `onSession`, `runs`, a reaction's `run`
78
- — and `features`. Absent `shell`, the app serves data only
78
+ `identity`, `phrases`, `functions`, `onSession`, `runs`, `reconcilers`, a
79
+ reaction's `run` — and `features`. Absent `shell`, the app serves data only
79
80
  (no server shells). Absent `functions`, `fn:` endpoints fail loudly.
80
81
 
81
82
  - `assignments` is optional: an app that declares `identity` answers roles per
@@ -112,9 +113,14 @@ Every field is an artifact (authored data) except the code seams — `scope`,
112
113
  **`server.checkFunctions()`** builds nobody's shell once, drops it, and reads
113
114
  what its `functions(session)` returned, so what is wrong with the functions
114
115
  is refused or said before anyone is served. The app calls it once it holds
115
- the server and before it listens, as a session hook may reach for the
116
- server: `serve` of `@niscorp/moss/node` does, and so do `nisc dev`, `nisc
117
- build`, `nisc check` and `nisc start` after the project's `boot`. It says: `[moss] functions(session)
116
+ the server, as a session hook may reach for the server, after it has
117
+ mounted every route of its own, and before it listens. Nobody's shell
118
+ makes its reads in-process, and the server takes no route once it has
119
+ answered one: a route mounted after the check throws `Can not add a route
120
+ since the matcher is already built.` `serve` of `@niscorp/moss/node` calls
121
+ it, so do `nisc dev`, `nisc build` and `nisc check` after the project's
122
+ `boot`, and `nisc start` once the project's `routes` and the site are
123
+ mounted. It says: `[moss] functions(session)
118
124
  returned a map of handlers, which is deprecated: return a list of { id,
119
125
  description, execute }.`, or `[moss] functions with no description:
120
126
  auth.leave. Give each a description.` An empty description counts as none,
@@ -170,6 +176,19 @@ Every field is an artifact (authored data) except the code seams — `scope`,
170
176
  answer from.
171
177
  - `session` is the session that recorded the run, so a sink can write the
172
178
  record through `session.wire`, as the caller.
179
+ - `reconcilers` — nova `Reconciler`s by name. A canvas whose `reconcile` names
180
+ one, in the app's shell or a page's, is reconciled by it whenever a
181
+ `reconcile` step aims at it (nova's SHELL_DOCS.md, "A canvas that names its
182
+ own reconciler"): handed each row as written, it decides what is kept,
183
+ matched, moved and removed — several cards of one action on one list canvas,
184
+ matched by a key and kept in the list's order. Every shell moss builds holds
185
+ them, the app's and each page's, the one a document is drawn from and the
186
+ socket's: from one seed, a reconciler that answers the same rows the same
187
+ way places the same instances in both. A reconciler
188
+ is handed the shell `session.shell` is: what would change what the shell is
189
+ made of throws there. **The boot is refused** where a canvas names one the
190
+ app does not hand over: ``shell.canvases.1.reconcile: "keyed" is not a
191
+ reconciler the app hands over in `reconcilers` ``.
173
192
  - `grammars` — strata sequences for documents only this app defines the shape
174
193
  of (its kit's component props). See "Documents are read in this code's
175
194
  grammars" below.
@@ -209,7 +228,8 @@ A `CanvasSeed` is an action id or `{ action, input?, with? }`, and a
209
228
  `ShellCanvas` is nova's canvas config with `initial` widened to one seed or a
210
229
  list of candidates. Neither type is exported by name: `ShellManifest['canvases']`
211
230
  carries both. Of a list of candidates, the first action the principal holds
212
- mounts; a canvas none of whose candidates they hold starts empty.
231
+ mounts; a canvas none of whose candidates they hold starts empty. A canvas's
232
+ `reconcile` names one of the app's `reconcilers`.
213
233
 
214
234
  `components` is the kit as the server knows it: each component's name, with
215
235
  its `meta` (a `description`, and `propsSchema`, the zod schema of its props).
@@ -1349,8 +1369,16 @@ It's a Hono app — mount it, extend it, or hand it to a listener.
1349
1369
  app keeps for them, and the one a page built for each connection of theirs.
1350
1370
  `false` = no record was held.
1351
1371
  - `invalidateTag(tag): number` — forget every identity record wearing the
1352
- tag the app put on it (`IdentityRecord.tag`); answers how many. Forgets, does
1353
- not reset shells.
1372
+ tag the app put on it (`IdentityRecord.tag`); answers how many. Then every
1373
+ living shell adopts, as after `refresh` ("A change is the server's", under
1374
+ `shells` below): it is brought level with what its principal holds now, in
1375
+ place, so a function or an action their new roles do not grant is no longer
1376
+ held. No shell is reset: what people were in the middle of stays. Every
1377
+ living shell, not only those of the records forgotten: a record can be
1378
+ dropped while its shell lives (past `runtime.identityMax`, or unread for
1379
+ `runtime.identityIdleMs`), and no tag finds it then. So each call asks the app's
1380
+ `identity` again for every signed-in person with a living shell whose
1381
+ record is not held.
1354
1382
  - `identity(principal): Promise<IdentityRecord>` — who one principal is,
1355
1383
  resolved the way a request resolves it: `{ roles, scope, installed? }`,
1356
1384
  through the same cache the request path uses. `null` is nobody signed in.
@@ -1919,7 +1947,7 @@ for (const error of report.errors) console.error(`${error.check}: ${error.detail
1919
1947
  over it the layout of their own they marked in use), the
1920
1948
  fragments, the entries, the component names), the
1921
1949
  app's code a shell calls (`inputs`, `seeds`, `phrases`, `functions`,
1922
- `onSession`, `runs`), the wire for a token, and its limits. Everything in
1950
+ `onSession`, `runs`, `reconcilers`), the wire for a token, and its limits. Everything in
1923
1951
  that answer but who somebody is comes from the running manifest, which is
1924
1952
  asked once for each build and once for each adopt
1925
1953
  (`artifactsFor`, `src/artifactory/running.ts`): an action, a layout, a fragment and an entry
@@ -2010,9 +2038,13 @@ for (const error of report.errors) console.error(`${error.check}: ${error.detail
2010
2038
  `false` = they hold no shell, which is an answer, not an error. The
2011
2039
  replacement is built from what the shell was opened with (for a page's,
2012
2040
  the inputs of its path and its id seed), and a shell's resets run one
2013
- after another. A reset whose build throws, or has not landed within
2014
- `runtime.endpointTimeoutMs`, is logged and leaves the shell that stood;
2015
- the reset after it goes ahead.
2041
+ after another. A reset that arrives while another waits for its turn is
2042
+ answered by that one, whose build has read nothing yet; it is never
2043
+ answered by the build under way, which may have read what it builds from
2044
+ before the change the later reset is for. So a burst of resets costs two
2045
+ builds at most: the one under way and one more. A reset whose build
2046
+ throws, or has not landed within `runtime.endpointTimeoutMs`, is logged
2047
+ and leaves the shell that stood; the reset after it goes ahead.
2016
2048
  - What `ShellHost.session(token, principal)` returns (a type that is not
2017
2049
  exported by name: `Awaited<ReturnType<ShellHost['session']>>`):
2018
2050
  `{ shell, attach, detach, resync, dispatch, publish, back, popTo, reset }`. The living nova `Shell`,
@@ -2131,7 +2163,12 @@ server.nudge('usr_ada', 'notes-changed');
2131
2163
  canvases are the broken thing, so it must not travel through one. It is
2132
2164
  protocol-level, not app-level — no action declares it and no charter grants
2133
2165
  it — and it is answered by the frames it produces, not by an envelope of its
2134
- own.
2166
+ own. Any terminal may send it, signed in or not, and each one that is acted
2167
+ on is a whole build: who somebody is, what they hold, and the app's
2168
+ `inputs`, `phrases`, `functions` and `seeds`. Resets that arrive while one
2169
+ waits for its turn are answered by it (`reset(principal)`, under `shells`),
2170
+ so a burst costs two builds at most. Nothing limits how often: a terminal
2171
+ that sends one each time a build lands keeps one build of its shell running.
2135
2172
  - `back` names no canvas either, and for a related reason: back is one gesture
2136
2173
  over the whole shell, and the terminal that sends it has no idea which canvas
2137
2174
  moved last — it is served trees, not stacks. The shell decides what back
@@ -2615,9 +2652,14 @@ hash of one key (a unique index on `integrations.key_hash`).
2615
2652
  **What intake holds a bundle to**, before any of it is kept. It is upgraded by
2616
2653
  its grammar stamps and read by the bundle's schema. Each action is named
2617
2654
  `ext.<audience>.<integration>.<name>` under the integration's own id; each of
2618
- its endpoints is a fingerprint the app serves or a URL under
2655
+ its endpoints is a fingerprint the app serves, called on one of the app's vex
2656
+ routes (`/api/vex`, `/api/<resource>/vex`), or a URL under
2619
2657
  `/integrations/<id>/` (and not under `hook/`, the door that asks for no
2620
- session), and none is `fn:`; its layout composes what the app's kit has; and no
2658
+ session), and none is `fn:`. The path of that URL, up to its `?`, is written
2659
+ as it resolves, because the path a URL parser reads is the one that is
2660
+ routed: a `..`, `.`, `%2e` or `\` that would move it is refused, and so is a
2661
+ `{{…}}` template, which is filled in when the endpoint is called; one in the
2662
+ query is taken. Its layout composes what the app's kit has; and no
2621
2663
  chain of its steps, laid over the app's own actions, runs for ever. Then
2622
2664
  `extension` is read by the app's schema and held to the app's `check`. Every
2623
2665
  reason, moss's and the app's, is reported together, and any one refuses the
@@ -1,4 +1,4 @@
1
- import { entriesOf, receiveManifest, verifiedAtBoot, verifyManifest, withFragments, candidateOf, FRAME_LAYOUT_REF, canvasLayoutRef, functionsIn, charterOverFunctions, refusalOf, functionsWarning, layoutMisfits, freezeDeep, entryMisfits, sessionOn, endlessChains, actionLayoutRef, endShell, GENERATED_ID_PREFIX, layoutNameRefusal, actionOfLayoutRef, withLayoutInPlace, canvasesOf, treeOf, buildShell, SHELL_GONE, draftedIn, attach, holdGranted, layoutsOf, withVariants, variantLayouts } from './chunk-6XC2MD7S.js';
1
+ import { entriesOf, receiveManifest, verifiedAtBoot, verifyManifest, withFragments, candidateOf, FRAME_LAYOUT_REF, canvasLayoutRef, functionsIn, charterOverFunctions, refusalOf, functionsWarning, layoutMisfits, freezeDeep, entryMisfits, sessionOn, endlessChains, actionLayoutRef, endShell, GENERATED_ID_PREFIX, layoutNameRefusal, actionOfLayoutRef, withLayoutInPlace, canvasesOf, treeOf, buildShell, SHELL_GONE, draftedIn, attach, holdGranted, layoutsOf, withVariants, variantLayouts } from './chunk-WTWRLOPK.js';
2
2
  import { emitterOf, FabricMessageSchema, spanClock } from './chunk-QAHDSRPK.js';
3
3
  import { DEFAULT_TOKEN_KEY, sessionNameOf, SNAPSHOT_ELEMENT_ID, CLOSE_SHELL_FAILED, CLOSE_PROTOCOL_MISMATCH, CLOSE_INVALID_TOKEN, CLOSE_AT_CAPACITY, PROTOCOL_MIN, PROTOCOL, offeredSealed, offeredToken, ClientMessageSchema } from './chunk-4ZGAFZGS.js';
4
4
  import { z } from 'zod';
@@ -3009,7 +3009,12 @@ var replaceShell = async (host, cell) => {
3009
3009
  for (const { connection, wants } of carried) attach(built.live, connection, host.delta && wants);
3010
3010
  };
3011
3011
  var resetCell = (host, cell) => {
3012
- const turn = (cell.resetting ?? Promise.resolve()).then(() => replaceShell(host, cell));
3012
+ if (cell.hasWaitingReset === true) return;
3013
+ cell.hasWaitingReset = true;
3014
+ const turn = (cell.resetting ?? Promise.resolve()).then(() => {
3015
+ cell.hasWaitingReset = false;
3016
+ return replaceShell(host, cell);
3017
+ });
3013
3018
  cell.resetting = turn.catch((error) => console.error("[moss/shells] a reset failed to rebuild", error));
3014
3019
  };
3015
3020
  var shellsOf = (host, principal) => {
@@ -3119,7 +3124,8 @@ var hostConfig = (deps, shell, kept) => {
3119
3124
  ...app.phrases !== void 0 ? { phrases: app.phrases } : {},
3120
3125
  ...app.functions !== void 0 ? { functions: app.functions } : {},
3121
3126
  ...app.onSession !== void 0 ? { onSession: app.onSession } : {},
3122
- ...app.runs !== void 0 ? { runs: app.runs } : {}
3127
+ ...app.runs !== void 0 ? { runs: app.runs } : {},
3128
+ ...app.reconcilers !== void 0 ? { reconcilers: app.reconcilers } : {}
3123
3129
  },
3124
3130
  ...app.phraseKeys !== void 0 ? { phraseKeys: app.phraseKeys } : {},
3125
3131
  kept,
@@ -3284,14 +3290,18 @@ var operatorPrefix = (runtime) => {
3284
3290
  guardOperator(operator, { key: runtime.operatorKey ?? "", gate: runtime.operatorGate });
3285
3291
  return operator;
3286
3292
  };
3287
- var buildSignals = ({ fabric, identity, reset, adopt: adopt2, deliver }) => {
3293
+ var buildSignals = ({ fabric, identity, reset, adopt: adopt2, adoptAll: adoptAll2, deliver }) => {
3288
3294
  const origin = randomBytes(8).toString("hex");
3289
3295
  const applyInvalidateIdentity = (principal) => {
3290
3296
  const held = identity.invalidate(principal);
3291
3297
  reset(principal);
3292
3298
  return held;
3293
3299
  };
3294
- const applyInvalidateTag = (tag) => identity.invalidateTag(tag).length;
3300
+ const applyInvalidateTag = (tag) => {
3301
+ const forgotten = identity.invalidateTag(tag).length;
3302
+ adoptAll2();
3303
+ return forgotten;
3304
+ };
3295
3305
  const applyNudge = (principal, channel) => {
3296
3306
  deliver(principal, channel);
3297
3307
  };
@@ -3433,7 +3443,7 @@ var assemble = async ({ app, runtime, session, revokeSessions, data }, stops) =>
3433
3443
  mountRoutes(server, { app, session, credentials: registered.credentials, identity, running, data });
3434
3444
  const hosts = buildShellHosts({ app, runtime, identity, running, data, savedAs: saved.of, wire: createInternalWire(server), wrapWire: composeWireWraps(registered), revokeSessions });
3435
3445
  stops.push(hosts.stop);
3436
- const signals = buildSignals({ fabric: runtime.fabric, identity, reset: hosts.reset, adopt: hosts.adoptFor, deliver: hosts.deliver });
3446
+ const signals = buildSignals({ fabric: runtime.fabric, identity, reset: hosts.reset, adopt: hosts.adoptFor, adoptAll: hosts.adopt, deliver: hosts.deliver });
3437
3447
  running.onChange(() => {
3438
3448
  identity.invalidateAll();
3439
3449
  hosts.adopt();
@@ -3552,5 +3562,5 @@ var subscribeReactions = ({ app, onWrite, deliver }) => {
3552
3562
  };
3553
3563
 
3554
3564
  export { MOSS_SEQUENCE, createServer, exportDocuments, migrateTables, mintDevToken, mintSession, renderDocument, revokeAllFor, sessionCookies };
3555
- //# sourceMappingURL=chunk-YZILOVCR.js.map
3556
- //# sourceMappingURL=chunk-YZILOVCR.js.map
3565
+ //# sourceMappingURL=chunk-4M2MALV7.js.map
3566
+ //# sourceMappingURL=chunk-4M2MALV7.js.map