@niscorp/moss 0.7.0 → 0.8.1

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 (51) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/DOCS.md +100 -58
  3. package/dist/{chunk-F45SFR7W.cjs → chunk-3DCTQKPQ.cjs} +56 -16
  4. package/dist/chunk-3DCTQKPQ.cjs.map +1 -0
  5. package/dist/{chunk-X2Q546EB.js → chunk-3T422CCN.js} +9 -3
  6. package/dist/chunk-3T422CCN.js.map +1 -0
  7. package/dist/{chunk-MYGVHWS5.js → chunk-6XC2MD7S.js} +51 -15
  8. package/dist/chunk-6XC2MD7S.js.map +1 -0
  9. package/dist/{chunk-Z2VA6AOE.cjs → chunk-I4UOWER3.cjs} +11 -5
  10. package/dist/chunk-I4UOWER3.cjs.map +1 -0
  11. package/dist/{chunk-C2DNDIQX.cjs → chunk-PVZMCEBX.cjs} +2 -2
  12. package/dist/chunk-PVZMCEBX.cjs.map +1 -0
  13. package/dist/{chunk-IMZZB4JE.js → chunk-QAHDSRPK.js} +2 -2
  14. package/dist/chunk-QAHDSRPK.js.map +1 -0
  15. package/dist/{chunk-DSTHFSTO.cjs → chunk-TMDKNZYL.cjs} +349 -159
  16. package/dist/chunk-TMDKNZYL.cjs.map +1 -0
  17. package/dist/{chunk-MTC46PGQ.js → chunk-YZILOVCR.js} +301 -111
  18. package/dist/chunk-YZILOVCR.js.map +1 -0
  19. package/dist/{document-AbQUbQaP.d.ts → document-BYAY-Qle.d.ts} +9 -9
  20. package/dist/{document-wHHxIXJz.d.cts → document-DAE71J27.d.cts} +9 -9
  21. package/dist/{index-Dml1klpZ.d.cts → index-CSEo7Tys.d.cts} +1 -0
  22. package/dist/{index-Dml1klpZ.d.ts → index-CSEo7Tys.d.ts} +1 -0
  23. package/dist/index.cjs +14 -14
  24. package/dist/index.d.cts +5 -5
  25. package/dist/index.d.ts +5 -5
  26. package/dist/index.js +3 -3
  27. package/dist/integrations.cjs +3 -3
  28. package/dist/integrations.d.cts +1 -1
  29. package/dist/integrations.d.ts +1 -1
  30. package/dist/integrations.js +1 -1
  31. package/dist/node.cjs +8 -8
  32. package/dist/node.d.cts +2 -2
  33. package/dist/node.d.ts +2 -2
  34. package/dist/node.js +4 -4
  35. package/dist/tide.d.cts +1 -1
  36. package/dist/tide.d.ts +1 -1
  37. package/dist/unverified.cjs +3 -3
  38. package/dist/unverified.js +2 -2
  39. package/dist/vite.cjs +9 -9
  40. package/dist/vite.d.cts +2 -2
  41. package/dist/vite.d.ts +2 -2
  42. package/dist/vite.js +4 -4
  43. package/package.json +8 -8
  44. package/dist/chunk-C2DNDIQX.cjs.map +0 -1
  45. package/dist/chunk-DSTHFSTO.cjs.map +0 -1
  46. package/dist/chunk-F45SFR7W.cjs.map +0 -1
  47. package/dist/chunk-IMZZB4JE.js.map +0 -1
  48. package/dist/chunk-MTC46PGQ.js.map +0 -1
  49. package/dist/chunk-MYGVHWS5.js.map +0 -1
  50. package/dist/chunk-X2Q546EB.js.map +0 -1
  51. package/dist/chunk-Z2VA6AOE.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,57 @@
