@stigmer/server 3.14.0 → 3.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/boot/compose.d.ts +8 -1
  2. package/dist/boot/compose.d.ts.map +1 -1
  3. package/dist/boot/compose.js +98 -12
  4. package/dist/boot/compose.js.map +1 -1
  5. package/dist/domain/agentexecution/constants.d.ts +16 -0
  6. package/dist/domain/agentexecution/constants.d.ts.map +1 -1
  7. package/dist/domain/agentexecution/constants.js +22 -0
  8. package/dist/domain/agentexecution/constants.js.map +1 -1
  9. package/dist/domain/agentexecution/controller.d.ts.map +1 -1
  10. package/dist/domain/agentexecution/controller.js +10 -3
  11. package/dist/domain/agentexecution/controller.js.map +1 -1
  12. package/dist/domain/agentexecution/run-target.d.ts +26 -0
  13. package/dist/domain/agentexecution/run-target.d.ts.map +1 -0
  14. package/dist/domain/agentexecution/run-target.js +31 -0
  15. package/dist/domain/agentexecution/run-target.js.map +1 -0
  16. package/dist/domain/apikey/verifier.d.ts +8 -1
  17. package/dist/domain/apikey/verifier.d.ts.map +1 -1
  18. package/dist/domain/apikey/verifier.js +14 -2
  19. package/dist/domain/apikey/verifier.js.map +1 -1
  20. package/dist/domain/identityaccount/constants.d.ts +66 -0
  21. package/dist/domain/identityaccount/constants.d.ts.map +1 -0
  22. package/dist/domain/identityaccount/constants.js +153 -0
  23. package/dist/domain/identityaccount/constants.js.map +1 -0
  24. package/dist/domain/identityaccount/controller.d.ts +34 -0
  25. package/dist/domain/identityaccount/controller.d.ts.map +1 -0
  26. package/dist/domain/identityaccount/controller.js +342 -0
  27. package/dist/domain/identityaccount/controller.js.map +1 -0
  28. package/dist/domain/identityaccount/operator.d.ts +14 -0
  29. package/dist/domain/identityaccount/operator.d.ts.map +1 -0
  30. package/dist/domain/identityaccount/operator.js +67 -0
  31. package/dist/domain/identityaccount/operator.js.map +1 -0
  32. package/dist/domain/identityaccount/provisioning.d.ts +52 -0
  33. package/dist/domain/identityaccount/provisioning.d.ts.map +1 -0
  34. package/dist/domain/identityaccount/provisioning.js +114 -0
  35. package/dist/domain/identityaccount/provisioning.js.map +1 -0
  36. package/dist/domain/identityaccount/resolve.d.ts +36 -0
  37. package/dist/domain/identityaccount/resolve.d.ts.map +1 -0
  38. package/dist/domain/identityaccount/resolve.js +12 -0
  39. package/dist/domain/identityaccount/resolve.js.map +1 -0
  40. package/dist/domain/identityaccount/resource-store.d.ts +4 -0
  41. package/dist/domain/identityaccount/resource-store.d.ts.map +1 -0
  42. package/dist/domain/identityaccount/resource-store.js +131 -0
  43. package/dist/domain/identityaccount/resource-store.js.map +1 -0
  44. package/dist/domain/identityaccount/steps.d.ts +79 -0
  45. package/dist/domain/identityaccount/steps.d.ts.map +1 -0
  46. package/dist/domain/identityaccount/steps.js +291 -0
  47. package/dist/domain/identityaccount/steps.js.map +1 -0
  48. package/dist/domain/identityaccount/store-contract.d.ts +22 -0
  49. package/dist/domain/identityaccount/store-contract.d.ts.map +1 -0
  50. package/dist/domain/identityaccount/store-contract.js +307 -0
  51. package/dist/domain/identityaccount/store-contract.js.map +1 -0
  52. package/dist/domain/identityaccount/store.d.ts +66 -0
  53. package/dist/domain/identityaccount/store.d.ts.map +1 -0
  54. package/dist/domain/identityaccount/store.js +13 -0
  55. package/dist/domain/identityaccount/store.js.map +1 -0
  56. package/dist/domain/session/constants.d.ts +15 -0
  57. package/dist/domain/session/constants.d.ts.map +1 -0
  58. package/dist/domain/session/constants.js +17 -0
  59. package/dist/domain/session/constants.js.map +1 -0
  60. package/dist/domain/session/controller.d.ts.map +1 -1
  61. package/dist/domain/session/controller.js +10 -0
  62. package/dist/domain/session/controller.js.map +1 -1
  63. package/dist/domain/session/run-target.d.ts +15 -0
  64. package/dist/domain/session/run-target.d.ts.map +1 -0
  65. package/dist/domain/session/run-target.js +14 -0
  66. package/dist/domain/session/run-target.js.map +1 -0
  67. package/dist/domain/workflowexecution/constants.d.ts +9 -0
  68. package/dist/domain/workflowexecution/constants.d.ts.map +1 -1
  69. package/dist/domain/workflowexecution/constants.js +13 -0
  70. package/dist/domain/workflowexecution/constants.js.map +1 -1
  71. package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
  72. package/dist/domain/workflowexecution/controller.js +8 -0
  73. package/dist/domain/workflowexecution/controller.js.map +1 -1
  74. package/dist/domain/workflowexecution/run-target.d.ts +18 -0
  75. package/dist/domain/workflowexecution/run-target.d.ts.map +1 -0
  76. package/dist/domain/workflowexecution/run-target.js +23 -0
  77. package/dist/domain/workflowexecution/run-target.js.map +1 -0
  78. package/dist/extensions/drivers.d.ts +26 -0
  79. package/dist/extensions/drivers.d.ts.map +1 -1
  80. package/dist/extensions/gate-slots.d.ts +16 -1
  81. package/dist/extensions/gate-slots.d.ts.map +1 -1
  82. package/dist/extensions/gate-slots.js +1 -0
  83. package/dist/extensions/gate-slots.js.map +1 -1
  84. package/dist/extensions/identity-federation.d.ts +36 -0
  85. package/dist/extensions/identity-federation.d.ts.map +1 -0
  86. package/dist/extensions/identity-federation.js +2 -0
  87. package/dist/extensions/identity-federation.js.map +1 -0
  88. package/dist/extensions/registry.d.ts +18 -1
  89. package/dist/extensions/registry.d.ts.map +1 -1
  90. package/dist/extensions/registry.js +20 -0
  91. package/dist/extensions/registry.js.map +1 -1
  92. package/dist/identity/oidc-discovery.d.ts +36 -0
  93. package/dist/identity/oidc-discovery.d.ts.map +1 -0
  94. package/dist/identity/oidc-discovery.js +60 -0
  95. package/dist/identity/oidc-discovery.js.map +1 -0
  96. package/dist/identity/oidc-userinfo.d.ts +30 -0
  97. package/dist/identity/oidc-userinfo.d.ts.map +1 -0
  98. package/dist/identity/oidc-userinfo.js +28 -0
  99. package/dist/identity/oidc-userinfo.js.map +1 -0
  100. package/dist/identity/oidc-verifier.d.ts +6 -0
  101. package/dist/identity/oidc-verifier.d.ts.map +1 -1
  102. package/dist/identity/oidc-verifier.js +35 -34
  103. package/dist/identity/oidc-verifier.js.map +1 -1
  104. package/dist/index.d.ts +8 -0
  105. package/dist/index.d.ts.map +1 -1
  106. package/dist/index.js +10 -0
  107. package/dist/index.js.map +1 -1
  108. package/dist/pipeline/interceptors/auth.d.ts +10 -0
  109. package/dist/pipeline/interceptors/auth.d.ts.map +1 -1
  110. package/dist/pipeline/interceptors/auth.js +9 -1
  111. package/dist/pipeline/interceptors/auth.js.map +1 -1
  112. package/dist/pipeline/steps/authorize-run-target.d.ts +105 -0
  113. package/dist/pipeline/steps/authorize-run-target.d.ts.map +1 -0
  114. package/dist/pipeline/steps/authorize-run-target.js +61 -0
  115. package/dist/pipeline/steps/authorize-run-target.js.map +1 -0
  116. package/dist/query/search/criteria.d.ts +10 -3
  117. package/dist/query/search/criteria.d.ts.map +1 -1
  118. package/dist/query/search/criteria.js +11 -4
  119. package/dist/query/search/criteria.js.map +1 -1
  120. package/package.json +4 -4
  121. package/src/boot/__tests__/auth-enabled-composition.test.ts +226 -2
  122. package/src/boot/compose.ts +118 -13
  123. package/src/domain/agentexecution/__tests__/run-gate.test.ts +245 -0
  124. package/src/domain/agentexecution/__tests__/run-target.test.ts +117 -0
  125. package/src/domain/agentexecution/constants.ts +25 -0
  126. package/src/domain/agentexecution/controller.ts +10 -3
  127. package/src/domain/agentexecution/run-target.ts +64 -0
  128. package/src/domain/apikey/__tests__/verifier.test.ts +146 -22
  129. package/src/domain/apikey/verifier.ts +24 -2
  130. package/src/domain/identityaccount/__tests__/constants.test.ts +155 -0
  131. package/src/domain/identityaccount/__tests__/identityaccount.test.ts +484 -0
  132. package/src/domain/identityaccount/__tests__/operator.test.ts +180 -0
  133. package/src/domain/identityaccount/__tests__/provisioning.test.ts +281 -0
  134. package/src/domain/identityaccount/__tests__/resolve.test.ts +114 -0
  135. package/src/domain/identityaccount/__tests__/resource-store.test.ts +216 -0
  136. package/src/domain/identityaccount/__tests__/support.ts +58 -0
  137. package/src/domain/identityaccount/constants.ts +178 -0
  138. package/src/domain/identityaccount/controller.ts +667 -0
  139. package/src/domain/identityaccount/operator.ts +94 -0
  140. package/src/domain/identityaccount/provisioning.ts +182 -0
  141. package/src/domain/identityaccount/resolve.ts +52 -0
  142. package/src/domain/identityaccount/resource-store.ts +157 -0
  143. package/src/domain/identityaccount/steps.ts +377 -0
  144. package/src/domain/identityaccount/store-contract.ts +471 -0
  145. package/src/domain/identityaccount/store.ts +70 -0
  146. package/src/domain/session/__tests__/run-gate.test.ts +219 -0
  147. package/src/domain/session/__tests__/run-target.test.ts +43 -0
  148. package/src/domain/session/constants.ts +17 -0
  149. package/src/domain/session/controller.ts +10 -0
  150. package/src/domain/session/run-target.ts +30 -0
  151. package/src/domain/workflowexecution/__tests__/run-gate.test.ts +200 -0
  152. package/src/domain/workflowexecution/__tests__/run-target.test.ts +80 -0
  153. package/src/domain/workflowexecution/constants.ts +17 -0
  154. package/src/domain/workflowexecution/controller.ts +10 -0
  155. package/src/domain/workflowexecution/run-target.ts +47 -0
  156. package/src/extensions/__tests__/extension-composition.test.ts +49 -0
  157. package/src/extensions/__tests__/identity-account-composed.test.ts +803 -0
  158. package/src/extensions/__tests__/identity-account-points.test.ts +129 -0
  159. package/src/extensions/__tests__/registry.test.ts +4 -0
  160. package/src/extensions/__tests__/tier-truthfulness.test.ts +299 -0
  161. package/src/extensions/drivers.ts +26 -0
  162. package/src/extensions/gate-slots.ts +16 -0
  163. package/src/extensions/identity-federation.ts +58 -0
  164. package/src/extensions/registry.ts +44 -1
  165. package/src/identity/__tests__/oidc-discovery.test.ts +122 -0
  166. package/src/identity/__tests__/oidc-userinfo.test.ts +103 -0
  167. package/src/identity/__tests__/oidc-verifier.test.ts +173 -3
  168. package/src/identity/oidc-discovery.ts +84 -0
  169. package/src/identity/oidc-userinfo.ts +64 -0
  170. package/src/identity/oidc-verifier.ts +42 -45
  171. package/src/index.ts +26 -0
  172. package/src/pipeline/__tests__/support.ts +34 -0
  173. package/src/pipeline/interceptors/auth.ts +13 -1
  174. package/src/pipeline/steps/__tests__/authorize-annotation-completeness.test.ts +184 -0
  175. package/src/pipeline/steps/__tests__/authorize-run-target.test.ts +261 -0
  176. package/src/pipeline/steps/authorize-run-target.ts +148 -0
  177. package/src/query/search/__tests__/criteria.test.ts +18 -1
  178. package/src/query/search/criteria.ts +11 -4
