@origintrail-official/dkg-semantic-runtime 0.0.0-stage → 10.1.3

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 (161) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +299 -2
  3. package/artifact-lock.json +12 -0
  4. package/dist/activation.d.ts +73 -0
  5. package/dist/activation.d.ts.map +1 -0
  6. package/dist/activation.js +145 -0
  7. package/dist/activation.js.map +1 -0
  8. package/dist/admission.d.ts +19 -0
  9. package/dist/admission.d.ts.map +1 -0
  10. package/dist/admission.js +52 -0
  11. package/dist/admission.js.map +1 -0
  12. package/dist/codec.d.ts +156 -0
  13. package/dist/codec.d.ts.map +1 -0
  14. package/dist/codec.js +376 -0
  15. package/dist/codec.js.map +1 -0
  16. package/dist/component-supervisor.d.ts +72 -0
  17. package/dist/component-supervisor.d.ts.map +1 -0
  18. package/dist/component-supervisor.js +413 -0
  19. package/dist/component-supervisor.js.map +1 -0
  20. package/dist/component-types.d.ts +102 -0
  21. package/dist/component-types.d.ts.map +1 -0
  22. package/dist/component-types.js +28 -0
  23. package/dist/component-types.js.map +1 -0
  24. package/dist/component-worker-protocol.d.ts +71 -0
  25. package/dist/component-worker-protocol.d.ts.map +1 -0
  26. package/dist/component-worker-protocol.js +2 -0
  27. package/dist/component-worker-protocol.js.map +1 -0
  28. package/dist/component-worker.d.ts +2 -0
  29. package/dist/component-worker.d.ts.map +1 -0
  30. package/dist/component-worker.js +547 -0
  31. package/dist/component-worker.js.map +1 -0
  32. package/dist/durable-host.d.ts +34 -0
  33. package/dist/durable-host.d.ts.map +1 -0
  34. package/dist/durable-host.js +184 -0
  35. package/dist/durable-host.js.map +1 -0
  36. package/dist/effect-broker.d.ts +163 -0
  37. package/dist/effect-broker.d.ts.map +1 -0
  38. package/dist/effect-broker.js +421 -0
  39. package/dist/effect-broker.js.map +1 -0
  40. package/dist/effect-capability-codec.d.ts +14 -0
  41. package/dist/effect-capability-codec.d.ts.map +1 -0
  42. package/dist/effect-capability-codec.js +136 -0
  43. package/dist/effect-capability-codec.js.map +1 -0
  44. package/dist/host.d.ts +80 -0
  45. package/dist/host.d.ts.map +1 -0
  46. package/dist/host.js +266 -0
  47. package/dist/host.js.map +1 -0
  48. package/dist/index.d.ts +18 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +17 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/integrity.d.ts +49 -0
  53. package/dist/integrity.d.ts.map +1 -0
  54. package/dist/integrity.js +166 -0
  55. package/dist/integrity.js.map +1 -0
  56. package/dist/persistence-codec.d.ts +20 -0
  57. package/dist/persistence-codec.d.ts.map +1 -0
  58. package/dist/persistence-codec.js +94 -0
  59. package/dist/persistence-codec.js.map +1 -0
  60. package/dist/persistence-schema.d.ts +6 -0
  61. package/dist/persistence-schema.d.ts.map +1 -0
  62. package/dist/persistence-schema.js +172 -0
  63. package/dist/persistence-schema.js.map +1 -0
  64. package/dist/persistence-types.d.ts +173 -0
  65. package/dist/persistence-types.d.ts.map +1 -0
  66. package/dist/persistence-types.js +2 -0
  67. package/dist/persistence-types.js.map +1 -0
  68. package/dist/persistence.d.ts +64 -0
  69. package/dist/persistence.d.ts.map +1 -0
  70. package/dist/persistence.js +527 -0
  71. package/dist/persistence.js.map +1 -0
  72. package/dist/program-execution-journal.d.ts +65 -0
  73. package/dist/program-execution-journal.d.ts.map +1 -0
  74. package/dist/program-execution-journal.js +76 -0
  75. package/dist/program-execution-journal.js.map +1 -0
  76. package/dist/program-policy.d.ts +148 -0
  77. package/dist/program-policy.d.ts.map +1 -0
  78. package/dist/program-policy.js +2 -0
  79. package/dist/program-policy.js.map +1 -0
  80. package/dist/program-trace.d.ts +30 -0
  81. package/dist/program-trace.d.ts.map +1 -0
  82. package/dist/program-trace.js +112 -0
  83. package/dist/program-trace.js.map +1 -0
  84. package/dist/projection.d.ts +30 -0
  85. package/dist/projection.d.ts.map +1 -0
  86. package/dist/projection.js +101 -0
  87. package/dist/projection.js.map +1 -0
  88. package/dist/receipt-journal.d.ts +31 -0
  89. package/dist/receipt-journal.d.ts.map +1 -0
  90. package/dist/receipt-journal.js +53 -0
  91. package/dist/receipt-journal.js.map +1 -0
  92. package/dist/runtime-support.d.ts +3 -0
  93. package/dist/runtime-support.d.ts.map +1 -0
  94. package/dist/runtime-support.js +10 -0
  95. package/dist/runtime-support.js.map +1 -0
  96. package/dist/typescript-programs.d.ts +41 -0
  97. package/dist/typescript-programs.d.ts.map +1 -0
  98. package/dist/typescript-programs.js +231 -0
  99. package/dist/typescript-programs.js.map +1 -0
  100. package/dist/worker-protocol.d.ts +42 -0
  101. package/dist/worker-protocol.d.ts.map +1 -0
  102. package/dist/worker-protocol.js +2 -0
  103. package/dist/worker-protocol.js.map +1 -0
  104. package/dist/worker-supervisor.d.ts +55 -0
  105. package/dist/worker-supervisor.d.ts.map +1 -0
  106. package/dist/worker-supervisor.js +271 -0
  107. package/dist/worker-supervisor.js.map +1 -0
  108. package/dist/worker.d.ts +2 -0
  109. package/dist/worker.d.ts.map +1 -0
  110. package/dist/worker.js +128 -0
  111. package/dist/worker.js.map +1 -0
  112. package/generated/cjs/package.json +1 -0
  113. package/generated/cjs/runtime.d.ts +94 -0
  114. package/generated/cjs/runtime.js +379 -0
  115. package/generated/cjs/runtime_bg.wasm +0 -0
  116. package/generated/cjs/runtime_bg.wasm.d.ts +23 -0
  117. package/generated/component/interfaces/origintrail-semantic-runtime-asset-create.d.ts +12 -0
  118. package/generated/component/interfaces/origintrail-semantic-runtime-capability.d.ts +8 -0
  119. package/generated/component/interfaces/origintrail-semantic-runtime-executor.d.ts +83 -0
  120. package/generated/component/interfaces/origintrail-semantic-runtime-investigator.d.ts +12 -0
  121. package/generated/component/interfaces/origintrail-semantic-runtime-query-catalog.d.ts +20 -0
  122. package/generated/component/interfaces/origintrail-semantic-runtime-remote-execute.d.ts +17 -0
  123. package/generated/component/interfaces/origintrail-semantic-runtime-safe-llm.d.ts +12 -0
  124. package/generated/component/interfaces/origintrail-semantic-runtime-sparql-read.d.ts +12 -0
  125. package/generated/component/interfaces/wasi-cli-environment.d.ts +2 -0
  126. package/generated/component/interfaces/wasi-cli-exit.d.ts +3 -0
  127. package/generated/component/interfaces/wasi-cli-stderr.d.ts +3 -0
  128. package/generated/component/interfaces/wasi-cli-stdin.d.ts +3 -0
  129. package/generated/component/interfaces/wasi-cli-stdout.d.ts +3 -0
  130. package/generated/component/interfaces/wasi-cli-terminal-input.d.ts +8 -0
  131. package/generated/component/interfaces/wasi-cli-terminal-output.d.ts +8 -0
  132. package/generated/component/interfaces/wasi-cli-terminal-stderr.d.ts +3 -0
  133. package/generated/component/interfaces/wasi-cli-terminal-stdin.d.ts +3 -0
  134. package/generated/component/interfaces/wasi-cli-terminal-stdout.d.ts +3 -0
  135. package/generated/component/interfaces/wasi-clocks-monotonic-clock.d.ts +4 -0
  136. package/generated/component/interfaces/wasi-io-error.d.ts +8 -0
  137. package/generated/component/interfaces/wasi-io-poll.d.ts +10 -0
  138. package/generated/component/interfaces/wasi-io-streams.d.ts +29 -0
  139. package/generated/component/runtime.component.wasm +0 -0
  140. package/generated/component/runtime.core.wasm +0 -0
  141. package/generated/component/runtime.core2.wasm +0 -0
  142. package/generated/component/runtime.core3.wasm +0 -0
  143. package/generated/component/runtime.d.ts +81 -0
  144. package/generated/component/runtime.js +10532 -0
  145. package/generated/component/wit/semantic-runtime.wit +228 -0
  146. package/generated/integrity.json +191 -0
  147. package/package.json +57 -3
  148. package/schema/semantic-runtime-v1-shacl.ttl +25 -0
  149. package/schema/semantic-runtime-v1.ttl +98 -0
  150. package/smoke/llm-agent.scm +10 -0
  151. package/smoke/llm-greeting.scm +10 -0
  152. package/smoke/remote-execute.scm +8 -0
  153. package/smoke/safe-llm.scm +8 -0
  154. package/smoke/two-agents.scm +10 -0
  155. package/typescript-runtime/compiler.mjs +76 -0
  156. package/typescript-runtime/entry.mjs +20 -0
  157. package/typescript-runtime/guest.mjs +34 -0
  158. package/typescript-runtime/limit-memory.mjs +37 -0
  159. package/typescript-runtime/pipeline.mjs +31 -0
  160. package/typescript-runtime/worker.mjs +23 -0
  161. package/typescript-runtime/workflow.wit +6 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2018 OriginTrail
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,300 @@
1
- # Temporary Holding Version
1
+ # DKG semantic runtime
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ This package contains the default-off TypeScript host and shared Rust semantic
4
+ kernel for DKG V10. Program S-expressions remain RDF data; every invocation
5
+ loads and admits one immutable Program plan into the same kernel.
6
+
7
+ Stored `typescript-v1` Programs use `TypeScriptProgramHost`: the daemon compiles
8
+ their source at approval with ComponentizeJS, then runs each invocation in a
9
+ separate Wasm process. Their effect APIs are `invoke_tool` and `invoke_program`, routed through
10
+ pinned tool and child operation grants with the original caller's permissions. The SDK
11
+ provides guest `pipe`, `map` and `reduce` helpers. See the
12
+ [TypeScript Program guide](../graph-computer/README.md#write-a-typescript-program)
13
+ for upload, approval and invocation examples, resource limits, and retry semantics.
14
+ This path shares the execution journal and RDF receipts with the S-expression
15
+ runtime, but does not checkpoint JavaScript continuations.
16
+
17
+ TypeScript source may also be an immutable multi-file bundle. The shared core
18
+ codec checks all dependency pins before the compiler's virtual resolver accepts
19
+ them. It has no npm, filesystem or URL resolution fallback. The bundler processes
20
+ source as data; dependency initialization runs in the bounded Wasm guest. See
21
+ [library imports](../graph-computer/README.md#import-a-library) for packaging,
22
+ approval identity and sandbox limits.
23
+
24
+ The execution boundary is a versioned WebAssembly component with typed,
25
+ asynchronous WIT. The official Rust WASI 0.3 build flow uses a
26
+ `wasm32-wasip2` carrier component plus async component-model bindings rather
27
+ than a Rust `wasm32-wasip3` target. This repository pins nightly
28
+ `2026-08-18`, `wit-bindgen` 0.61.1, and jco 1.32.1. See
29
+ [`docs/architecture/semantic-runtime-wasi-0.3.md`](../../docs/architecture/semantic-runtime-wasi-0.3.md).
30
+
31
+ Run `pnpm build:semantic-runtime` from a source checkout. It builds the
32
+ gitignored local artifacts, validates their WIT world and bounded memories, and
33
+ requires them to match `artifact-lock.json`. Generated Wasm and JavaScript glue
34
+ are packaged in npm but are not stored in Git.
35
+
36
+ The Wasm build normalizes source paths, compiler metadata, and Rust archive
37
+ member names so the pinned artifacts can be reproduced on different hosts.
38
+ The compiler wrapper works around
39
+ [Cargo's host-dependent metadata issue](https://github.com/rust-lang/cargo/issues/8140)
40
+ and the resulting archive names, which Rust uses to order link-time optimization
41
+ inputs. Cargo's outer cache filenames and compiled object contents are preserved,
42
+ as are the artifact hash checks. Custom `RUSTFLAGS`,
43
+ `CARGO_ENCODED_RUSTFLAGS`, `RUSTC_WRAPPER`, and `RUSTC_WORKSPACE_WRAPPER` values
44
+ are rejected; clear them before running this pinned build.
45
+
46
+ Executing or admitting Programs requires a Node.js runtime with native
47
+ WebAssembly JavaScript Promise Integration (JSPI); use **Node.js 26.8.2 or newer**,
48
+ which is also the version exercised by the semantic runtime CI lanes.
49
+ The default DKG installation
50
+ and artifact build still support the repository's Node.js 22 baseline; opt-in
51
+ semantic runtime deployments must use the newer Node.js executable. Node.js 22
52
+ does not expose the required `WebAssembly.Suspending` and `WebAssembly.promising`
53
+ APIs, even with its experimental JSPI flag. Startup checks these APIs before
54
+ creating a runtime partition, and direct admission checks them before creating
55
+ a component Worker. No V8 flags are enabled automatically.
56
+
57
+ The packaged component owns bounded S-expression parsing, deterministic plan
58
+ compilation, and canonical-plan re-admission. Compilation uses a disposable
59
+ component Worker. Each active execution then has its own component instance and
60
+ Worker, with an ordered per-execution queue and a bounded global execution
61
+ count. A timeout, trap, or memory failure terminates only that execution
62
+ partition.
63
+
64
+ The host-side V1 modules provide:
65
+
66
+ - a dedicated WAL/FULL SQLite event, snapshot, capability, approval,
67
+ authorization, and effect journal;
68
+ - a closed adapter registry and prepared-effect gateway with current-policy and
69
+ capability rechecks;
70
+ - explicit `unknown` outcomes and read-only reconciliation rather than blind
71
+ mutation retry;
72
+ - trusted graph-trigger activation pinned to graph revision, policy epoch,
73
+ signature, review state, and Wasm-admitted plan semantics; and
74
+ - allowlisted DKG provenance projection that excludes mailboxes, normalized
75
+ inputs, credentials, and opaque capability identifiers.
76
+
77
+ The CLI integration remains deliberately conservative: its exact opt-in starts
78
+ the integrity/watchdog/recovery partition, but it does not automatically enable
79
+ graph trigger intake or register consequential production adapters. Deployments
80
+ must supply those trusted host dependencies explicitly. The runtime makes no
81
+ general exactly-once claim; ambiguous protected effects remain blocked until
82
+ their adapter reconciles them.
83
+
84
+ The daemon integration is opt-in:
85
+
86
+ ```json
87
+ {
88
+ "semanticRuntime": {
89
+ "enabled": true,
90
+ "watchdogMs": 100
91
+ }
92
+ }
93
+ ```
94
+
95
+ When enabled, a missing or modified local artifact, build-lock mismatch,
96
+ unexpected component import/export, incompatible ABI, failed Worker handshake,
97
+ or restore mismatch fails closed. Carrier WASI imports receive deny-only stubs:
98
+ the component receives no filesystem, network, environment, stdio, random, or
99
+ clock authority. Its repository-owned imports are an opaque, host-created
100
+ execution capability and five explicit typed tool interfaces.
101
+
102
+ Programs are stored in the DKG as `sr:Program` resources with `sr:language`,
103
+ `sr:version`, and `sr:source` triples. The authenticated
104
+ `POST /api/programs/execute` route loads a program by IRI from the
105
+ explicitly selected WM, SWM, or VM view of the requested context graph, admits
106
+ its S-expression in Wasm, and executes its logical agents there. The caller
107
+ also explicitly selects the Execution KA's target layer. The narrow execution
108
+ slice supports ordered `emit` forms and one typed tool request per delegate:
109
+ `agent/investigate@1`, `dkg/query@1`, `dkg/sparql-read@1`, `dkg/asset-create@1`, `remote-execute@1`, or `llm/safe@1`. The
110
+ host performs only the requested operation and returns its result to the
111
+ waiting Wasm process.
112
+
113
+ `llm/safe@1` runs a native Rust Rig loop whose only tools are zero-argument
114
+ Programs explicitly named by the parent Program's `sr:permitsProgram` triples.
115
+ The model receives opaque generated tool names, never a Program IRI or a
116
+ general query/network interface:
117
+
118
+ ```turtle
119
+ <urn:sr:program:safe-agent>
120
+ a sr:Program ;
121
+ sr:requiresTool <urn:sr:tool:safe-llm-v1> ;
122
+ sr:permitsProgram <urn:sr:program:field-a-read> .
123
+ ```
124
+
125
+ ```lisp
126
+ (delegate agent
127
+ (grant llm.invoke.safe)
128
+ (call llm/safe@1 "Read field A and summarize it."))
129
+ ```
130
+
131
+ Every selected child runs through the existing Program invocation path and
132
+ must persist its own Execution before its result is returned to Rig. The
133
+ parent Execution persists the final model text and links each child Execution
134
+ with `prov:wasInformedBy`.
135
+
136
+ The author node can run this loop against its local OpenAI-compatible model
137
+ without an API key. `DKG_LLM_URL` may name either the chat-completions endpoint
138
+ or its `/v1` base URL; `DKG_LLM_MODEL` selects the model:
139
+
140
+ ```bash
141
+ DKG_LLM_URL=http://127.0.0.1:8080/v1/chat/completions \
142
+ DKG_LLM_MODEL=qwen3-8b-q4-k-m \
143
+ pnpm dkg daemon-foreground-worker
144
+ ```
145
+
146
+ Only loopback endpoints are accepted without credentials. A remote compatible
147
+ endpoint still requires `llm.apiKey` (or `DKG_LLM_API_KEY` when selected with
148
+ `DKG_LLM_URL`).
149
+
150
+ `remote-execute@1` composes Programs without exposing a network socket to the
151
+ component:
152
+
153
+ ```lisp
154
+ (delegate composer
155
+ (grant program.remote-execute)
156
+ (call remote-execute@1 "12D3KooWTargetPeer" "urn:sr:program:child"))
157
+ ```
158
+
159
+ The child inherits the parent Context Graph and selected Program/Execution
160
+ layers. The signing wallet never comes from the S-expression. Each executing
161
+ node signs the next target-bound DKG inbox delegation with its current operator
162
+ wallet. The target independently requires a private Context Graph and current
163
+ membership for that immediate caller before executing the replicated Program
164
+ as its own node operator. This makes composition transitive without propagating
165
+ the root caller's wallet authority across hops.
166
+
167
+ For direct invocation, private Context Graph membership intentionally grants the right to request
168
+ Program execution; there is no mandatory caller-to-Program ACL. Final execution
169
+ authority remains with the target operator: every tool requested by the
170
+ Wasm-admitted Program must be offered by that operator, allowed by its
171
+ operator-authored VM policy, and backed by a locally installed and enabled
172
+ adapter. See
173
+ [`docs/architecture/semantic-runtime-invocation-authorization.md`](../../docs/architecture/semantic-runtime-invocation-authorization.md)
174
+ for the decision, trust model, and optional finer-grained policy extensions.
175
+
176
+ Admission can be exercised without activating the daemon integration:
177
+
178
+ ```ts
179
+ const admission = new WasmStrategyAdmissionClient();
180
+ const result = await admission.compileAndAdmit(source);
181
+ if (!result.ok) console.error(result.diagnostics);
182
+ ```
183
+
184
+ The conformance suite covers all restart classes and sibling strategies,
185
+ restart intensity, bounded mailboxes and budgets, native/Wasm kernel parity,
186
+ Worker hang/trap recovery, durable replay, every protected-effect crash
187
+ boundary, trusted activation, redacted projection, and the Listener Boy
188
+ ambiguous-effect lifecycle.
189
+
190
+ ### Optional operator Program policy
191
+
192
+ `semanticRuntime.programPolicy` adds local execution and disclosure controls independently
193
+ of any marketplace. Install it in trusted node configuration, alongside the existing
194
+ `operatorPolicyIri`; invocation requests and RDF Programs cannot grant themselves this policy.
195
+ Without this option, the existing adapter selection behavior remains available.
196
+
197
+ ```json
198
+ {
199
+ "programPolicy": {
200
+ "contextGraphIds": ["tenant-equipment"],
201
+ "programs": [
202
+ {
203
+ "programIri": "urn:program:maintenance-assessment",
204
+ "sourceHash": "<SHA-256 of the exact reviewed S-expression source>"
205
+ },
206
+ {
207
+ "programIri": "urn:program:maintenance-count",
208
+ "sourceHash": "<SHA-256 of the exact reviewed S-expression source>",
209
+ "queries": ["<reviewed SemanticQueryPin object>"]
210
+ }
211
+ ],
212
+ "disclosure": {
213
+ "policyId": "urn:policy:maintenance-summary",
214
+ "promptSha256s": ["<SHA-256 of the exact allowed prompt>"],
215
+ "programs": [{
216
+ "programIri": "urn:program:maintenance-count",
217
+ "sourceHash": "<same reviewed child source hash>",
218
+ "outputIndexes": [0],
219
+ "allowedJsonPointers": ["/result/bindings/0/count"]
220
+ }]
221
+ }
222
+ }
223
+ }
224
+ ```
225
+
226
+ This is a configuration template: replace the placeholders with reviewed pins and
227
+ 64-character lowercase hexadecimal hashes. The CLI helper `createSemanticQueryPin`
228
+ constructs a pin from a decoded catalog item and a closed, bounded output schema.
229
+ Review the query, its parameters, graph/view selection, and output schema before
230
+ installing that pin. The adapter checks the catalog definition before querying and
231
+ the actual query result against the schema before returning it. Omitting `queries`
232
+ from a Program in pinned mode grants no named queries.
233
+
234
+ Pinned mode registers only `dkg/query` and, when a disclosure policy is present,
235
+ `llm/safe`. Investigator and remote-execute adapters are unavailable in this mode.
236
+ Permitted children must be pinned and hosted locally; child invocations retain the
237
+ original caller. Local composition rejects cycles and chains longer than eight
238
+ Programs. Each LLM run retains the existing four-tool-call limit. The host rechecks
239
+ caller graph access, Program declarations/source, operator policy and active runtime
240
+ capabilities before model dispatch, child invocation and disclosure. Parent authority
241
+ also applies to nested children. This does not cancel a provider request already sent.
242
+
243
+ Disclosure rules select ordered child output positions, optionally projecting only
244
+ named JSON scalar fields. Omitting `allowedJsonPointers` releases the entire selected
245
+ output string. JSON objects/arrays cannot be released through a scalar pointer after
246
+ a schema change. Only a pinned prompt and approved opaque tool descriptions are sent;
247
+ raw child errors and child execution identifiers are excluded from model tool results.
248
+ Returned model text remains untrusted. These controls are additional host policy;
249
+ Wasm isolation alone does not authorize data release.
250
+
251
+ Execution KAs now include `sr:orderedOutputs`, a JSON string array preserving positions
252
+ and duplicate values alongside the existing `sr:output` triples. Reads check that both
253
+ representations agree. Legacy records with multiple distinct outputs fail closed because
254
+ RDF triples cannot recover their order; zero/single-value legacy records remain readable.
255
+ Invocation reuse is bound to the caller, source, policy, graph and memory layers. Older
256
+ journal entries without these bindings require a new invocation UUID.
257
+
258
+ ### Checkpointed adapter continuation
259
+
260
+ The runtime journal migrates existing v1 databases to v2 by adding a bounded adapter
261
+ checkpoint table. `writeAdapterCheckpoint` binds payloads to an existing effect digest
262
+ and uses an expected version to reject concurrent writes. Checkpoints remain local to
263
+ the node and may contain sensitive adapter state; no payload inspection HTTP route is
264
+ introduced here.
265
+
266
+ Adapters may explicitly implement `resume` and use `RuntimeEffectBroker.resumeUnknown`
267
+ when they can continue from durable receipts without repeating an unresolved side effect.
268
+ Continuation rechecks current capability, policy, expiry and adapter enablement, including
269
+ after asynchronous checks. Continuation and reconciliation serialize per database/effect
270
+ within one daemon process; this is not a lease for multiple processes sharing a database.
271
+ Terminal reconciliation updates are transactional.
272
+
273
+ The direct Rig LLM adapter does not implement `resume`: an interrupted model request
274
+ still requires reconciliation/manual review and is never blindly replayed. Provider
275
+ idempotency/status protocols, paid-call receipts, billing and seller transport belong to
276
+ the adapter/application that supplies those guarantees.
277
+
278
+ Tenant-configured invoke-only operations can load a pinned Program from a separate Context Graph while keeping the data graph private. See [tenant Program bindings](../../docs/architecture/tenant-program-bindings.md) for setup, API calls, activation and revocation. These operations derive execution authority from the trusted local binding and its explicitly approved installed adapters, without requiring VM policy or tool-offer publication. Direct invocation retains its VM policy requirements.
279
+
280
+
281
+ `dkg/asset-create@1` is installed for tenant bindings with an explicit `assetCreation`
282
+ grant. It accepts a JSON string containing bounded RDF triples; the host chooses
283
+ CG, execution layer, executor identity and a deterministic asset name. VM creation
284
+ requires confirmed publication. Retries use the durable effect/checkpoint journal;
285
+ an unresolved publication is reconciled rather than blindly repeated. See
286
+ [tenant Program operations](../../docs/architecture/tenant-program-bindings.md#creating-a-knowledge-asset-in-the-execution-layer)
287
+ for configuration and a Kamstrup example. This is not arbitrary SPARQL UPDATE.
288
+
289
+ `dkg/sparql-read@1` is available only with a tenant binding's explicit `sparqlRead`
290
+ grant. It runs approved Program-source SPARQL through the existing scoped query
291
+ engine, with a fixed CG, executor and memory layer, bounded output schema and
292
+ limits. No query catalog entry is required. `SERVICE`, dataset overrides and
293
+ SPARQL writes are rejected. See [raw reads and the Kamstrup example](../../docs/architecture/tenant-program-bindings.md#raw-sparql-reads-without-a-query-catalog).
294
+
295
+ Program permissions and outbound routes can now be managed through the
296
+ [Program authorization API](../../docs/architecture/program-authorization-api.md).
297
+ Owner/operator-authenticated changes persist in SQLite and apply immediately;
298
+ API revocation/removal overrides file defaults across restarts. Invocation keeps
299
+ its signed-agent and invoke-only authority boundary. The API does not grant raw
300
+ graph membership and never dispatches host effects during activation preflight.
@@ -0,0 +1,12 @@
1
+ {
2
+ "lockVersion": 1,
3
+ "rustToolchain": "nightly-2026-08-18",
4
+ "rustVersion": "1.100.0-nightly",
5
+ "jcoVersion": "1.32.1",
6
+ "wasiVersion": "0.3.0",
7
+ "targetCarrier": "wasm32-wasip2",
8
+ "witPackage": "origintrail:semantic-runtime@0.1.0",
9
+ "integritySha256": "2c83f80e1e092162c7434c4bbbc8a72814d872dc7b2521c44bcb2f9f0783441a",
10
+ "componentSha256": "0bae419255a0326d09d595c70db283270dc145389b9d92d1aed696bf66240a77",
11
+ "witSha256": "6088e48817533febc37f00d738002417769ce904bef319deabe6a1df8d538155"
12
+ }
@@ -0,0 +1,73 @@
1
+ import { SemanticRuntimeStore, type ExecutionRecord, type StrategyArtifactRecord } from './persistence.js';
2
+ import type { AdmittedPlanSummary } from './codec.js';
3
+ export interface TriggerCandidate {
4
+ triggerId: string;
5
+ triggerType: string;
6
+ triggerDigest: string;
7
+ strategyId: string;
8
+ strategyVersion: string;
9
+ graphRevision: string;
10
+ policyEpoch: bigint;
11
+ activationPrincipal: string;
12
+ eventTime: number;
13
+ }
14
+ export interface StrategyActivationMetadata {
15
+ strategyId: string;
16
+ version: string;
17
+ strategyType: string;
18
+ artifactHash: string;
19
+ authorPrincipal: string;
20
+ authorKeyId: string;
21
+ signature: Uint8Array;
22
+ reviewState: 'draft' | 'reviewed' | 'approved' | 'revoked';
23
+ activationScope: string;
24
+ declaredEffects: string[];
25
+ requiredCapabilities: string[];
26
+ }
27
+ export interface StrategyMetadataLookup {
28
+ resolve(candidate: Readonly<TriggerCandidate>): Promise<StrategyActivationMetadata | null>;
29
+ }
30
+ export interface ImmutableStrategyArtifactProvider {
31
+ get(artifactHash: string): Promise<{
32
+ canonicalPlan: Uint8Array;
33
+ sourceRef: string;
34
+ createdAt: number;
35
+ } | null>;
36
+ }
37
+ export interface StrategySignatureVerifier {
38
+ verify(input: {
39
+ artifactHash: string;
40
+ signature: Uint8Array;
41
+ authorPrincipal: string;
42
+ authorKeyId: string;
43
+ }): Promise<boolean>;
44
+ }
45
+ export interface StrategyPlanAdmission {
46
+ admitPlan(canonicalPlan: Uint8Array): Promise<AdmittedPlanSummary>;
47
+ }
48
+ export interface TrustedActivationPolicy {
49
+ allowedStrategyTypes: ReadonlySet<string>;
50
+ allowedStrategyIds: ReadonlySet<string>;
51
+ trustedAuthors: ReadonlySet<string>;
52
+ requiredReviewState: 'reviewed' | 'approved';
53
+ currentPolicyEpoch(): bigint;
54
+ acceptsScope(scope: string, candidate: Readonly<TriggerCandidate>): boolean;
55
+ }
56
+ export interface ActivationResult {
57
+ execution: ExecutionRecord;
58
+ metadata: StrategyActivationMetadata;
59
+ artifact: StrategyArtifactRecord;
60
+ }
61
+ export declare class TrustedStrategyActivationService {
62
+ private readonly store;
63
+ private readonly metadata;
64
+ private readonly artifacts;
65
+ private readonly signatures;
66
+ private readonly admission;
67
+ private readonly policy;
68
+ constructor(store: SemanticRuntimeStore, metadata: StrategyMetadataLookup, artifacts: ImmutableStrategyArtifactProvider, signatures: StrategySignatureVerifier, admission: StrategyPlanAdmission, policy: TrustedActivationPolicy);
69
+ activate(candidate: TriggerCandidate): Promise<ActivationResult>;
70
+ private validateMetadata;
71
+ }
72
+ export declare function hashCanonicalPlan(canonicalPlan: Uint8Array): string;
73
+ //# sourceMappingURL=activation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../src/activation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,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