1
1
  # @niscorp/moss
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8eaea60: The docs say where `server.checkFunctions()` goes: after every route of the app's own, before it listens.
8
+
9
+ 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.
10
+
11
+ ## 0.8.0
12
+
13
+ ### Minor Changes
14
+
15
+ - 2076f80: `session.draft.add` is what `session.draft.put` was. **Breaking.**
16
+
17
+ BREAKING — approved by moccadroid, 2026-10-18: rename `session.draft.put(...)` to `session.draft.add(...)`. Nothing else about it changes: it takes what `save` takes, what is added is in that one shell when the add answers, and `save`, `discard`, `show`, `remove` and `list` are as they were.
18
+
19
+ - cdc89cc: `server.checkFunctions()` reads the app's functions and refuses what is wrong with them before anyone is served. **Breaking.**
20
+
21
+ BREAKING — approved by moccadroid, 2026-10-18: `serve` of `@niscorp/moss/node`, and `nisc dev`, `nisc build`, `nisc check` and `nisc start`, refuse to come up on an action that calls a function the app has no function of, a charter `functions` deny that matches nothing, or two functions under one id. An app that hands a function only to signed-in sessions, with a shipped action calling it, hands it to every session (the function refuses whom it must), or is refused.
22
+
23
+ An app's functions are known only once a session is: `functions(session)` is called for each shell, and a session hook may reach for the server object, which the app holds only once `createServer` has answered. So the check is the app's to call, once it holds the server and before it listens; `serve` of `@niscorp/moss/node` calls it, and so do `nisc dev`, `nisc build`, `nisc check` and `nisc start` after the project's `boot`; each closes what it built where it refuses. It builds nobody's shell once, after everything is in force, and drops it. What that call returned is checked, and it refuses on:
24
+ - **an action, or a fragment a shell ships, that calls a function the app does not have**: `"home" calls "auth.leave", which the app has no function of`. Before, the call failed when a person pressed the button. An app with no `functions` has none. A set of actions handed over while the app runs is held to the same at that refresh.
25
+ - **a charter `functions` deny that matches nothing**: `Charter is incoherent over the app’s functions — refusing to serve:`.
26
+ - **two functions under one id**: `moss: functions(session) returned "auth.leave" twice.`
27
+
28
+ What the charter only warns of (a grant that names no function, a function no role grants), the functions with no description, and a map of handlers are said at that point, once.
29
+
30
+ The cost is one anonymous shell built, as any visitor who is not signed in causes. Every check reads nobody's functions: an app that hands a function only to signed-in sessions is refused where an action calls it.
31
+
32
+ ### Patch Changes
33
+
34
+ - edd3271: `session.answerIntent(writers, asked)` also replays a query that exists: `asked` may be `{ fingerprint, context }`.
35
+
36
+ It is answered as the caller, as an intent is, with what vex knows of the query: the context keys it binds, the ones the call left out (`meta.missingContext`), its warnings. The wire answers a replay with the rows alone. A model that proves a query before it builds on it learns from this why a replay came back empty.
37
+
38
+ - f461b98: What a person generated and nobody has used for long enough is deleted, with `runtime.artifactsUnusedMs`.
39
+ - A version of an artifact a person saved is stamped as used (`artifacts.last_used_at`, migration `nisc.moss/6`) when a shell is built for them, once an hour at most, through the same vex entries and row rule as the save itself.
40
+ - A sweep runs as the server comes up and then every hour: every artifact of a person whose newest version was neither saved nor used within `artifactsUnusedMs` is deleted, every version of it, and the saves left empty with them. What is published for everybody (`*`) never ages; what the build ships is not a row.
41
+ - Without the setting nothing is deleted. `0` or less refuses the boot.
42
+ - The sweep is one raw statement in moss (`data/aging.ts`), entered in the raw-SQL ledger: vex keeps every statement of its own to one principal's rows, and the sweep crosses them all.
43
+
44
+ - 37422bf: `server.defaults(publisher)` publishes every kind a person saves: an action, a fragment and a read, beside a layout.
45
+ - **An action or a fragment is given its id by whoever publishes it**, as a shipped one has one: `server.defaults(who).save([{ kind: 'action', id: 'promo', body }])`. One without an id is refused (`moss: a published action is given its id by whoever publishes it: name it.`), and so is one under `generated.`. The charter grants it by that id: a new id needs a grant, and one that is a shipped action's or fragment's replaces the build's for everybody until it is reset.
46
+ - **A read vex wrote is published under its fingerprint**, `save([{ kind: 'read', id: '<fingerprint>' }])`, and is answered to everybody, nobody signed in included, after what the caller saved themselves. One under the fingerprint of a shipped entry is refused. A generated action anybody saves may replay it.
47
+ - **Checked as a person's save is, as the publisher, and then as a manifest.** An action's `fn:` calls are ones the publisher's roles grant and its reads ones they may replay; then the whole set in force is verified as a set handed over is, and a holder whose roles do not grant a call refuses the publish: `Publish refused — actions call functions the app does not have, or that their holders’ charter does not grant:`.
48
+ - **A default that no longer passes under a new build is left out, and the build's copies stand**, with a line said once per read of the rows: `[moss] what is published for everybody is left out, and the build’s copies stand: …`.
49
+ - `publishedArtifacts(saved, publisher)` of the running manifest takes who publishes, for the roles and reads a publish is held to; `server.defaults` resolves them from the publisher's principal.
50
+
51
+ - Updated dependencies [63b9ab5]
52
+ - Updated dependencies [6a62604]
53
+ - @niscorp/nova@0.5.0
54
+
3
55
  ## 0.7.0
4
56
 
5
57
  ### Minor Changes
package/DOCS.md CHANGED
@@ -107,40 +107,53 @@ Every field is an artifact (authored data) except the code seams — `scope`,
107
107
  endpoint name, `execute` is what an `fn:` endpoint calls, `(data, signal) =>
108
108
  Promise<unknown>`, and `description` says what it does and what to send, for
109
109
  the model that writes a call to it (`session.functions()` lists it). Two