@@ -49,6 +49,7 @@ import { newPipeline } from "../../pipeline/pipeline.js";
49
49
  import { callerIdentityOf } from "../../pipeline/interceptors/auth.js";
50
50
  import { RequestContext } from "../../pipeline/request-context.js";
51
51
  import { newAuthorizeStep } from "../../pipeline/steps/authorize.js";
52
+ import { newAuthorizeRunTargetStep } from "../../pipeline/steps/authorize-run-target.js";
52
53
  import { newGuardReservedLabelsStep } from "../../pipeline/steps/guard-reserved-labels.js";
53
54
  import { newBuildUpdateStateStep } from "../../pipeline/steps/build-update-state.js";
54
55
  import { newBuildNewStateStep } from "../../pipeline/steps/defaults.js";
@@ -116,6 +117,7 @@ import { getEventLog } from "./get-event-log.js";
116
117
  import { getExecutionSummary } from "./get-execution-summary.js";
117
118
  import { listPendingApprovals } from "./list-pending-approvals.js";
118
119
  import { loadAllWorkflowExecutions } from "./queries.js";
120
+ import { workflowExecutionRunTarget } from "./run-target.js";
119
121
  import { workflowExecutionSearchExtractor } from "./search-extractor.js";
120
122
  import type { SandboxLane } from "../../sandbox/lane.js";
