@serene-pub/sdk 0.6.0-pr-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 (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,17 @@
1
+ Serene Pub SDK
2
+ Copyright (c) 2025-2026 Jody Doolittle
3
+
4
+ This product includes software developed as part of the Serene Pub project
5
+ (https://github.com/doolijb/serene-pub).
6
+
7
+ The Serene Pub SDK is licensed under the Apache License, Version 2.0.
8
+
9
+ Note that the Serene Pub application itself is a separate work, licensed under
10
+ the GNU Affero General Public License v3.0. Building on this SDK does not place
11
+ your extension under the AGPL — that is the reason this SDK is licensed
12
+ permissively.
13
+
14
+ "Serene Pub" and the Serene Pub logo are trademarks of the project owner and are
15
+ not licensed by the Apache License (see Section 6). Their use is governed by the
16
+ project's trademark policy:
17
+ https://github.com/doolijb/serene-pub/blob/main/TRADEMARK.md
package/README.md ADDED
@@ -0,0 +1,368 @@
1
+ # `@serene-pub/sdk` — preview
2
+
3
+ A working draft of the SDK described in `/docs/pipeline` (00–17). **Preview: breaking
4
+ changes are expected before 0.7.0.**
5
+
6
+ ```bash
7
+ npm install
8
+ npm test # tsc --noEmit, then 310 assertions across 109 use cases
9
+ npm run build # emits dist/ for all four packages, in dependency order
10
+ SHOW_RECEIPT=1 npx tsx --test test/usecases.test.ts # a rendered receipt
11
+ SHOW_PREVIEW=1 npx tsx --test test/preview.test.ts # a rendered debug preview
12
+ SHOW_WIRE=1 npx tsx --test test/wire.test.ts # the panel with the `why` trail
13
+ SHOW_CONFORMANCE=1 npx tsx --test test/conformance.test.ts # the kit core runs against itself
14
+
15
+ node packages/cli/dist/bin.js check ./my-plugin # what core would refuse, and why
16
+ ```
17
+
18
+ ## Four packages, because there are four clocks
19
+
20
+ The split is not cosmetic. A single package would force one version number onto four things
21
+ that move independently, and the one that hurts is `contracts`: a plugin author bumping the
22
+ SDK to get a nicer builder would silently change **which SP release's types they compile
23
+ against**. So the version of `@serene-pub/contracts` *is* the SP release.
24
+
25
+ | package | who installs it | what its version tracks |
26
+ |---|---|---|
27
+ | **`@serene-pub/sdk`** (+ `/testing`) | plugin authors | the authoring API |
28
+ | **`@serene-pub/contracts`** | plugin authors | **the SP release** — `0.6.x` compiles against SP 0.6.x |
29
+ | **`@serene-pub/conformance`** | SP Core and any alternate host | the Fixed Ledger |
30
+ | **`@serene-pub/cli`** | plugin authors, build time only | the authoring API |
31
+
32
+ Two consequences worth stating. A plugin author never downloads the host test kit, because
33
+ the kit answers a question they are not asking ("does this host obey the laws?") and its
34
+ fixtures are not examples to copy. And **nothing in `@serene-pub/cli` is importable by a
35
+ running plugin** — the packager computes a plugin's permissions from its source, so a plugin
36
+ that could import the packager would be a plugin that could argue with the manifest.
37
+
38
+ `npm test` runs the typechecker first on purpose. `test/types.assert.ts` has no runtime
39
+ assertions — it is a file of `@ts-expect-error` directives, so **the build fails if a
40
+ mistake that is supposed to be a compile error stops being one.**
41
+
42
+ ## What's here
43
+
44
+ | | |
45
+ |---|---|
46
+ | `sdk/src/shapes.ts` | versioned shapes; assignability; connection **and** sampling kinds are the same ids (F17) |
47
+ | `sdk/src/descriptors.ts` | `describeInletDefinition` / `describeQueryDefinition` / `describeTaskDefinition` / `describeOracleDefinition` / `describeOutletDefinition`, slots, pinned constructors |
48
+ | `sdk/src/refs.ts` | `$ref` (data edges) vs `slot.*` (config references — not edges, F35) |
49
+ | `sdk/src/scope.ts` | the typed chain scope — `$.history.messages`, and F9 at the call site |
50
+ | `sdk/src/builder.ts` | the kind-named chain: `on/input/query/task/provider/consume` + `async/map/include` |
51
+ | `sdk/src/document.ts` | compile to a canonical document, derive edges, resolve config refs at publish |
52
+ | `sdk/src/validate.ts` | the statically checkable laws — every error names what to do instead |
53
+ | `sdk/src/config.ts` | five-layer scope chain, per slot; the write matrix |
54
+ | `sdk/src/executor.ts` | a minimal runtime: discriminated results incl. `halt`, run seed, timeouts, budgets, receipts, replay |
55
+ | `sdk/src/review.ts` | the gate: three positions, keyed on **declared effects** not kind; no position forbids it |
56
+ | `sdk/src/template.ts` | a minimal renderer + static variable checking |
57
+ | `sdk/src/wire.ts` | **allocation vs. formatting** — allocated blocks, the wire registry, one measurement |
58
+ | `conformance/src/index.ts` | **the kit SP Core upgrades against**: 26 requirements, each naming what breaks |
59
+ | `sdk/src/engines.ts` | template engines as a **registry** — render, extract, check, and the cost profile |
60
+ | `sdk/src/identity.ts` | owner + slug + semver; the import rule; ownership is not transferred |
61
+ | `sdk/src/migration.ts` | the parity harness: legacy output vs the **preview payload** |
62
+ | `sdk/src/preview.ts` | debug mode: halt at the first spine Provider and report what would be sent |
63
+ | `sdk/src/events.ts` | the core-owned registry: unique slugs, **data vs action** families |
64
+ | `sdk/src/hooks.ts` | the three hook kinds and their surfaces; the F32 conformance probe |
65
+ | `sdk/src/settings.ts` | the plugin settings schema: one declaration → form, validation, manifest, types |
66
+ | `sdk/src/extension.ts` | `defineExtension` — one declaration ties handlers, settings, components, genres, presets and pipelines |
67
+ | `sdk/src/testing.ts` | the author's harness: goldens, binding probes, the equivalence law |
68
+ | `sdk/src/connections.ts` | what an import must wire, derived from types rather than stored rows |
69
+ | `sdk/src/registry.ts` | `type_registry` rows, and install-time validation from data alone |
70
+ | `sdk/src/dev.ts` | dev loading: memory-only overlay, and which reloads may apply mid-run |
71
+ | `contracts/src/index.ts` | sample core + plugin types across four modalities |
72
+ | `cli/src/compiler.ts` | the packager: a source scan plus the built extension, cross-checked |
73
+ | `cli/src/codegen.ts` | `/contracts` generation, and the rule that binding names are **derived** |
74
+ | `cli/src/bin.ts` | `serene-pub build / check / contracts` |
75
+
76
+ ## What the draft demonstrates
77
+
78
+ **Laws are compile errors, not validator findings.** `.inlet()` is the only method offered
79
+ first and is never offered again. `.query()` given an oracle constructor is a type error.
80
+ There is no branch method to call. And **a node cannot reference one declared below it** —
81
+ the scope handed to each step holds only what precedes it, so F9's "no back-edges" is
82
+ unwritable rather than reported:
83
+
84
+ ```ts
85
+ .query('history', $ => C.chatHistory({ scope: $.input.chatScope }))
86
+ .task ('prompt', $ => C.assemble({ messages: $.history.messages }))
87
+ .outlet('save', $ => C.createMessage({ text: $.generate.text }))
88
+ ```
89
+
90
+ `$ref('history','messages')` still works and produces the identical value — use case 52
91
+ asserts both forms compile to the same canonical hash, because F6 means nicer authoring has
92
+ to be provably invisible to the document. **Every test in this draft is written in the scope
93
+ form**; the two places `$ref` still appears are the parity tests that exist to compare the
94
+ two forms.
95
+
96
+ **Node keys accumulate fully qualified, exactly as they land in the rows**, and the scope
97
+ type expands the dots back into a path. So a gather clause's members, an each clause's members and an
98
+ included fragment's members are all in scope afterwards:
99
+
100
+ ```ts
101
+ .gather('gather', { mode: 'parallel' }, b => b
102
+ .chain('semantic', c => c
103
+ .oracle('embed', $ => C.embedText({ text: $.input.text, connection: slot.connection() }))
104
+ .query ('vsearch', $ => C.vectorSearch({ vector: $.gather.semantic.embed.vector }))))
105
+ .include('ctx', contextInfill)
106
+ .task('merge', $ => C.mergeCandidates({ sources: [$.gather.semantic.vsearch.hits] }))
107
+ .task('prompt', $ => C.assemble({ candidates: $.ctx.merge.candidates }))
108
+ ```
109
+
110
+ A clause name alone is a **path**, not a ref — only the leaf is a node, which falls out of
111
+ the key split rather than needing a rule. `types.assert.ts` pins both directions: the
112
+ qualified paths compile, and a misspelled chain name or a fragment node that doesn't exist
113
+ is a compile error.
114
+
115
+ **Nothing switches on modality.** `generateText`, `speak`, `renderImage` and `mcpTool` are
116
+ the same object to the config model, the scope chain and the receipt — because `params` is
117
+ declared per type, not per kind.
118
+
119
+ **The receipt explains itself.** The rendered output above answers "why isn't RAG working"
120
+ (no embeddings connection, one line), "why does mirostat do nothing" (the adapter ignored
121
+ it, stated), and "what caused that other pipeline to run" (core emitted, because a write
122
+ happened).
123
+
124
+ ## The 103 use cases
125
+
126
+ Each maps to a law or a documented behaviour, so a failure points at the doc it violates.
127
+
128
+ | # | Case | Reference |
129
+ |---|---|---|
130
+ | 01 | minimal chat turn runs; kind mismatch cannot compile | 04 §4a |
131
+ | 02 | exactly one Input, positionally first | 01 §2 |
132
+ | 03 | one live row; other writes and emits unlimited; chain continues past it | F7 |
133
+ | 04 | no branch method; fan-in is legal | F25 |
134
+ | 05 | halt ends the run as `halt`, records node + reason, skips downstream | 01 §5 |
135
+ | 06 | seeded dice replay identically; no `random` without `declaresRandomness` | F11 |
136
+ | 07 | a Query is handed no network handle | 16 §1 |
137
+ | 08 | async block: parallel ≡ forced-sequential; no write-class consumer inside | F26, 01 §4 |
138
+ | 09 | map publishes with a declared max; unbounded is an error | 01 §4 |
139
+ | 10 | streaming decided at publish; `earlyExit` on a settled input warns | 01 §11, F22 |
140
+ | 11 | timeouts bound execution; admin ceiling wins; **a week of waiting doesn't trip one** | F36 |
141
+ | 12 | budgets trip on consumption; waiting consumes nothing | F13 |
142
+ | 13 | five-layer chain resolves per path; users can't write `connection` | 12 §2, F20 |
143
+ | 14 | sampling referenced + field-overridden; ignored samplers recorded | 12 §2 |
144
+ | 15 | connection **metadata** readable, **material** never leaves core | 01 §10, F18 |
145
+ | 16 | budget flows forward; `downstreamProvider()` resolves at publish | F35, 16 §5b-i |
146
+ | 17 | Assemble reads declared weights off its inputs | 16 §5a |
147
+ | 18 | auto→keyword with no embeddings; auto→vector with them; nothing skipped | 16 §2 |
148
+ | 19 | three rankers substitute freely, including a plugin's | 16 §5c |
149
+ | 20 | a fragment expands at publish to flat, namespaced rows | 16 §3a |
150
+ | 21 | `import(export(rows))` is identity; hash stable | F3 |
151
+ | 22 | only core emits; a node declaring `emits` is rejected | F8 |
152
+ | 23 | replay reproduces the run **without calling the provider** | F16 |
153
+ | 24 | TTS, image-gen and MCP use the same structure as chat | 17 §1 |
154
+ | 25 | review `off` invokes the binding directly | 01 §7 |
155
+ | 26 | `sync` parks **before** the binding; rejection halts; a week parked trips no timeout | 01 §7, F13 |
156
+ | 27 | an edited payload is **indistinguishable to the binding** | F14 |
157
+ | 28 | author may default review on; user can turn it off; no position forbids it; gate keys on effects | F14, 14 §4a |
158
+ | 29 | the receipt records action, both hashes and who | F15 |
159
+ | 30 | `async` proposes without blocking — **and hands downstream a proposal id** | 01 §7 |
160
+ | 30a | an unclassified external tool is gate-**eligible** but **ungated** | 14 §4 |
161
+ | 31 | source and assembly templates render | 16 §3b |
162
+ | 32 | unknown variable errors and lists what exists; dynamic access warns | 16 §4 |
163
+ | 33 | extraction finds loop sources and expressions | 16 §4 |
164
+ | 34 | **template scope is declared on the slot, not derived from ports** | 16 §4 correction |
165
+ | 35 | regex keys, logic operators (AND_ALL / NOT_ANY), scan depth | 13 §7i |
166
+ | 36 | bounded recursion inside the Query's interior — no pipeline construct | 13 §7i |
167
+ | 37 | constants activate without a key match | 13 §7i |
168
+ | 38 | probability rolls against the run seed — **replayable, unlike ST's** | 13 §7i |
169
+ | 39 | inclusion groups resolve in the rank Task, weighted and seeded | 16 §5c |
170
+ | 40 | insertion order is a sort key | 13 §7i |
171
+ | 41 | positional insertion at depth — **the assembly template does it** | 16 §5e |
172
+ | 42 | async blocks publish **branch-results in declaration order**; a merge was rejected | 13 §1 |
173
+ | 43 | map iterates, numbers its iterations, and fails rather than truncating past `max` | 13 §1, F26 |
174
+ | 44 | an **event-triggered** halt before any effect compacts; a click's halt does not | 13 §2 |
175
+ | 45 | an admin kill is `cancelled` with an actor — **not** `err` | 13 §3 |
176
+ | 46 | a week queued trips no timeout and consumes no budget | 13 §3, F13, F36 |
177
+ | 47 | a `secret` setting is redacted **by type**, hidden from the client, dropped from export | 13 §6 |
178
+ | 48 | event slugs are unique; **action events drop out of the cycle graph by construction** | 13 §7, §7g |
179
+ | 49 | `ui-action` carries owner *and* trigger — budget owner without a separate rule | 13 §7 |
180
+ | 50 | no hook surface carries Provider access or a trigger; scheduled work is an event | 13 §7c, F32 |
181
+ | 51 | a lorebook entry can carry `depth` — the one real parity gap, closed | 13 §7i |
182
+ | 52 | **scope sugar and `$ref` compile to the same canonical hash** | F3, F6 |
183
+ | 53 | `$.history` is the `main` port; `$.history.messages` refines it | 04 §4a-i |
184
+ | 54 | a forward reference throws, and the message lists what exists | F9 |
185
+ | 55 | `$.a.b.c` is refused — ports are flat, and the error says so | 04 §4a-i |
186
+ | 56 | inside a block a sibling is `$.embed`; from the spine it is the full path | 04 §4a-i |
187
+ | 57 | `over: $ => $.chunks.items`, and `$.$item` needs no block key | 01 §4 |
188
+ | 58 | `slot.connectionOf($.generate)` — still not a data edge | F35 |
189
+ | 59 | preview stops at the first Provider **on the spine**, not at `embed` in the block | 16 §7 |
190
+ | 60 | **the previewed payload is byte-identical to the one actually sent** | 16 §7 |
191
+ | 61 | per-source stats, a reason on every dropped block, metadata but never material | F18 |
192
+ | 62 | a payload over the available budget is flagged, not silently truncated | 16 §7 |
193
+ | 63 | a preview receipt is never compacted — the preview *is* the payload | 13 §2 |
194
+ | 64 | author presets: slugged, one default, renaming the label keeps selections | 12 §3a, §3b |
195
+ | 65 | unknown node key, undeclared slot and `connection` are all refused | 12 §3a, §4 |
196
+ | 65a | selective export; a filtered doc is a *different* doc; nothing drops silently | 12 §7a |
197
+ | 66 | a template carries **its engine**; an extension registers its own compiler | 12 §2a |
198
+ | 67 | cost profiles separate fixed from per-iteration; `exact: false` degrades safely | 16 §7 |
199
+ | 72 | migrated rows get a **derived** slug, so the job can be safely re-run | 12 §3b |
200
+ | 73 | **parity is byte-identical output, measured on the preview** | 08 §5b |
201
+ | 74 | the gate fails an empty corpus — "nothing checked" ≠ "no failures" | 08 §5b |
202
+ | 75 | no silent drops; the scope each value landed at is recorded | 12 §2, §5 |
203
+ | 76 | owner + slug + semver; newer replaces; ownership is never transferred | 12 §3b |
204
+ | 77 | one schema drives the form, validation, the manifest **and the value types** | 12 §6 |
205
+ | 78 | values are range/enum/type checked; every finding names the fix | 12 §6 |
206
+ | 79 | a schema that would leak a secret cannot be constructed | 13 §6 |
207
+ | 80 | on update, removed fields are **orphaned, not deleted** | 12 §5, §6 |
208
+ | 81 | `needs-configuration` is a distinct state from `broken` | 12 §6 |
209
+ | 82 | client sees "set/unset", export drops it, only the owning hook sees plaintext | F18 |
210
+ | 83 | a tool-calling loop on the spine: per-step receipts, not one opaque call | 01 §4a |
211
+ | 84 | dispatch is data, which is why branching is still not a construct | 01 §4a |
212
+ | 85 | blocks nest; two iterations never see each other's values | 01 §4a |
213
+ | 86 | a loop publishes `branch-results`, exactly like a map | 13 §1 |
214
+ | 87 | unbounded loop, outside-the-body predicate and inner writes are all refused | 01 §4a, F7 |
215
+ | 88 | halt still halts the run — the loop does not swallow it | 01 §5 |
216
+ | 89 | one allocation, five wire formats; dropped blocks reach none of them | 16 §7 |
217
+ | 90 | scaffolding is **declared and counted**, not discovered by the vendor | 16 §7a |
218
+ | 91 | over budget is `err` — not a silent trim, and not a retry | F9, F25 |
219
+ | 92 | `allocated-context` → `assembled-context` one way only, so core migrates node by node | 16 §7 |
220
+ | 95 | **the reference implementation passes its own conformance kit** | 03 §9 |
221
+ | 96 | `defineExtension` ties the whole plugin together; a foreign namespace is refused | 03 §2 |
222
+ | 97 | permissions are compiled from **what the code calls**; a computed declaration is an error | 13 §7c, §30 |
223
+ | 98 | manifest + documents; a subscription is a permission; conditional registration is caught | 10 §10.2 |
224
+ | 99 | **every binding name derives from its type id** — an alias table is a generator that drifts | 04 §2 |
225
+ | 100 | goldens diff the payload, not the pass/fail — "it still runs" is not the assertion | 03 §9 |
226
+ | 101 | five binding probes; each failure names what it breaks, not just what it was | 03 §9 |
227
+ | 102 | F26 as a one-liner an author can run | F26 |
228
+ | 103 | the CLI: `check` exits non-zero on what core would refuse; there is **no `install` verb** | 03 §9 |
229
+ | 104 | `createMessage` / `updateMessage`: two names, no inference; create → update in one run is unwritable | 13 §10b |
230
+ | 105 | a gate-eligible write publishes `write-result@1`, **checked at registration** — three core types did not | 13 §7j-b |
231
+ | 106 | the legacy split migration recovers the decision or reports `unmapped` — never guesses | 13 §10b, 08 §5b |
232
+ | 107 | connections an import must wire, derived from types so an unconfigured export still declares them | 13 §10a |
233
+ | 108 | install-time validation from manifest + documents alone, incl. **shape drift every id survives** | 13 §10c |
234
+ | 109 | dev loading: memory-only overlay, and a reload that waits on the run it would have broken | 13 §11 |
235
+ | ✓ | every validation error states what to do instead | 15 §1.3 |
236
+ | ✓ | `types.assert.ts` — eight mistakes that must stay compile errors, incl. block paths, map members and fragment includes | tsc |
237
+
238
+ ## The 2026-08-18 rulings, as code
239
+
240
+ Eight rulings landed; the draft implements them rather than recording them. Four are worth
241
+ calling out because the ruling changed what the code does, not just what a doc says.
242
+
243
+ **Joined effects are gone, and the union is a list.** An async block or a map publishes
244
+ `core:shape/branch-results@1` — one entry per branch, in **declaration order**, each
245
+ carrying `branchKey`, `index` and the discriminated result. Not a merged object: merging
246
+ needs a field-collision policy, and use case 42 demonstrates the failure by merging two
247
+ branches that both produce `hits` and watching one disappear. `async` and `map` publish the
248
+ same shape, so F26's equivalence harness covers both without knowing which it is looking at.
249
+
250
+ **A gate-eligible write publishes a discriminated result.** This closes finding (b) below.
251
+ Under `async` review the value is a proposal a reviewer may still reject, so it is
252
+ `{status:'pending', proposalId}` rather than an id; committed is `{status:'committed', ids}`.
253
+ `write-result@1` is deliberately **not** assignable to `row-ids@1`, which means a downstream
254
+ port that wants raw ids fails at publish with a message that explains the dangling foreign
255
+ key it just prevented. There is no branch node to check `status` with (F25), so the
256
+ obligation belongs to the type rather than to the spec — that is the whole design.
257
+
258
+ **Compaction is scoped to where the multiplier actually is.** A receipt compacts when the run
259
+ halted before any effectful node **and** the trigger was an event. That is the case the
260
+ ruling was about: a hot event × every subscribed pipeline × every message, where most
261
+ subscribers halt immediately and halting is success. A run someone started by clicking
262
+ happens once per click and keeps full detail. The rendered receipt says it was compacted and
263
+ how many rows went, so an empty node list is never a mystery.
264
+
265
+ **A `secret` setting is redacted by its type.** Use case 47 puts a ciphertext through a run
266
+ and asserts it appears nowhere in the serialized receipt. That assertion is the argument for
267
+ typing the field rather than adding a free-form secrets column: core cannot redact, exclude
268
+ from export, or keep write-only a value it cannot identify.
269
+
270
+ ## Three findings for the docs, and one retraction
271
+
272
+ These are places where building it disagreed with what 00–17 say. All three are cheap to
273
+ fix and none is architectural. **(b) is now ruled and implemented** — kept here because the
274
+ reasoning is the useful part.
275
+
276
+ ### 1. Template variable scope cannot come from typed ports alone — 16 §4 is half wrong
277
+
278
+ 16 §4 claims variable awareness "falls out of typed ports with no new mechanism." That
279
+ holds for an **assembly** template, whose scope really is its input ports.
280
+
281
+ It does **not** hold for a **source** template. Rendering one lorebook entry means
282
+ referencing `{{ entry.title }}` — and the entry's shape lives *inside* the port's payload,
283
+ not on the port. No amount of port typing recovers it.
284
+
285
+ **Fix:** the template slot declares its own `variables`. One field on the descriptor, not a
286
+ new mechanism — but the doc currently promises something that would have failed for the
287
+ first plugin author who tried it. Use case 34 pins this.
288
+
289
+ ### 2. Under async review, downstream gets a *proposal* id — **RULED, implemented**
290
+
291
+ 01 §7 says an async proposal "is committed data," which is consistent. But a downstream node
292
+ referencing `$ref('save','messageId')` received `proposal:save`, not a message id — and
293
+ nothing in the design said so.
294
+
295
+ **Ruled: a discriminated pending/committed shape**, not a shared id space. The rejected
296
+ option is the one worth naming, because it is the one that looks simpler: under a shared id
297
+ space a proposal id is indistinguishable from a row id right up until the reviewer rejects
298
+ it, and then a foreign key written during the run dangles — a failure that surfaces long
299
+ after the run that caused it. Use case 30 now pins both statuses and the publish-time error.
300
+
301
+ ### 3. "Effectful by default" and "reviewed by default" are different claims
302
+
303
+ 14 §4 says every MCP tool is effectful by default and the admin classifies it. `effects:
304
+ 'external'` delivers that — the node becomes gate-**eligible**. But the review *position* is
305
+ a separate setting, and with no author default and no admin setting it resolves to `off`.
306
+
307
+ So a freshly-snapshotted MCP tool that sends mail **runs unreviewed** until someone
308
+ classifies it. **Fix:** the MCP snapshot writes `review: 'sync'` at instance scope until an
309
+ admin marks the tool read-only. One field, no new machinery. Use case 30a pins both halves.
310
+
311
+ ### 4. RETRACTED — all seven World Info features mapped
312
+
313
+ An earlier version of this README reported that positional insertion at chat depth needed a
314
+ shape change on `context-candidates`. **That was wrong.** Depth is a context-template
315
+ concern, and the assembly template expresses it:
316
+
317
+ ```jinja
318
+ {% for m in messages %}{% set d = loop.revindex %}
319
+ {% for l in lore %}{% if l.depth == d %}{{ l.rendered }}{% endif %}{% endfor %}
320
+ {{ m.rendered }}
321
+ {% endfor %}
322
+ ```
323
+
324
+ `{% set %}` captures the outer loop's index before the inner loop shadows `loop`. Use case 41
325
+ tests it end to end rather than asserting it.
326
+
327
+ So **all seven mapped with no new mechanism** — and this is also the answer to why Jinja beats
328
+ a fixed position enum: it expresses ST's four positions plus anything an author invents.
329
+
330
+ Fixing the demonstration required three real corrections to the toy engine, all of which were
331
+ bugs a regex-pass renderer will always have: non-greedy matching can't handle nested blocks,
332
+ inner loops must render *inside* their parent's scope rather than innermost-first, and `set`
333
+ tags belonging to an inner scope must not be stripped by an outer pass.
334
+
335
+ **The genuine parity gap is narrower than "positional insertion is missing": SP's lorebook
336
+ entries have no `depth` field.** An entry-schema addition in the lorebook model, not pipeline
337
+ work.
338
+
339
+ ## Known gaps in the draft
340
+
341
+ Unimplemented, not undecided.
342
+
343
+ - **In-process timeouts abandon rather than kill**, matching 13 §7h. The abandoned promise
344
+ keeps running; only the result is discarded.
345
+ - **No sidecar transport, no MCP client.** `mcpTool` is a descriptor with a stub binding.
346
+ - **No real tokenizer.** `contextBudget` reads `metadata.contextLength` and subtracts.
347
+ - **The template engine is minimal** — `{{ a.b }}` and `{% for %}` only, enough to prove the
348
+ variable-awareness contract, not to be Jinja.
349
+ - **ST parity items are declared but not implemented** — recursion, inclusion groups and
350
+ positional insertion are `params` on the descriptors only (13 §7i).
351
+ - **A map forces sequential execution.** The observable result is identical, which is exactly
352
+ what F26 asserts, but the draft does not actually run iterations concurrently — a single
353
+ shared value map cannot hold two iterations at once. Real per-iteration scoping is the
354
+ work, not the shape.
355
+ - **`secret` values are stored as tagged plaintext**, not encrypted. `forOwningHookSplit` takes a
356
+ `decrypt` function so the seam is in the right place; the app secret in `meta.json` is
357
+ core's side of it (13 §5).
358
+
359
+ ## Two bugs the tests caught while writing this
360
+
361
+ Both the kind that ship silently.
362
+
363
+ 1. **`redact()` turned arrays into objects**, corrupting receipts while execution stayed
364
+ correct — the run was right, the record of it was wrong. Caught by use case 17 reading an
365
+ allocation array back out of a receipt. That is precisely the failure that would make the
366
+ explicability claim quietly unreliable.
367
+ 2. **A too-strict sink shape** made every socket emit a publish error. The fix — `json` as a
368
+ top type — is right, but the failure was the validator working, not misbehaving.