110
- under one id are refused when a shell is built: `moss: functions(session)
111
- returned "auth.leave" twice.` A map of handlers by id still works and is
112
- deprecated. The first shell a process builds says once what to change, read
113
- off what that first session's `functions(session)` returned: `[moss]
114
- functions(session) returned a map of handlers, which is deprecated: return a
115
- list of { id, description, execute }.`, or `[moss] functions with no
116
- description: auth.leave. Give each a description.` An empty description
117
- counts as none, and a function given by a map has none. **A shell holds only the functions
110
+ under one id are refused: `moss: functions(session) returned "auth.leave"
111
+ twice.` A map of handlers by id still works and is deprecated.
112
+ **`server.checkFunctions()`** builds nobody's shell once, drops it, and reads
113
+ what its `functions(session)` returned, so what is wrong with the functions
114
+ is refused or said before anyone is served. The app calls it once it holds
115
+ the server, as a session hook may reach for the server, after it has
116
+ mounted every route of its own, and before it listens. Nobody's shell
117
+ makes its reads in-process, and the server takes no route once it has
118
+ answered one: a route mounted after the check throws `Can not add a route
119
+ since the matcher is already built.` `serve` of `@niscorp/moss/node` calls
120
+ it, so do `nisc dev`, `nisc build` and `nisc check` after the project's
121
+ `boot`, and `nisc start` once the project's `routes` and the site are
122
+ mounted. It says: `[moss] functions(session)
123
+ returned a map of handlers, which is deprecated: return a list of { id,
124
+ description, execute }.`, or `[moss] functions with no description:
125
+ auth.leave. Give each a description.` An empty description counts as none,
126
+ and a function given by a map has none. **A shell holds only the functions
118
127
  its principal's roles grant**, in the charter's `functions` part (names or
119
128
  globs, with `extends` and `deny`, as `actions`): a role with none may call
120
129
  none, and an `fn:` endpoint to one it does not grant fails when it is called.
121
130
  What a living shell holds follows the roles an adopt answers, as its actions
122
131
  do.
123
132
  - **The boot is refused** where somebody holds an action that calls a
124
- function their roles do not grant. It reads the `fn:` endpoints of the
125
- actions held by each role on its own, each combination `wearable` or
133
+ function their roles do not grant, and **`server.checkFunctions()` refuses**
134
+ where an action, or a fragment the shells ship, calls a function the app
135
+ does not have (`"home" calls "auth.leave", which the app has no function
136
+ of`); an app with no `functions` has none. It reads the `fn:` endpoints of
137
+ the actions held by each role on its own, each combination `wearable` or
126
138
  `assignments` lists, and `public`, and of the fragments the shells ship,
127
139
  and lists every call that is missing: `"member" hold "chrome.topbar",
128
- which calls "auth.leave": their functions do not grant it`. A name with a
129
- template in it (`fn: '{{$.saveFn}}'`) is worked out when it is called, and
130
- the shell's map decides then.
140
+ which calls "auth.leave": their functions do not grant it`. A set handed
141
+ over while the app runs is held to the same. A name with a template in it
142
+ (`fn: '{{$.saveFn}}'`) is worked out when it is called, and the shell's map
143
+ decides then.
131
144
  - **`functions: ['*']`** grants every function, as an app had before this
132
145
  part existed. The boot says so for each role that has it: `role "member"
133
146
  allows every function ('*'): the generated actions of the people who hold
134
147
  it, or a role that extends it, may call any it does not deny`. Grant each
135
148
  role the functions it calls.
136
- - **A grant that names no function** is said at the first shell a process
137
- builds, when the names of the app's functions are known, with the
138
- charter's own checks: `[moss] charter: role "member" allows "notes.ad"
139
- (functions) which matches nothing`, a deny that matches nothing, and a
140
- function no role grants. They are read against the names that shell's
141
- `functions(session)` returned: an app whose functions differ by who the
142
- session is for may see a grant reported that another session's names
143
- would match.
149
+ - **The charter's own checks over the functions run in `checkFunctions`
150
+ too**, against what nobody's shell was given: a deny that matches nothing
151
+ refuses (`Charter is incoherent over the app’s functions — refusing to
152
+ serve:`), and a grant that names no function or a function no role grants
153
+ is said (`[moss] charter: role "member" allows "notes.ad" (functions)
154
+ which matches nothing`). Every check reads nobody's functions: an app that
155
+ hands a function only to signed-in sessions is refused where an action
156
+ calls it, and a later session that adds one is not read again.
144
157
  - `onSession(session)` — called once per living app shell, for session code
145
158
  that is not an endpoint (an observer, a roster). It runs before the shell
146
159
  finishes building, so it must not touch `session.shell` synchronously. Its
@@ -440,10 +453,18 @@ functions: (session) => [
440
453
  catalog: `/catalog`, the socket's hello and `server.catalogOf` answer what
441
454
  the charter grants. What somebody generated is listed by
442
455
  `session.artifacts.list('action')`.
456
+ - **It ages out when nobody uses it.** With `runtime.artifactsUnusedMs`, a
457
+ version of an artifact a person saved is stamped as used when a shell is
458
+ built for them (`last_used_at`, once an hour at most), and every artifact of
459
+ theirs whose newest version was neither saved nor used within that time is
460
+ deleted, every version of it, by a sweep that runs as the server comes up and
461
+ then every hour. What is published for everybody never ages, and what the
462
+ build ships is not a row. Without the setting nothing is deleted. A limit of
463
+ `0` or less refuses the boot.
443
464
  - **It reaches its owner's open shells a moment after the save answers**, as a
444
465
  saved layout does, and not before: a function that saves an action and
445
466
  opens it in the same call finds it not there yet. One that is to be seen at
446
- once is put into the draft (`session.draft`, below), which answers when the
467
+ once is added to the draft (`session.draft`, below), which answers when the
447
468
  shell has it.
448
469
  - **What it defines replays reads, and calls the functions its owner's roles
449
470
  grant.** An `fn:` endpoint names a function its owner's roles grant in the
@@ -544,7 +565,7 @@ its mapping, its shape and its intent.
544
565
  replay is refused, where one over such an entry the app ships is left out.
545
566
  - **A generated action may replay a read its owner saved**, as it may an entry
546
567
  the app ships that its owner may replay. A draft takes a read too, and an
547
- action put into the same draft may replay it.
568
+ action added to the same draft may replay it.
548
569
  - **What is refused**, in a sentence: a read with no id, or with a body; one
549
570
  under the fingerprint of an entry the app ships or was handed; one vex did
550
571
  not write for a request; a write; one whose mapping vex kept no config for
@@ -681,7 +702,7 @@ is (a reset, an idle shell that was dropped, a restart).
681
702
 
682
703
  ```typescript