121
123
  import type { WorkflowSandboxTerminalObserver } from "../../sandbox/steps.js";
@@ -243,6 +245,11 @@ export function registerWorkflowExecutionServices(
243
245
  * Create — create.go buildCreatePipeline, step-for-step (the numbered
244
246
  * 15-step chain): validation (proto → visibility → slug →
245
247
  * workflow-or-instance presence, the #196 InvalidArgument contrast) →
248
+ * the run gate (AuthorizeRunTarget, P1 sp.run-gate: the first step after
249
+ * the target reference is guaranteed, asking workflow_instance#can_execute
250
+ * or workflow#can_execute by request shape — before the engine gate so a
251
+ * denied caller learns nothing about engine state, and before the workflow
252
+ * lookup, so a denial reads nothing) →
246
253
  * the ENGINE GATE at its pinned position (before every side effect — a
247
254
  * down engine orphans nothing; Go's unit test pins that it precedes even
248
255
  * the workflow lookup) → default-instance resolution → the standard
@@ -276,6 +283,9 @@ async function createExecution(
276
283
  .addStep(newValidateVisibilityStep())
277
284
  .addStep(newResolveSlugStep())
278
285
  .addStep(newValidateWorkflowOrInstanceStep())
286
+ .addStep(
287
+ newAuthorizeRunTargetStep(deps.authorizer, workflowExecutionRunTarget),
288
+ )
279
289
  .addStep(newEnsureEngineAvailableStep(deps.engineState))
280
290
  .addStep(
281
291
  newCreateDefaultInstanceIfNeededStep({
@@ -0,0 +1,47 @@
1
+ /**
2
+ * The workflow-execution run-target resolver (P1 sp.run-gate): the chain's
3
+ * own precedence — an explicit workflow_instance_id fully names the target
4
+ * (CreateDefaultInstanceIfNeeded returns early on it):
5
+ * workflow_instance#can_execute; else workflow_id names the blueprint whose
6
+ * default instance the chain resolves (or mints) only AFTER the gate:
7
+ * workflow#can_execute (the model derives the default instance's viewers
8
+ * from the blueprint's, so asking the blueprint's question is what lets the
9
+ * gate precede the side effect).
10
+ *
11
+ * Neither set is ValidateWorkflowOrInstance's INVALID_ARGUMENT, thrown
12
+ * before this resolver runs — never a check. Pure over the record being
13
+ * built.
14
+ */
15
+ import type { WorkflowExecution } from "@stigmer/protos/ai/stigmer/agentic/workflowexecution/v1/api_pb";
16
+
17
+ import {
18
+ RUN_GATE_CHECKS,
19
+ type RunTarget,
20
+ } from "../../pipeline/steps/authorize-run-target.js";
21
+ import {
22
+ runWorkflowDeniedMessage,
23
+ runWorkflowInstanceDeniedMessage,
24
+ } from "./constants.js";
25
+
26
+ export function workflowExecutionRunTarget(
27
+ execution: WorkflowExecution,
28
+ ): RunTarget | undefined {
29
+ const spec = execution.spec;
30
+ const workflowInstanceId = spec?.workflowInstanceId ?? "";
31
+ if (workflowInstanceId !== "") {
32
+ return {
33
+ ...RUN_GATE_CHECKS.workflowInstance,
34
+ resourceId: workflowInstanceId,
35
+ deniedMessage: runWorkflowInstanceDeniedMessage(workflowInstanceId),
36
+ };
37
+ }
38
+ const workflowId = spec?.workflowId ?? "";
39
+ if (workflowId !== "") {
40
+ return {
41
+ ...RUN_GATE_CHECKS.workflow,
42
+ resourceId: workflowId,
43
+ deniedMessage: runWorkflowDeniedMessage(workflowId),
44
+ };
45
+ }
46
+ return undefined;
47
+ }
@@ -178,6 +178,55 @@ describe("extension composition (composed server)", () => {
178
178
  });
179
179
  });
180
180
 
181
+ /**
182
+ * The third edition on the wire (editions program, sp.edition-contract):
183
+ * a unit declaring ServerEdition.enterprise is answered verbatim by
184
+ * getServerInfo. The registry is generic over concrete editions, so this
185
+ * pins the end-to-end path (declaration → resolved registry → platform
186
+ * controller → wire) for the value no composition emits yet — the day
187
+ * P4's Enterprise composition declares it, the wire is already proven.
188
+ */
189
+ describe("extension composition (enterprise edition on the wire)", () => {
190
+ let server: ComposedServer;
191
+ let dir: string;
192
+ let portTransport: Transport;
193
+
194
+ const enterpriseUnit: ServerExtension = {
195
+ name: "fake-enterprise",
196
+ edition: ServerEdition.enterprise,
197
+ };
198
+
199
+ beforeAll(async () => {
200
+ dir = mkdtempSync(path.join(tmpdir(), "extension-composition-ee-test-"));
201
+ server = await composeServer({
202
+ config: loadConfig({
203
+ STIGMER_MODEL_REGISTRY_REFRESH: "off",
204
+ DB_PATH: path.join(dir, "stigmer.db"),
205
+ ARTIFACT_LOCAL_BASE_PATH: path.join(dir, "artifacts"),
206
+ }),
207
+ logger: createLogger({ level: "warn", pretty: false, write: () => {} }),
208
+ extensions: [enterpriseUnit],
209
+ portOverride: 0,
210
+ host: "127.0.0.1",
211
+ });
212
+ const port = await server.start();
213
+ portTransport = createGrpcTransport({
214
+ baseUrl: `http://127.0.0.1:${port}`,
215
+ });
216
+ });
217
+
218
+ afterAll(async () => {
219
+ await server.shutdown();
220
+ rmSync(dir, { recursive: true, force: true });
221
+ });
222
+
223
+ it("answers enterprise on getServerInfo", async () => {
224
+ const client = createClient(PlatformQueryController, portTransport);
225
+ const info = await client.getServerInfo({});
226
+ expect(info.edition).toBe(ServerEdition.enterprise);
227
+ });
228
+ });
229
+
181
230
  /**
182
231
  * The caller-guard arm (entry 20260902.02 ruling Q1): a composed guard
183
232
  * is enforced on the SERVING chain and structurally absent from the