683
704
  type SessionDraft = {
684
- put: (artifacts: readonly { kind: ArtifactKind; id?: string; body: unknown }[]) => Promise<{ step: number; artifacts: readonly { kind: ArtifactKind; id: string }[] }>;
705
+ add: (artifacts: readonly { kind: ArtifactKind; id?: string; body: unknown }[]) => Promise<{ step: number; artifacts: readonly { kind: ArtifactKind; id: string }[] }>;
685
706
  list: () => readonly { kind: ArtifactKind; id: string; body: unknown }[];
686
707
  remove: (kind: ArtifactKind, id: string) => Promise<{ step: number }>;
687
708
  show: (step: number) => Promise<void>;
@@ -696,37 +717,37 @@ functions: (session) => [
696
717
  id: 'screen.try',
697
718
  description: 'Shows an action the person is trying out, without keeping it. Send { action }.',
698
719
  execute: async ({ action }) => {
699
- const put = await session.draft.put([{ kind: 'action', body: action }]);
700
- session.shell.push('main', put.artifacts[0].id);
720
+ const added = await session.draft.add([{ kind: 'action', body: action }]);
721
+ session.shell.push('main', added.artifacts[0].id);
701
722
  },
702
723
  },
703
724
  { id: 'screen.keep', description: 'Keeps what the person is trying out.', execute: async () => session.draft.save() },
704
725
  ],
705
726
  ```
706
727
 
707
- - **`put` takes what `session.artifacts.save` takes and refuses what it
728
+ - **`add` takes what `session.artifacts.save` takes and refuses what it
708
729
  refuses**, with the same sentences. Each artifact is checked beside what is
709
730
  in force for the principal with the draft laid over, so a layout may be for
710
731
  an action that is itself in the draft. A draft is one shell's, so what is
711
- put into it is held to the components of that shell, where a save is held to
732
+ added to it is held to the components of that shell, where a save is held to
712
733
  those of any shell of the app. A new action or fragment gets its
713
734
  `generated.` id here, and keeps it when the draft is saved. An `id` names
714
735
  one in the draft, or one the principal saved: a new take of it, which stands
715
736
  in for the saved one in this shell until the draft is saved or the take is
716
- taken out. A put that marks a layout `use: true` takes the mark off the
737
+ taken out. An add that marks a layout `use: true` takes the mark off the
717
738
  draft's others for that ref, as a save does.
718
- - **A put is in the shell when it answers.** The function that put an action
739
+ - **What is added is in the shell when the add answers.** The function that added an action
719
740
  opens it on its next line. An open screen follows a drafted layout with what
720
- was typed into it kept, as it follows a saved one. A put the shell could not
741
+ was typed into it kept, as it follows a saved one. An add the shell could not
721
742
  take rejects, and the draft is as it was.
722
743
  - **What the shell draws**: what is in the draft, then what `session.artifacts`
723
744
  would draw. A drafted layout marked `use: true` is drawn in place of a saved
724
745
  one that is marked for the same ref.
725
746
  - **`list`** answers what the draft holds, and **`remove`** takes one out of
726
747
  it; what is under it is drawn again. **`discard`** empties it.
727
- - **Each put or removal is a numbered step**, from 1. **`show(step)`** has the
748
+ - **Each add or removal is a numbered step**, from 1. **`show(step)`** has the
728
749
  shell show the draft as it was after that step, and `show(0)` none of it. A
729
- put or a removal while an earlier step is shown goes on from that step: the
750
+ add or a removal while an earlier step is shown goes on from that step: the
730
751
  steps after it are dropped. The steps are the draft's and are saved nowhere.
731
752
  - **`save`** is one save of what the draft holds, as the principal's own and
732
753
  under the ids it had, checked once more. The draft is then empty and the
@@ -753,6 +774,7 @@ type NiscRuntime = {
753
774
  migrations?: 'apply' | 'verify'; // the boot's ledgered run; default 'apply'
754
775
  tables?: readonly Sequence[]; // the app's own table sequences, in that same run
755
776
  shellIdleMs?: number; // idle shell eviction; default 30 min, `0` disables
777
+ artifactsUnusedMs?: number; // delete what a person generated once nobody has loaded it for this long; default never
756
778
  anonymousShellMax?: number; // shells for nobody signed in alive at once; default 1,000, `Infinity` is no limit
757
779
  endpointTimeoutMs?: number; // a server shell's endpoint call, and the build of a shell; default nova's, 30s
758
780
  sessionRevalidateMs?: number; // live-socket re-verify; default 60s, `0` disables
@@ -1249,17 +1271,24 @@ It's a Hono app — mount it, extend it, or hand it to a listener.
1249
1271
  a set changes through `replaceActions`.
1250
1272
  - `defaults(publisher): SessionArtifacts` — what is published for everybody,
1251
1273
  with the five calls a session's `artifacts` has (`save`, `list`, `history`,
1252
- `restore`, `reset`) and the same body: `server.defaults(who).save([{ kind:
1253
- 'layout', body: { ref: 'action/<id>', layout, use: true } }])` publishes a
1254
- layout for an action, and every shell draws it under that action's ref
1255
- unless its principal has a layout of their own in use or their roles hold a
1256
- layout variant. With `ref: 'frame'` it publishes the layout of the app's own
1257
- shell, and with `ref: 'canvas/<id>'` that of one of its canvases: each is
1258
- drawn for everybody who has none of their own in use. Several may be kept for one ref and the one marked `use:
1259
- true` is drawn; every publish is a version; a `reset` shows the build's
1260
- again. A layout is the one kind that is published: an action or a fragment
1261
- is refused here. `publisher` is who the publish is made by, and is kept with the save
1262
- (`artifact_saves.created_by`); an empty one is refused.
1274
+ `restore`, `reset`), the same kinds and the same bodies. A published default
1275
+ is drawn, opened or replayed by everybody, nobody signed in included, under
1276
+ what a person has of their own; every publish is a version, and a `reset`
1277
+ shows the build's again. **A layout:** `server.defaults(who).save([{ kind:
1278
+ 'layout', body: { ref: 'action/<id>', layout, use: true } }])` is drawn under
1279
+ that action's ref unless its principal has a layout of their own in use or
1280
+ their roles hold a layout variant; `ref: 'frame'` and `ref: 'canvas/<id>'`
1281
+ publish the layouts of the app's own shell. **An action or a fragment** is
1282
+ given its id by whoever publishes it, as a shipped one has one: `save([{
1283
+ kind: 'action', id: 'promo', body }])`; one without an id is refused, and so
1284
+ is one under `generated.`. The charter grants it by that id, so a new id
1285
+ needs a grant and one that is a shipped action's or fragment's replaces the
1286
+ build's for everybody until it is reset. **A read** vex wrote is published
1287
+ under its fingerprint, `save([{ kind: 'read', id: '<fingerprint>' }])`, and is
1288
+ answered to everybody after what the caller saved themselves; one under the
1289
+ fingerprint of a shipped entry is refused. `publisher` is who the publish is
1290
+ made by, kept with the save (`artifact_saves.created_by`); an empty one is
1291
+ refused.
1263
1292
  **No session can publish.** The rows are those of one principal no caller
1264
1293
  is (`*`), and every write a session makes carries its own `userId`: vex's
1265
1294
  row rule, the one a person's own rows are under. Only the app's own code on
@@ -1268,20 +1297,33 @@ It's a Hono app — mount it, extend it, or hand it to a listener.
1268
1297
  the session's principal as `publisher`, and grants the action that calls
1269
1298
  that function to the roles that may. A function is declared before the
1270
1299
  server exists, so the app keeps the server where its functions can reach it.
1271
- A layout is checked when it is published as one is when it is saved, held to
1272
- every action in force with the layout it is built with: a ref no such action
1273
- keeps a layout under is refused, and so is what a save refuses. When a shell
1274
- is built it is checked again for that shell and that principal: one for an
1275
- action they do not hold is not loaded, and one that no longer passes is left
1276
- out with a line (`[moss] the layout "…" published for everybody is left out:
1277
- …`, said once for each time the rows are read, not at every shell).
1278
- One read of the rows answers every shell a process builds. A boot makes it,
1279
- and fails if it cannot. The first shell built after this process publishes,
1280
- or after the generation pointer moves, makes it again, and a read that fails
1281
- fails that shell and is made again by the next. A publish has every living
1282
- shell adopt, as `refresh` does, and moves the pointer, whether or not the
1283
- rows can be read back: every other process on the same database follows
1284
- within one poll ([Many processes](#many-processes)).
1300
+ **What is published is checked three times.** At the publish, as a person's
1301
+ save is: a layout against every action in force and every shell's kit, an
1302
+ action or a fragment as a generated one is, as the publisher (its `fn:`
1303
+ calls are ones the publisher's roles grant, its reads ones they may replay,
1304
+ no write), and then the whole as a manifest, as a set handed over is:
1305
+ `Publish refused — actions call functions the app does not have, or that
1306
+ their holders’ charter does not grant:` lists a holder whose roles do not
1307
+ grant a call. When the rows are read, the same again, and what does not pass
1308
+ any more is left out with a line, said once for each read of the rows: a
1309
+ layout, an action or a fragment on its own where its own check refuses it
1310
+ (`[moss] the action "…" published for everybody is left out: …`), and the
1311
+ actions and fragments all together where the manifest refuses them (`[moss]
1312
+ what is published for everybody is left out, and the build’s copies stand:
1313
+ …`). Once `checkFunctions` has read the app's functions, the rows are read
1314
+ again against them: a published action calling a function a new build
1315
+ dropped is left out, and the boot is not refused. When a shell is built, for
1316
+ that shell and that principal: a layout for an action they do not hold is
1317
+ not loaded, and a published fragment a shell cannot draw is left out of that
1318
+ shell (`[moss] the fragment "…" published for everybody is left out of a
1319
+ shell that cannot draw it: …`).
1320
+ One read of the rows answers every shell a process builds, and every save a
1321
+ session makes. A boot makes it, and fails if it cannot. The first shell built
1322
+ after this process publishes, or after the generation pointer moves, makes it
1323
+ again, and a read that fails fails that shell and is made again by the next.
1324
+ A publish has every living shell adopt, as `refresh` does, and moves the
1325
+ pointer, whether or not the rows can be read back: every other process on
1326
+ the same database follows the pointer and reads them.
1285
1327
  - `catalogOf(principal): Promise<{ ids, hash }>` — what a principal holds of the
1286
1328
  actions in force: `{ ids, hash }`, the granted action ids sorted, with a
1287
1329
  content-hash version token (equal hash, equal application). The principal is
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkC2DNDIQX_cjs = require('./chunk-C2DNDIQX.cjs');
3
+ var chunkPVZMCEBX_cjs = require('./chunk-PVZMCEBX.cjs');
4
4
  var chunk3RIWTXGI_cjs = require('./chunk-3RIWTXGI.cjs');
5
5
  var charter = require('@niscorp/charter');
6
6
  var nova = require('@niscorp/nova');
@@ -66,6 +66,11 @@ var candidateOf = (shipped, inForce, grants) => ({
66
66
  entries: inForce.entries,
67
67
  profiles: vex.scopeProfiles(shipped.behaviors ?? {})
68
68
  });
69
+ var withFragments = (candidate, fragments) => ({
70
+ ...candidate,
71
+ fragmentIds: /* @__PURE__ */ new Set([...candidate.fragmentIds, ...Object.keys(fragments)]),
72
+ fragmentCalls: [...candidate.fragmentCalls, ...Object.entries(fragments).map(([id, fragment]) => ({ id, calls: functionsCalledBy(fragment) }))]
73
+ });
69
74
  var unreadActions = (actions) => Object.entries(actions).flatMap(([id, definition]) => {
70
75
  if (strata.exceedsDepth(definition)) return [{ id, why: strata.depthRefusal() }];
71
76
  const parsed = nova.ActionDefinitionSchema.safeParse(definition);
@@ -95,7 +100,7 @@ var generatedIdErrors = (actions) => Object.entries(actions).flatMap(([listed, d
95
100
  });
96
101
  var fragmentIdErrors = (actions, fragmentIds) => Object.entries(actions).flatMap(([listed, definition]) => {
97
102
  const taken = [listed, definition.id].find((id) => fragmentIds.has(id));
98
- return taken === void 0 ? [] : [`"${taken}" is the id of an action and of a fragment a shell ships: an id names one of the two`];
103
+ return taken === void 0 ? [] : [`"${taken}" is the id of an action and of a fragment: an id names one of the two`];
99
104
  });
100
105
  var reachErrors = (entries, profiles) => {
101
106
  const unknown = entries.flatMap((entry2) => entry2.reach !== void 0 && !profiles.has(entry2.reach) ? [`${entry2.fingerprint} declares reach "${entry2.reach}"`] : []);
@@ -129,6 +134,14 @@ var functionGrantErrors = (candidate) => {
129
134
  }
130
135
  return [...errors];
131
136
  };
137
+ var unknownFunctionErrors = (candidate) => {
138
+ const known = candidate.functionIds;
139
+ if (known === void 0) return [];
140
+ return [
141
+ ...Object.entries(candidate.actions).flatMap(([id, definition]) => functionsCalledBy(definition).map((fn) => ({ by: `"${id}"`, fn }))),
142
+ ...candidate.fragmentCalls.flatMap(({ id, calls }) => calls.map((fn) => ({ by: `the fragment "${id}"`, fn })))
143
+ ].flatMap(({ by, fn }) => known.has(fn) ? [] : [`${by} calls "${fn}", which the app has no function of`]);
144
+ };
132
145
  var everyFunctionGranted = (charter$1) => Object.entries(charter$1).flatMap(
133
146
  ([role, def]) => charter.normalizeRole(def, "functions").allow.includes("*") ? [`role "${role}" allows every function ('*'): the generated actions of the people who hold it, or a role that extends it, may call any it does not deny`] : []
134
147
  );
@@ -151,7 +164,7 @@ var verifyManifest = (candidate) => {
151
164
  ...found("actions", generatedIdErrors(read.actions)),
152
165
  ...found("actions", fragmentIdErrors(read.actions, read.fragmentIds)),
153
166
  ...found("charter", charter$1.errors.map((error) => `${error.rule}: ${error.detail}`)),
154
- ...found("functions", functionGrantErrors(read)),
167
+ ...found("functions", [...unknownFunctionErrors(read), ...functionGrantErrors(read)]),
155
168
  ...found("reach", reachErrors(read.entries, read.profiles)),
156
169
  ...found("variants", verifyVariants(read))
157
170
  ],
@@ -162,19 +175,42 @@ var verifyManifest = (candidate) => {
162
175
  charter: charter$1
163
176
  };
164
177
  };
178
+ var verifiedAtBoot = (candidate) => {
179
+ const report = verifyManifest(candidate);
180
+ for (const line of report.said) console.error(`[moss] ${line}`);
181
+ const refused = refusalOf(report, "boot");
182
+ if (refused !== void 0) throw new Error(refused);
183
+ return report;
184
+ };
185
+ var charterOverFunctions = (charter$1, universes, ids) => {
186
+ const before = charter.verifyCharter(charter$1, universes);
187
+ const known = new Set([...before.errors, ...before.warnings].map((issue) => issue.detail));
188
+ const after = charter.verifyCharter(charter$1, { ...universes, functions: ids });
189
+ return {
190
+ errors: after.errors.flatMap((issue) => known.has(issue.detail) ? [] : [`${issue.rule}: ${issue.detail}`]),
191
+ warnings: after.warnings.flatMap((issue) => known.has(issue.detail) ? [] : [issue.detail])
192
+ };
193
+ };
165
194
  var verifyApp = (app, grants) => verifyManifest(candidateOf(app, { actions: app.actions, entries: entriesOf(app) }, grants));
166
195
  var HEADLINES = {
167
196
  boot: {
168
197
  actions: "Actions are not ones nova reads \u2014 refusing to serve:",
169
198
  charter: "Charter is incoherent \u2014 refusing to serve:",
170
- functions: "Roles hold actions that call functions their charter does not grant \u2014 refusing to serve:",
199
+ functions: "Actions call functions the app does not have, or that their holders\u2019 charter does not grant \u2014 refusing to serve:",
171
200
  reach: "Entries declare a reach no table offers \u2014 refusing to serve:",
172
201
  variants: "Layout variants are incoherent \u2014 refusing to serve:"
173
202
  },
203
+ publish: {
204
+ actions: "Publish refused \u2014 actions nova does not read:",
205
+ charter: "Publish refused \u2014 charter incoherent over what is published:",
206
+ functions: "Publish refused \u2014 actions call functions the app does not have, or that their holders\u2019 charter does not grant:",
207
+ reach: "Publish refused \u2014 entries declare a reach no table offers:",
208
+ variants: "Publish refused \u2014 layout variants incoherent:"
209
+ },
174
210
  refresh: {
175
211
  actions: "Refresh refused \u2014 actions nova does not read:",
176
212
  charter: "Refresh refused \u2014 charter incoherent over the new artifacts:",
177
- functions: "Refresh refused \u2014 roles hold actions that call functions their charter does not grant:",
213
+ functions: "Refresh refused \u2014 actions call functions the app does not have, or that their holders\u2019 charter does not grant:",
178
214
  reach: "Refresh refused \u2014 entries declare a reach no table offers:",
179
215
  variants: "Refresh refused \u2014 layout variants incoherent:"
180
216
  }
@@ -423,10 +459,10 @@ var sessionDraftOn = ({ saving, liveOf, adopt }) => {
423
459
  return steps.length;
424
460
  };
425
461
  return {
426
- put: (artifacts) => inTurn(async () => {
462
+ add: (artifacts) => inTurn(async () => {
427
463
  const live = standing();
428
- const answered = await savingOrRefuse().put(artifacts, draftedIn(live.draft));
429
- return { step: await stepped(live, answered.drafted), artifacts: answered.put };
464
+ const answered = await savingOrRefuse().add(artifacts, draftedIn(live.draft));
465
+ return { step: await stepped(live, answered.drafted), artifacts: answered.added };
430
466
  }),
431
467
  list: () => draftedIn(standing().draft),
432
468
  remove: (kind, id) => inTurn(async () => {
@@ -593,7 +629,7 @@ var instrumentFunctions = (fns, emit, principal) => Object.fromEntries(
593
629
  Object.entries(fns).map(([name, handler]) => [
594
630
  name,
595
631
  async (data, signal) => {
596
- const clock = chunkC2DNDIQX_cjs.spanClock();
632
+ const clock = chunkPVZMCEBX_cjs.spanClock();
597
633
  const hasPrincipal = principal !== null;
598
634
  try {
599
635
  const out = await handler(data, signal);
@@ -761,10 +797,10 @@ var mountedCanvases = (declared, granted, inputs, given) => declared.map((canvas
761
797
  }
762
798
  const action = typeof seed === "string" ? seed : seed.action;
763
799
  const staticInput = typeof seed === "string" ? {} : seed.input ?? {};
764
- const withFragments = typeof seed === "string" ? void 0 : seed.with;
800
+ const withFragments2 = typeof seed === "string" ? void 0 : seed.with;
765
801
  return {
766
802
  ...canvas,
767
- initial: { action, input: { ...staticInput, ...inputs[canvas.id] ?? {}, ...given?.[canvas.id] ?? {} }, ...withFragments !== void 0 ? { with: withFragments } : {} }
803
+ initial: { action, input: { ...staticInput, ...inputs[canvas.id] ?? {}, ...given?.[canvas.id] ?? {} }, ...withFragments2 !== void 0 ? { with: withFragments2 } : {} }
768
804
  };
769
805
  });
770
806
  var seedCanvases = (live, declaredSeeds, granted) => {
@@ -776,9 +812,9 @@ var seedCanvases = (live, declaredSeeds, granted) => {
776
812
  const action = typeof seed === "string" ? seed : seed.action;
777
813
  if (!granted.has(action)) continue;
778
814
  const input = typeof seed === "string" ? void 0 : seed.input;
779
- const withFragments = typeof seed === "string" ? void 0 : seed.with;
815
+ const withFragments2 = typeof seed === "string" ? void 0 : seed.with;
780
816
  try {
781
- live.shell.push(canvasId, action, input, withFragments, { history: false });
817
+ live.shell.push(canvasId, action, input, withFragments2, { history: false });
782
818
  } catch (error) {
783
819
  console.error(`[moss/shells] the seed "${action}" on canvas "${canvasId}" could not be pushed, and was skipped:`, error);
784
820
  }
@@ -792,7 +828,7 @@ var buildShell = async (host, asked) => {
792
828
  const { config, emit, kept, delta } = host;
793
829
  const { hooks } = config;
794
830
  const { token, principal, opening, reset, wanted } = asked;
795
- const buildClock = emit === void 0 ? void 0 : chunkC2DNDIQX_cjs.spanClock();
831
+ const buildClock = emit === void 0 ? void 0 : chunkPVZMCEBX_cjs.spanClock();
796
832
  const made = await config.composition(principal);
797
833
  if (!wanted()) return void 0;
798
834
  const ids = Object.keys(made.actions);
@@ -877,6 +913,7 @@ exports.buildShell = buildShell;
877
913
  exports.candidateOf = candidateOf;
878
914
  exports.canvasLayoutRef = canvasLayoutRef;
879
915
  exports.canvasesOf = canvasesOf;
916
+ exports.charterOverFunctions = charterOverFunctions;
880
917
  exports.defineApp = defineApp;
881
918
  exports.draftedIn = draftedIn;
882
919
  exports.endShell = endShell;
@@ -884,6 +921,7 @@ exports.endlessChains = endlessChains;
884
921
  exports.entriesOf = entriesOf;
885
922
  exports.entryMisfits = entryMisfits;
886
923
  exports.freezeDeep = freezeDeep;
924
+ exports.functionsIn = functionsIn;
887
925
  exports.functionsWarning = functionsWarning;
888
926
  exports.holdGranted = holdGranted;
889
927
  exports.layoutMisfits = layoutMisfits;
@@ -894,10 +932,12 @@ exports.refusalOf = refusalOf;
894
932
  exports.sessionOn = sessionOn;
895
933
  exports.treeOf = treeOf;
896
934
  exports.variantLayouts = variantLayouts;
935
+ exports.verifiedAtBoot = verifiedAtBoot;
897
936
  exports.verifyApp = verifyApp;
898
937
  exports.verifyManifest = verifyManifest;
899
938
  exports.wholeShellOf = wholeShellOf;
939
+ exports.withFragments = withFragments;
900
940
  exports.withLayoutInPlace = withLayoutInPlace;
901
941
  exports.withVariants = withVariants;
902
- //# sourceMappingURL=chunk-F45SFR7W.cjs.map
903
- //# sourceMappingURL=chunk-F45SFR7W.cjs.map
942
+ //# sourceMappingURL=chunk-3DCTQKPQ.cjs.map
943
+ //# sourceMappingURL=chunk-3DCTQKPQ.cjs.map