@decionis/agentsafe 0.2.4 → 0.3.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 (320) hide show
  1. package/README.md +135 -20
  2. package/dist/Cli.js +20 -0
  3. package/dist/Cli.js.map +1 -1
  4. package/dist/Index.d.ts +22 -5
  5. package/dist/Index.d.ts.map +1 -1
  6. package/dist/Index.js +19 -2
  7. package/dist/Index.js.map +1 -1
  8. package/dist/TrustedExecutor.d.ts.map +1 -1
  9. package/dist/TrustedExecutor.js +1 -0
  10. package/dist/TrustedExecutor.js.map +1 -1
  11. package/dist/adapters/AdapterActionHandler.d.ts.map +1 -1
  12. package/dist/adapters/AdapterActionHandler.js +8 -4
  13. package/dist/adapters/AdapterActionHandler.js.map +1 -1
  14. package/dist/adapters/EffectAdapter.d.ts +6 -1
  15. package/dist/adapters/EffectAdapter.d.ts.map +1 -1
  16. package/dist/adapters/EffectAdapter.js +7 -1
  17. package/dist/adapters/EffectAdapter.js.map +1 -1
  18. package/dist/adapters/banking/CoreBankingHttpAdapter.d.ts.map +1 -1
  19. package/dist/adapters/banking/CoreBankingHttpAdapter.js +4 -4
  20. package/dist/adapters/banking/CoreBankingHttpAdapter.js.map +1 -1
  21. package/dist/adapters/cards/CardAuthorizationMatcher.d.ts +44 -0
  22. package/dist/adapters/cards/CardAuthorizationMatcher.d.ts.map +1 -0
  23. package/dist/adapters/cards/CardAuthorizationMatcher.js +39 -0
  24. package/dist/adapters/cards/CardAuthorizationMatcher.js.map +1 -0
  25. package/dist/adapters/cards/CardEffect.d.ts +52 -0
  26. package/dist/adapters/cards/CardEffect.d.ts.map +1 -0
  27. package/dist/adapters/cards/CardEffect.js +117 -0
  28. package/dist/adapters/cards/CardEffect.js.map +1 -0
  29. package/dist/adapters/cards/CardHandlers.d.ts +15 -0
  30. package/dist/adapters/cards/CardHandlers.d.ts.map +1 -0
  31. package/dist/adapters/cards/CardHandlers.js +26 -0
  32. package/dist/adapters/cards/CardHandlers.js.map +1 -0
  33. package/dist/adapters/cards/CardPurchase.d.ts +61 -0
  34. package/dist/adapters/cards/CardPurchase.d.ts.map +1 -0
  35. package/dist/adapters/cards/CardPurchase.js +116 -0
  36. package/dist/adapters/cards/CardPurchase.js.map +1 -0
  37. package/dist/adapters/cards/HeldCardGrants.d.ts +70 -0
  38. package/dist/adapters/cards/HeldCardGrants.d.ts.map +1 -0
  39. package/dist/adapters/cards/HeldCardGrants.js +79 -0
  40. package/dist/adapters/cards/HeldCardGrants.js.map +1 -0
  41. package/dist/adapters/cards/Pan.d.ts +17 -0
  42. package/dist/adapters/cards/Pan.d.ts.map +1 -0
  43. package/dist/adapters/cards/Pan.js +52 -0
  44. package/dist/adapters/cards/Pan.js.map +1 -0
  45. package/dist/adapters/mcp/McpGuard.d.ts +91 -0
  46. package/dist/adapters/mcp/McpGuard.d.ts.map +1 -0
  47. package/dist/adapters/mcp/McpGuard.js +147 -0
  48. package/dist/adapters/mcp/McpGuard.js.map +1 -0
  49. package/dist/adapters/mcp/McpIntentBinder.d.ts +54 -0
  50. package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -0
  51. package/dist/adapters/mcp/McpIntentBinder.js +79 -0
  52. package/dist/adapters/mcp/McpIntentBinder.js.map +1 -0
  53. package/dist/adapters/mcp/McpInvocation.d.ts +55 -0
  54. package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -0
  55. package/dist/adapters/mcp/McpInvocation.js +88 -0
  56. package/dist/adapters/mcp/McpInvocation.js.map +1 -0
  57. package/dist/audit/HashChain.d.ts +8 -2
  58. package/dist/audit/HashChain.d.ts.map +1 -1
  59. package/dist/audit/HashChain.js +14 -2
  60. package/dist/audit/HashChain.js.map +1 -1
  61. package/dist/boundary/BoundaryIdentity.d.ts +88 -0
  62. package/dist/boundary/BoundaryIdentity.d.ts.map +1 -0
  63. package/dist/boundary/BoundaryIdentity.js +126 -0
  64. package/dist/boundary/BoundaryIdentity.js.map +1 -0
  65. package/dist/cli/Commands.d.ts +1 -1
  66. package/dist/cli/Commands.d.ts.map +1 -1
  67. package/dist/cli/Commands.js +10 -0
  68. package/dist/cli/Commands.js.map +1 -1
  69. package/dist/cli/Edge.d.ts +4 -0
  70. package/dist/cli/Edge.d.ts.map +1 -0
  71. package/dist/cli/Edge.js +250 -0
  72. package/dist/cli/Edge.js.map +1 -0
  73. package/dist/cli/Help.d.ts.map +1 -1
  74. package/dist/cli/Help.js +9 -0
  75. package/dist/cli/Help.js.map +1 -1
  76. package/dist/cli/Host.d.ts +36 -0
  77. package/dist/cli/Host.d.ts.map +1 -0
  78. package/dist/cli/Host.js +247 -0
  79. package/dist/cli/Host.js.map +1 -0
  80. package/dist/cli/Identity.d.ts +47 -0
  81. package/dist/cli/Identity.d.ts.map +1 -0
  82. package/dist/cli/Identity.js +145 -0
  83. package/dist/cli/Identity.js.map +1 -0
  84. package/dist/cli/TcpBrokerCli.d.ts +4 -0
  85. package/dist/cli/TcpBrokerCli.d.ts.map +1 -0
  86. package/dist/cli/TcpBrokerCli.js +93 -0
  87. package/dist/cli/TcpBrokerCli.js.map +1 -0
  88. package/dist/cli/TcpClientCli.d.ts +16 -0
  89. package/dist/cli/TcpClientCli.d.ts.map +1 -0
  90. package/dist/cli/TcpClientCli.js +175 -0
  91. package/dist/cli/TcpClientCli.js.map +1 -0
  92. package/dist/cli/TestCommand.d.ts +8 -0
  93. package/dist/cli/TestCommand.d.ts.map +1 -1
  94. package/dist/cli/TestCommand.js +25 -5
  95. package/dist/cli/TestCommand.js.map +1 -1
  96. package/dist/config/ConfigKeys.d.ts +2 -2
  97. package/dist/config/ConfigKeys.d.ts.map +1 -1
  98. package/dist/config/ConfigKeys.js +19 -0
  99. package/dist/config/ConfigKeys.js.map +1 -1
  100. package/dist/config/ExecutorConfig.d.ts +62 -0
  101. package/dist/config/ExecutorConfig.d.ts.map +1 -1
  102. package/dist/config/ExecutorConfig.js +124 -0
  103. package/dist/config/ExecutorConfig.js.map +1 -1
  104. package/dist/edge/EdgeLicence.d.ts +25 -0
  105. package/dist/edge/EdgeLicence.d.ts.map +1 -0
  106. package/dist/edge/EdgeLicence.js +42 -0
  107. package/dist/edge/EdgeLicence.js.map +1 -0
  108. package/dist/edge/EdgeReplay.d.ts +45 -0
  109. package/dist/edge/EdgeReplay.d.ts.map +1 -0
  110. package/dist/edge/EdgeReplay.js +69 -0
  111. package/dist/edge/EdgeReplay.js.map +1 -0
  112. package/dist/edge/Entitlement.d.ts +57 -0
  113. package/dist/edge/Entitlement.d.ts.map +1 -0
  114. package/dist/edge/Entitlement.js +139 -0
  115. package/dist/edge/Entitlement.js.map +1 -0
  116. package/dist/edge/EntitlementEvaluation.d.ts +66 -0
  117. package/dist/edge/EntitlementEvaluation.d.ts.map +1 -0
  118. package/dist/edge/EntitlementEvaluation.js +74 -0
  119. package/dist/edge/EntitlementEvaluation.js.map +1 -0
  120. package/dist/edge/UsageCount.d.ts +40 -0
  121. package/dist/edge/UsageCount.d.ts.map +1 -0
  122. package/dist/edge/UsageCount.js +140 -0
  123. package/dist/edge/UsageCount.js.map +1 -0
  124. package/dist/edge/UsageKeyRegistration.d.ts +34 -0
  125. package/dist/edge/UsageKeyRegistration.d.ts.map +1 -0
  126. package/dist/edge/UsageKeyRegistration.js +74 -0
  127. package/dist/edge/UsageKeyRegistration.js.map +1 -0
  128. package/dist/edge/UsageMeter.d.ts +89 -0
  129. package/dist/edge/UsageMeter.d.ts.map +1 -0
  130. package/dist/edge/UsageMeter.js +275 -0
  131. package/dist/edge/UsageMeter.js.map +1 -0
  132. package/dist/edge/UsagePeriod.d.ts +23 -0
  133. package/dist/edge/UsagePeriod.d.ts.map +1 -0
  134. package/dist/edge/UsagePeriod.js +31 -0
  135. package/dist/edge/UsagePeriod.js.map +1 -0
  136. package/dist/edge/UsageReport.d.ts +92 -0
  137. package/dist/edge/UsageReport.d.ts.map +1 -0
  138. package/dist/edge/UsageReport.js +153 -0
  139. package/dist/edge/UsageReport.js.map +1 -0
  140. package/dist/edge/UsageTally.d.ts +63 -0
  141. package/dist/edge/UsageTally.d.ts.map +1 -0
  142. package/dist/edge/UsageTally.js +89 -0
  143. package/dist/edge/UsageTally.js.map +1 -0
  144. package/dist/egress/EgressError.d.ts +7 -1
  145. package/dist/egress/EgressError.d.ts.map +1 -1
  146. package/dist/egress/EgressError.js.map +1 -1
  147. package/dist/egress/EgressPolicy.d.ts +16 -3
  148. package/dist/egress/EgressPolicy.d.ts.map +1 -1
  149. package/dist/egress/EgressPolicy.js +33 -3
  150. package/dist/egress/EgressPolicy.js.map +1 -1
  151. package/dist/egress/GuardedFetch.d.ts +38 -1
  152. package/dist/egress/GuardedFetch.d.ts.map +1 -1
  153. package/dist/egress/GuardedFetch.js +52 -7
  154. package/dist/egress/GuardedFetch.js.map +1 -1
  155. package/dist/egress/TcpClient.d.ts +103 -0
  156. package/dist/egress/TcpClient.d.ts.map +1 -0
  157. package/dist/egress/TcpClient.js +490 -0
  158. package/dist/egress/TcpClient.js.map +1 -0
  159. package/dist/egress/TcpControlClient.d.ts +49 -0
  160. package/dist/egress/TcpControlClient.d.ts.map +1 -0
  161. package/dist/egress/TcpControlClient.js +186 -0
  162. package/dist/egress/TcpControlClient.js.map +1 -0
  163. package/dist/gateway/AuthorityAttacks.d.ts +39 -0
  164. package/dist/gateway/AuthorityAttacks.d.ts.map +1 -0
  165. package/dist/gateway/AuthorityAttacks.js +158 -0
  166. package/dist/gateway/AuthorityAttacks.js.map +1 -0
  167. package/dist/gateway/ForwardHandler.d.ts.map +1 -1
  168. package/dist/gateway/ForwardHandler.js +7 -4
  169. package/dist/gateway/ForwardHandler.js.map +1 -1
  170. package/dist/gateway/Gateway.d.ts +197 -10
  171. package/dist/gateway/Gateway.d.ts.map +1 -1
  172. package/dist/gateway/Gateway.js +524 -63
  173. package/dist/gateway/Gateway.js.map +1 -1
  174. package/dist/gateway/GatewayConfig.d.ts +78 -0
  175. package/dist/gateway/GatewayConfig.d.ts.map +1 -1
  176. package/dist/gateway/GatewayConfig.js +167 -2
  177. package/dist/gateway/GatewayConfig.js.map +1 -1
  178. package/dist/gateway/GatewayReport.d.ts +31 -1
  179. package/dist/gateway/GatewayReport.d.ts.map +1 -1
  180. package/dist/gateway/GatewayReport.js +12 -0
  181. package/dist/gateway/GatewayReport.js.map +1 -1
  182. package/dist/gateway/InterceptedRequest.d.ts +9 -2
  183. package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
  184. package/dist/gateway/InterceptedRequest.js +41 -9
  185. package/dist/gateway/InterceptedRequest.js.map +1 -1
  186. package/dist/gateway/RateLimit.d.ts +29 -0
  187. package/dist/gateway/RateLimit.d.ts.map +1 -0
  188. package/dist/gateway/RateLimit.js +33 -0
  189. package/dist/gateway/RateLimit.js.map +1 -0
  190. package/dist/gateway/RefusalSampler.d.ts +28 -0
  191. package/dist/gateway/RefusalSampler.d.ts.map +1 -0
  192. package/dist/gateway/RefusalSampler.js +52 -0
  193. package/dist/gateway/RefusalSampler.js.map +1 -0
  194. package/dist/gateway/RouteTable.d.ts +3 -0
  195. package/dist/gateway/RouteTable.d.ts.map +1 -1
  196. package/dist/gateway/RouteTable.js +44 -7
  197. package/dist/gateway/RouteTable.js.map +1 -1
  198. package/dist/gateway/Upstream.d.ts +26 -0
  199. package/dist/gateway/Upstream.d.ts.map +1 -1
  200. package/dist/gateway/Upstream.js +41 -2
  201. package/dist/gateway/Upstream.js.map +1 -1
  202. package/dist/gateway/UpstreamProof.d.ts +235 -0
  203. package/dist/gateway/UpstreamProof.d.ts.map +1 -0
  204. package/dist/gateway/UpstreamProof.js +375 -0
  205. package/dist/gateway/UpstreamProof.js.map +1 -0
  206. package/dist/handlers/ForwardRequestHandler.d.ts +5 -1
  207. package/dist/handlers/ForwardRequestHandler.d.ts.map +1 -1
  208. package/dist/handlers/ForwardRequestHandler.js +12 -2
  209. package/dist/handlers/ForwardRequestHandler.js.map +1 -1
  210. package/dist/hosted/TenantHost.d.ts +180 -0
  211. package/dist/hosted/TenantHost.d.ts.map +1 -0
  212. package/dist/hosted/TenantHost.js +432 -0
  213. package/dist/hosted/TenantHost.js.map +1 -0
  214. package/dist/hosted/TenantRegistry.d.ts +73 -0
  215. package/dist/hosted/TenantRegistry.d.ts.map +1 -0
  216. package/dist/hosted/TenantRegistry.js +123 -0
  217. package/dist/hosted/TenantRegistry.js.map +1 -0
  218. package/dist/http/ExecutorHttpServer.d.ts +7 -0
  219. package/dist/http/ExecutorHttpServer.d.ts.map +1 -1
  220. package/dist/http/ExecutorHttpServer.js +30 -5
  221. package/dist/http/ExecutorHttpServer.js.map +1 -1
  222. package/dist/http/GatewayHttpServer.d.ts +55 -3
  223. package/dist/http/GatewayHttpServer.d.ts.map +1 -1
  224. package/dist/http/GatewayHttpServer.js +157 -17
  225. package/dist/http/GatewayHttpServer.js.map +1 -1
  226. package/dist/http/RedirectServer.d.ts +26 -0
  227. package/dist/http/RedirectServer.d.ts.map +1 -0
  228. package/dist/http/RedirectServer.js +62 -0
  229. package/dist/http/RedirectServer.js.map +1 -0
  230. package/dist/http/Routes.d.ts +17 -0
  231. package/dist/http/Routes.d.ts.map +1 -1
  232. package/dist/http/Routes.js +21 -0
  233. package/dist/http/Routes.js.map +1 -1
  234. package/dist/http/TcpBroker.d.ts +57 -0
  235. package/dist/http/TcpBroker.d.ts.map +1 -0
  236. package/dist/http/TcpBroker.js +299 -0
  237. package/dist/http/TcpBroker.js.map +1 -0
  238. package/dist/http/TcpHostRelay.d.ts +24 -0
  239. package/dist/http/TcpHostRelay.d.ts.map +1 -0
  240. package/dist/http/TcpHostRelay.js +194 -0
  241. package/dist/http/TcpHostRelay.js.map +1 -0
  242. package/dist/http/TcpRelayStreams.d.ts +24 -0
  243. package/dist/http/TcpRelayStreams.d.ts.map +1 -0
  244. package/dist/http/TcpRelayStreams.js +128 -0
  245. package/dist/http/TcpRelayStreams.js.map +1 -0
  246. package/dist/http/TlsListener.d.ts +3 -1
  247. package/dist/http/TlsListener.d.ts.map +1 -1
  248. package/dist/http/TlsListener.js +7 -2
  249. package/dist/http/TlsListener.js.map +1 -1
  250. package/dist/identity/PrincipalsFile.d.ts +3 -1
  251. package/dist/identity/PrincipalsFile.d.ts.map +1 -1
  252. package/dist/identity/PrincipalsFile.js +1 -0
  253. package/dist/identity/PrincipalsFile.js.map +1 -1
  254. package/dist/incident/Metrics.d.ts +2 -0
  255. package/dist/incident/Metrics.d.ts.map +1 -1
  256. package/dist/incident/Metrics.js +10 -0
  257. package/dist/incident/Metrics.js.map +1 -1
  258. package/dist/incident/SecurityEvents.d.ts +89 -0
  259. package/dist/incident/SecurityEvents.d.ts.map +1 -1
  260. package/dist/incident/SecurityEvents.js +93 -2
  261. package/dist/incident/SecurityEvents.js.map +1 -1
  262. package/dist/journal/ExecutionJournal.d.ts +27 -0
  263. package/dist/journal/ExecutionJournal.d.ts.map +1 -1
  264. package/dist/journal/ExecutionJournal.js +28 -0
  265. package/dist/journal/ExecutionJournal.js.map +1 -1
  266. package/dist/journal/FileExecutionJournal.d.ts +2 -1
  267. package/dist/journal/FileExecutionJournal.d.ts.map +1 -1
  268. package/dist/journal/FileExecutionJournal.js +4 -1
  269. package/dist/journal/FileExecutionJournal.js.map +1 -1
  270. package/dist/journal/InMemoryExecutionJournal.d.ts +2 -1
  271. package/dist/journal/InMemoryExecutionJournal.d.ts.map +1 -1
  272. package/dist/journal/InMemoryExecutionJournal.js +4 -1
  273. package/dist/journal/InMemoryExecutionJournal.js.map +1 -1
  274. package/dist/provenance/DockerProvenanceProvider.d.ts +23 -0
  275. package/dist/provenance/DockerProvenanceProvider.d.ts.map +1 -0
  276. package/dist/provenance/DockerProvenanceProvider.js +24 -0
  277. package/dist/provenance/DockerProvenanceProvider.js.map +1 -0
  278. package/dist/provenance/KubernetesProvenanceProvider.d.ts +17 -0
  279. package/dist/provenance/KubernetesProvenanceProvider.d.ts.map +1 -0
  280. package/dist/provenance/KubernetesProvenanceProvider.js +18 -0
  281. package/dist/provenance/KubernetesProvenanceProvider.js.map +1 -0
  282. package/dist/provenance/NoneProvenanceProvider.d.ts +15 -0
  283. package/dist/provenance/NoneProvenanceProvider.d.ts.map +1 -0
  284. package/dist/provenance/NoneProvenanceProvider.js +16 -0
  285. package/dist/provenance/NoneProvenanceProvider.js.map +1 -0
  286. package/dist/provenance/ProvenanceProvider.d.ts +94 -0
  287. package/dist/provenance/ProvenanceProvider.d.ts.map +1 -0
  288. package/dist/provenance/ProvenanceProvider.js +118 -0
  289. package/dist/provenance/ProvenanceProvider.js.map +1 -0
  290. package/dist/provenance/StaticProvenanceProvider.d.ts +18 -0
  291. package/dist/provenance/StaticProvenanceProvider.d.ts.map +1 -0
  292. package/dist/provenance/StaticProvenanceProvider.js +25 -0
  293. package/dist/provenance/StaticProvenanceProvider.js.map +1 -0
  294. package/dist/service/AuthorityClients.d.ts +8 -1
  295. package/dist/service/AuthorityClients.d.ts.map +1 -1
  296. package/dist/service/AuthorityClients.js +33 -5
  297. package/dist/service/AuthorityClients.js.map +1 -1
  298. package/dist/service/EdgeRuntime.d.ts +73 -0
  299. package/dist/service/EdgeRuntime.d.ts.map +1 -0
  300. package/dist/service/EdgeRuntime.js +209 -0
  301. package/dist/service/EdgeRuntime.js.map +1 -0
  302. package/dist/service/EscalationResolver.d.ts +82 -2
  303. package/dist/service/EscalationResolver.d.ts.map +1 -1
  304. package/dist/service/EscalationResolver.js +39 -3
  305. package/dist/service/EscalationResolver.js.map +1 -1
  306. package/dist/service/Requests.d.ts +28 -2
  307. package/dist/service/Requests.d.ts.map +1 -1
  308. package/dist/service/TrustedExecutorService.d.ts +71 -1
  309. package/dist/service/TrustedExecutorService.d.ts.map +1 -1
  310. package/dist/service/TrustedExecutorService.js +461 -27
  311. package/dist/service/TrustedExecutorService.js.map +1 -1
  312. package/dist/tcp/TcpWire.d.ts +18 -0
  313. package/dist/tcp/TcpWire.d.ts.map +1 -0
  314. package/dist/tcp/TcpWire.js +114 -0
  315. package/dist/tcp/TcpWire.js.map +1 -0
  316. package/dist/verify/VerifyAuditChain.d.ts +5 -0
  317. package/dist/verify/VerifyAuditChain.d.ts.map +1 -1
  318. package/dist/verify/VerifyAuditChain.js +20 -4
  319. package/dist/verify/VerifyAuditChain.js.map +1 -1
  320. package/package.json +7 -3
@@ -0,0 +1,209 @@
1
+ import { join } from "node:path";
2
+ import { EdgeBundleManager, EdgeModule, EdgeModuleError, FileBundleSource, LocalGrants, UrlBundleSource, } from "@decionis/agent-safe-pipeline";
3
+ import { EdgeLicence } from "../edge/EdgeLicence.js";
4
+ import { memoryReplay, postgresReplay } from "../edge/EdgeReplay.js";
5
+ import { FileEntitlementSource, UrlEntitlementSource } from "../edge/Entitlement.js";
6
+ import { FileUsageDelivery, UrlUsageDelivery, UsageMeter, } from "../edge/UsageMeter.js";
7
+ import { usageSigningKey } from "../edge/UsageReport.js";
8
+ import { RequestContext } from "../http/RequestContext.js";
9
+ /** How often usage reports are attempted, the entitlement re-read and lapsed claims removed. */
10
+ const TICK_MS = 3_600_000;
11
+ /**
12
+ * The long-lived half of the edge authority: the module, the bundle it holds,
13
+ * the local grants, the replay store, the usage meter and the licence check.
14
+ * It outlives a rebuild of the authority clients, so a rotated Presence
15
+ * credential neither reloads the module nor forgets which intents have run.
16
+ */
17
+ export class EdgeRuntime {
18
+ options;
19
+ module;
20
+ bundles;
21
+ grants;
22
+ replay;
23
+ usage;
24
+ licence;
25
+ onUnavailable;
26
+ clock;
27
+ shared;
28
+ timer = null;
29
+ constructor(options, module, source, key) {
30
+ this.options = options;
31
+ const { config, events } = options;
32
+ const edge = config.edge;
33
+ if (edge === null)
34
+ throw new Error("EDGE_NOT_CONFIGURED");
35
+ this.module = module;
36
+ this.clock = options.clock ?? Date.now;
37
+ this.onUnavailable = edge.onUnavailable;
38
+ this.grants = new LocalGrants(this.clock);
39
+ this.shared =
40
+ edge.replay.store === "memory"
41
+ ? memoryReplay()
42
+ : postgresReplay({
43
+ databaseUrl: () => options.secrets
44
+ .get("EXECUTOR_EDGE_REPLAY_DATABASE_URL")
45
+ .use((value) => value.toString("utf8").trim()),
46
+ namespace: edge.orgId,
47
+ table: edge.replay.table,
48
+ clock: this.clock,
49
+ ...(options.loadPg === undefined ? {} : { load: options.loadPg }),
50
+ });
51
+ this.replay = this.shared.store;
52
+ this.bundles = new EdgeBundleManager({
53
+ module,
54
+ source,
55
+ orgId: edge.orgId,
56
+ refreshSeconds: edge.refreshSeconds,
57
+ clock: this.clock,
58
+ onEvent: (event) => events.emit(event),
59
+ });
60
+ const url = edge.bundle.source === "url";
61
+ const delivery = url
62
+ ? new UrlUsageDelivery({
63
+ baseUrl: config.authority.baseUrl,
64
+ apiKey: options.apiKey,
65
+ fetch: options.fetch,
66
+ })
67
+ : edge.usage.reportDir === null
68
+ ? null
69
+ : new FileUsageDelivery(edge.usage.reportDir);
70
+ this.usage = new UsageMeter({
71
+ orgId: edge.orgId,
72
+ chain: options.chain,
73
+ installationId: edge.usage.installationId,
74
+ stateDir: config.evidence.journalDir === null ? null : join(config.evidence.journalDir, "edge"),
75
+ checkpointLines: config.evidence.checkpointLines,
76
+ events,
77
+ key,
78
+ delivery,
79
+ clock: this.clock,
80
+ });
81
+ this.licence = new EdgeLicence({
82
+ source: url
83
+ ? new UrlEntitlementSource({
84
+ baseUrl: config.authority.baseUrl,
85
+ apiKey: options.apiKey,
86
+ fetch: options.fetch,
87
+ })
88
+ : new FileEntitlementSource(edge.entitlement.file, edge.entitlement.jwksFile),
89
+ meter: this.usage,
90
+ orgId: edge.orgId,
91
+ events,
92
+ clock: this.clock,
93
+ });
94
+ if (key !== null) {
95
+ // The kid an operator registers as a `usage_report` provider key.
96
+ events.emit({
97
+ event: "EDGE_USAGE_KEY_LOADED",
98
+ kid: key().kid,
99
+ installation_id: this.usage.installationId,
100
+ });
101
+ }
102
+ }
103
+ /**
104
+ * The runtime the configuration asks for, or null for a hosted deployment.
105
+ * A module that cannot be read, is not WebAssembly, or is not ABI 3, and a
106
+ * usage-report key that is not an Ed25519 private key, are refusals to
107
+ * start that name the variable and the reason, never a deployment that
108
+ * quietly decides hosted instead.
109
+ */
110
+ static create(options) {
111
+ const edge = options.config.edge;
112
+ if (edge === null)
113
+ return null;
114
+ let module;
115
+ try {
116
+ module = (options.loadModule ?? EdgeModule.fromFile)(edge.wasmPath);
117
+ }
118
+ catch (error) {
119
+ const code = error instanceof EdgeModuleError ? error.code : "EDGE_MODULE_INVALID";
120
+ throw new Error(`CONFIG_INVALID: EXECUTOR_EDGE_WASM_PATH (${code})`);
121
+ }
122
+ let key = null;
123
+ if (edge.usage.signing) {
124
+ // Read at each use, so a rotated key file is followed; checked once here.
125
+ key = () => usageSigningKey(options.secrets
126
+ .get("EXECUTOR_EDGE_USAGE_SIGNING_KEY")
127
+ .use((value) => value.toString("utf8")), edge.usage.keyId);
128
+ try {
129
+ key();
130
+ }
131
+ catch {
132
+ throw new Error("CONFIG_INVALID: EXECUTOR_EDGE_USAGE_SIGNING_KEY (not an Ed25519 key)");
133
+ }
134
+ }
135
+ const source = edge.bundle.source === "file"
136
+ ? new FileBundleSource(edge.bundle.file)
137
+ : new UrlBundleSource({
138
+ baseUrl: options.config.authority.baseUrl,
139
+ apiKey: options.apiKey,
140
+ allowInsecureLoopback: options.config.authority.allowInsecureLoopback,
141
+ fetch: options.fetch,
142
+ });
143
+ return new EdgeRuntime(options, module, source, key);
144
+ }
145
+ /**
146
+ * Links one local decision, or a local attempt's outcome, on the evidence
147
+ * chain. A decision is counted as its line is written, with the sequence
148
+ * and hash that line carries, so the count is the chain's own.
149
+ */
150
+ record(record) {
151
+ // The record holds identifiers, codes and digests only; copied as JSON so
152
+ // the chain links exactly what the line will say.
153
+ const fields = JSON.parse(JSON.stringify(record));
154
+ const at = new Date(this.clock()).toISOString();
155
+ const chain = this.options.chain;
156
+ chain.link({ at, ...fields, caller_principal: RequestContext.current()?.principal ?? null }, (line) => {
157
+ this.options.write(line);
158
+ if (record.event !== "EDGE_DECISION")
159
+ return;
160
+ this.usage.observe({
161
+ at,
162
+ mode: record.mode,
163
+ verdict: record.verdict,
164
+ delegated: record.delegated,
165
+ jti: record.jti,
166
+ seq: chain.head.seq,
167
+ hash: chain.head.hash,
168
+ });
169
+ });
170
+ }
171
+ /**
172
+ * The replay store first: a shared store that cannot be reached is a
173
+ * refusal to start, since nothing could be run once. Then the first
174
+ * bundle fetch, the first usage report and licence check, and the hourly
175
+ * schedule for both and for removing lapsed claims.
176
+ */
177
+ async start() {
178
+ try {
179
+ await this.shared.ready();
180
+ }
181
+ catch (error) {
182
+ const code = error instanceof Error && error.message === "REPLAY_DRIVER_MISSING"
183
+ ? "REPLAY_DRIVER_MISSING"
184
+ : "REPLAY_STORE_UNAVAILABLE";
185
+ throw new Error(`CONFIG_INVALID: EXECUTOR_EDGE_REPLAY_DATABASE_URL (${code})`);
186
+ }
187
+ await this.bundles.start();
188
+ await this.tick();
189
+ this.timer = setInterval(() => void this.tick(), TICK_MS);
190
+ this.timer.unref();
191
+ }
192
+ /** One round of housekeeping. Never throws, and touches no decision. */
193
+ async tick() {
194
+ await this.usage.report();
195
+ await this.licence.check();
196
+ await this.shared.cleanup().catch(() => {
197
+ this.options.events.emit({ event: "EDGE_REPLAY_CLEANUP_FAILED" });
198
+ });
199
+ }
200
+ stop() {
201
+ if (this.timer !== null)
202
+ clearInterval(this.timer);
203
+ this.timer = null;
204
+ this.bundles.stop();
205
+ this.usage.stop();
206
+ void this.shared.close().catch(() => undefined);
207
+ }
208
+ }
209
+ //# sourceMappingURL=EdgeRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EdgeRuntime.js","sourceRoot":"","sources":["../../src/service/EdgeRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,WAAW,EACX,eAAe,GAMhB,MAAM,+BAA+B,CAAC;AAIvC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,cAAc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,OAAO,CAAC,IAAI,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC;CACF"}
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { type AuditRecorder, type CapturedIntent, type DecionisGate, type GateDecision, type PresenceApprovalClient } from "@decionis/agent-safe-pipeline";
2
+ import { type AuditRecorder, type CapturedIntent, type DecionisGate, type DecisionAuthority, type GateDecision, type PresenceApprovalClient } from "@decionis/agent-safe-pipeline";
3
3
  import type { EscalationConfig } from "../config/ExecutorConfig.js";
4
4
  import type { FetchLike } from "../handlers/HandlerRegistration.js";
5
5
  /**
@@ -45,6 +45,67 @@ export declare const EscalationHandoffSchema: z.ZodDiscriminatedUnion<[z.ZodObje
45
45
  }, z.core.$strict>;
46
46
  }, z.core.$strict>], "mode">;
47
47
  export type EscalationHandoff = z.infer<typeof EscalationHandoffSchema>;
48
+ /**
49
+ * A presence provider's attestation presented for an open escalation: the
50
+ * exact intent, and the compact JWS the provider signed over it (a
51
+ * cardholder's tap, for instance). It is evidence for a fresh evaluation,
52
+ * never authority; this process shapes and bounds it, sends it to the
53
+ * authority, which verifies it, and keeps nothing of it.
54
+ */
55
+ export declare const AttestationResumeSchema: z.ZodObject<{
56
+ mode: z.ZodLiteral<"ATTESTATION">;
57
+ intent: z.ZodRecord<z.ZodString, z.ZodUnknown>;
58
+ attestation: z.ZodString;
59
+ }, z.core.$strict>;
60
+ /** What `/v1/escalations` accepts: a handoff it was given, or an attestation for the intent. */
61
+ export declare const EscalationResumeSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z.ZodObject<{
62
+ mode: z.ZodLiteral<"DIRECT">;
63
+ intent: z.ZodRecord<z.ZodString, z.ZodUnknown>;
64
+ request_id: z.ZodString;
65
+ approval_url: z.ZodNullable<z.ZodString>;
66
+ expires_at: z.ZodNullable<z.ZodString>;
67
+ }, z.core.$strict>, z.ZodObject<{
68
+ mode: z.ZodLiteral<"MANAGED">;
69
+ intent: z.ZodRecord<z.ZodString, z.ZodUnknown>;
70
+ escalation: z.ZodObject<{
71
+ escalationId: z.ZodString;
72
+ intentId: z.ZodString;
73
+ status: z.ZodEnum<{
74
+ FAILED: "FAILED";
75
+ PENDING_PRESENCE: "PENDING_PRESENCE";
76
+ PRESENCE_REQUESTED: "PRESENCE_REQUESTED";
77
+ AWAITING_APPROVER: "AWAITING_APPROVER";
78
+ PRESENCE_VERIFIED: "PRESENCE_VERIFIED";
79
+ REAUTHORIZING: "REAUTHORIZING";
80
+ GRANT_READY: "GRANT_READY";
81
+ EXPIRED: "EXPIRED";
82
+ REJECTED: "REJECTED";
83
+ BLOCKED: "BLOCKED";
84
+ CANCELLED: "CANCELLED";
85
+ }>;
86
+ outcome: z.ZodEnum<{
87
+ ALLOW: "ALLOW";
88
+ BLOCK: "BLOCK";
89
+ ESCALATE_PENDING: "ESCALATE_PENDING";
90
+ ERROR: "ERROR";
91
+ }>;
92
+ expiresAt: z.ZodString;
93
+ reasonCodes: z.ZodReadonly<z.ZodArray<z.ZodString>>;
94
+ }, z.core.$strict>;
95
+ }, z.core.$strict>], "mode">, z.ZodObject<{
96
+ mode: z.ZodLiteral<"ATTESTATION">;
97
+ intent: z.ZodRecord<z.ZodString, z.ZodUnknown>;
98
+ attestation: z.ZodString;
99
+ }, z.core.$strict>]>;
100
+ export type EscalationResume = z.infer<typeof EscalationResumeSchema>;
101
+ /**
102
+ * What the caller is handed when an escalation can be resumed with an
103
+ * attestation and nothing else: the exact intent, to present back with it.
104
+ */
105
+ export interface AttestationHandoff {
106
+ readonly mode: "ATTESTATION";
107
+ readonly intent: Record<string, unknown>;
108
+ }
48
109
  type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
49
110
  /** The handoff without the intent: what a mode knows, and what is echoed while pending. */
50
111
  export type EscalationState = DistributiveOmit<EscalationHandoff, "intent">;
@@ -75,11 +136,23 @@ export interface EscalationDependencies {
75
136
  export declare class EscalationResolver {
76
137
  private readonly config;
77
138
  private readonly gate;
139
+ /**
140
+ * What makes the first decision: the gate, unless an edge authority
141
+ * decides in front of it. Resumption is always the gate's: a ceremony's
142
+ * status and the re-evaluation with its receipt are hosted.
143
+ */
144
+ private readonly first;
78
145
  private readonly coordinator;
79
146
  private readonly presence;
80
147
  constructor(config: EscalationConfig, gate: DecionisGate, audit: AuditRecorder, dependencies?: EscalationDependencies,
81
148
  /** The Presence credential for `DIRECT`, read from its handle by the caller for this build. */
82
- presenceApiKey?: string | null);
149
+ presenceApiKey?: string | null,
150
+ /**
151
+ * What makes the first decision: the gate, unless an edge authority
152
+ * decides in front of it. Resumption is always the gate's: a ceremony's
153
+ * status and the re-evaluation with its receipt are hosted.
154
+ */
155
+ first?: DecisionAuthority);
83
156
  get mode(): EscalationConfig["mode"];
84
157
  /** The first evaluation: in managed mode it also asks the authority to orchestrate. */
85
158
  evaluate(captured: CapturedIntent): Promise<GateDecision>;
@@ -88,6 +161,13 @@ export declare class EscalationResolver {
88
161
  * the Presence request, bound to the intent hash the person will see.
89
162
  */
90
163
  handoff(captured: CapturedIntent, decision: GateDecision): Promise<EscalationState | null>;
164
+ /**
165
+ * A fresh evaluation of the same intent with a presence attestation as the
166
+ * approval evidence. Whatever the escalation shape, this asks for no
167
+ * orchestration: the authority verifies the attestation against the
168
+ * intent hash and decides, and a refusal is a fail-closed `BLOCK`.
169
+ */
170
+ attest(captured: CapturedIntent, attestation: string): Promise<GateDecision>;
91
171
  /** One bounded lookup, then either a fresh decision or the state to report. */
92
172
  resume(captured: CapturedIntent, handoff: EscalationHandoff): Promise<EscalationResolution>;
93
173
  private resumeManaged;
@@ -1 +1 @@
1
- {"version":3,"file":"EscalationResolver.d.ts","sourceRoot":"","sources":["../../src/service/EscalationResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC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edUnion("mode", [
42
42
  }),
43
43
  }),
44
44
  ]);
45
+ /**
46
+ * A presence provider's attestation presented for an open escalation: the
47
+ * exact intent, and the compact JWS the provider signed over it (a
48
+ * cardholder's tap, for instance). It is evidence for a fresh evaluation,
49
+ * never authority; this process shapes and bounds it, sends it to the
50
+ * authority, which verifies it, and keeps nothing of it.
51
+ */
52
+ export const AttestationResumeSchema = z.strictObject({
53
+ mode: z.literal("ATTESTATION"),
54
+ intent: z.record(z.string(), z.unknown()),
55
+ attestation: z
56
+ .string()
57
+ .max(20_000)
58
+ .regex(/^[\w-]+\.[\w-]+\.[\w-]+$/),
59
+ });
60
+ /** What `/v1/escalations` accepts: a handoff it was given, or an attestation for the intent. */
61
+ export const EscalationResumeSchema = z.union([EscalationHandoffSchema, AttestationResumeSchema]);
45
62
  /**
46
63
  * Resolves an `ESCALATE` in the shape the adopter configured. Both shapes
47
64
  * are stateless on this side: the handoff the caller presents is validated
@@ -51,13 +68,21 @@ export const EscalationHandoffSchema = z.discriminatedUnion("mode", [
51
68
  export class EscalationResolver {
52
69
  config;
53
70
  gate;
71
+ first;
54
72
  coordinator;
55
73
  presence;
56
74
  constructor(config, gate, audit, dependencies = {},
57
75
  /** The Presence credential for `DIRECT`, read from its handle by the caller for this build. */
58
- presenceApiKey = null) {
76
+ presenceApiKey = null,
77
+ /**
78
+ * What makes the first decision: the gate, unless an edge authority
79
+ * decides in front of it. Resumption is always the gate's: a ceremony's
80
+ * status and the re-evaluation with its receipt are hosted.
81
+ */
82
+ first = gate) {
59
83
  this.config = config;
60
84
  this.gate = gate;
85
+ this.first = first;
61
86
  if (config.mode !== "DIRECT") {
62
87
  this.coordinator = null;
63
88
  this.presence = null;
@@ -81,8 +106,8 @@ export class EscalationResolver {
81
106
  /** The first evaluation: in managed mode it also asks the authority to orchestrate. */
82
107
  async evaluate(captured) {
83
108
  if (this.config.mode !== "MANAGED")
84
- return await this.gate.evaluate(captured);
85
- return await this.gate.evaluate(captured, undefined, {
109
+ return await this.first.evaluate(captured);
110
+ return await this.first.evaluate(captured, undefined, {
86
111
  escalation: {
87
112
  mode: "MANAGED",
88
113
  approver: {
@@ -124,6 +149,17 @@ export class EscalationResolver {
124
149
  expires_at: result.expires_at ?? null,
125
150
  };
126
151
  }
152
+ /**
153
+ * A fresh evaluation of the same intent with a presence attestation as the
154
+ * approval evidence. Whatever the escalation shape, this asks for no
155
+ * orchestration: the authority verifies the attestation against the
156
+ * intent hash and decides, and a refusal is a fail-closed `BLOCK`.
157
+ */
158
+ async attest(captured, attestation) {
159
+ return await this.gate.evaluate(captured, {
160
+ humanApproval: { provider: "attestation", attestation },
161
+ });
162
+ }
127
163
  /** One bounded lookup, then either a fresh decision or the state to report. */
128
164
  async resume(captured, handoff) {
129
165
  if (handoff.mode !== this.config.mode) {
@@ -1 +1 @@
1
- {"version":3,"file":"EscalationResolver.js","sourceRoot":"","sources":["../../src/service/EscalationResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EACL,2BAA2B,GAO5B,MAAM,+BAA+B,CAAC;AAIvC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IAClE,CAAC,CAAC,YAAY,CAAC;QACb,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;QACzB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;QACzC,UAAU,EAAE,UAAU;QACtB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,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C,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,YAAY,EAAE,OAAO,CAAC,YAAY;oBAClC,UAAU,EAAE,OAAO,CAAC,UAAU;iBAC/B;gBACD,WAAW,EAAE,CAAC,yBAAyB,CAAC;aACzC,CAAC;QACJ,CAAC;QACD,0EAA0E;QAC1E,yEAAyE;QACzE,yEAAyE;QACzE,sCAAsC;QACtC,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,MAAM,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAAC,QAAQ,EAAE,OAAO,CAAC;SAC1E,CAAC;IACJ,CAAC;CACF"}
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { type CapturedIntent, type ExecutionRecoveryReference } from "@decionis/agent-safe-pipeline";
3
3
  import type { ExecutorMode } from "../config/ExecutorConfig.js";
4
- import type { EscalationHandoff } from "./EscalationResolver.js";
4
+ import type { AttestationHandoff, EscalationHandoff } from "./EscalationResolver.js";
5
5
  /**
6
6
  * What the caller sends. `proposal` is the agent's part and nothing else:
7
7
  * tenant, actor, downstream target and credentials come from the executor's
@@ -83,7 +83,7 @@ export interface ActionResponse {
83
83
  readonly reference: ExecutionRecoveryReference;
84
84
  } | null;
85
85
  /** Present while an escalation is open: what to present to resume. */
86
- readonly escalation: EscalationHandoff | null;
86
+ readonly escalation: EscalationHandoff | AttestationHandoff | null;
87
87
  }
88
88
  export interface ReconciliationResponse {
89
89
  readonly intent_id: string;
@@ -96,4 +96,30 @@ export interface ReconciliationResponse {
96
96
  readonly result: unknown;
97
97
  readonly effect: Readonly<Record<string, unknown>> | null;
98
98
  }
99
+ /** What the issuer's authorization hook is answered: approve on a held grant, or no match and why. */
100
+ export type CardAuthorizationAnswer = {
101
+ readonly decision: "APPROVE";
102
+ readonly authorization_id: string;
103
+ readonly intent_id: string;
104
+ readonly intent_hash: string;
105
+ readonly decision_id: string;
106
+ readonly dossier_id: string;
107
+ readonly grant_id: string;
108
+ /** Until when a result is recorded as an outcome; after it, as indeterminate. */
109
+ readonly lease_expires_at: string;
110
+ } | {
111
+ readonly decision: "NO_MATCH";
112
+ readonly code: string;
113
+ };
114
+ /** What a recorded authorization result became: the commit outcome and the effect observed. */
115
+ export interface CardResultResponse {
116
+ readonly authorization_id: string;
117
+ readonly intent_id: string;
118
+ readonly intent_hash: string;
119
+ readonly outcome: "COMMITTED" | "FAILED" | "INDETERMINATE";
120
+ readonly executed: boolean | null;
121
+ readonly finalization: "RECORDED" | "PENDING" | "UNSUPPORTED";
122
+ readonly reason_codes: readonly string[];
123
+ readonly effect: Readonly<Record<string, unknown>> | null;
124
+ }
99
125
  //# sourceMappingURL=Requests.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Requests.d.ts","sourceRoot":"","sources":["../../src/service/Requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,0BAA0B,EAChC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAIjE;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;kBAQhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,6FAA6F;AAC7F,eAAO,MAAM,2BAA2B;;;;;;;;;;;kBAWtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;;kBAE5B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;kBAAoB,CAAC;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;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC,GACD;IAAE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,+FAA+F;AAC/F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,QAAQ,GAAG,eAAe,CAAC;IAC3D,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;IAC9D,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAC3D"}
@@ -1,3 +1,4 @@
1
+ import { type EdgeModule } from "@decionis/agent-safe-pipeline";
1
2
  import { HashChain } from "../audit/HashChain.js";
2
3
  import type { LineWriter } from "../audit/LineAuditSink.js";
3
4
  import type { EscalationMode, ExecutorConfig, ExecutorMode } from "../config/ExecutorConfig.js";
@@ -14,7 +15,8 @@ import { type EvidenceBundle } from "../incident/EvidenceExport.js";
14
15
  import type { PostureState } from "../posture/HostPosture.js";
15
16
  import type { ReloadReport, SecretStore } from "../secrets/SecretStore.js";
16
17
  import { type EscalationDependencies } from "./EscalationResolver.js";
17
- import { type ActionResponse, type ReconciliationResponse } from "./Requests.js";
18
+ import { type ActionResponse, type CardAuthorizationAnswer, type CardResultResponse, type ReconciliationResponse } from "./Requests.js";
19
+ import type { LoadPg } from "../edge/EdgeReplay.js";
18
20
  export interface ServiceDependencies extends Omit<EscalationDependencies, "fetch"> {
19
21
  /** Where audit lines go; stdout in the process, an array in the proof. */
20
22
  readonly emit?: LineWriter;
@@ -38,6 +40,10 @@ export interface ServiceDependencies extends Omit<EscalationDependencies, "fetch
38
40
  /** The stop; one is built from the configuration unless a test hands in its own. */
39
41
  readonly halt?: HaltSwitch;
40
42
  readonly clock?: () => number;
43
+ /** Loads the edge evaluator; the configured file unless a test hands in its own. */
44
+ readonly loadEdgeModule?: (path: string) => EdgeModule;
45
+ /** Loads `pg` for the shared replay store; the installed package unless a test hands in its own. */
46
+ readonly loadPg?: LoadPg;
41
47
  }
42
48
  /** What `/v1/control/status` reports: identifiers, counts, and heads, never a value. */
43
49
  export interface ExecutorStatus {
@@ -96,8 +102,16 @@ export declare class TrustedExecutorService {
96
102
  readonly haltSwitch: HaltSwitch;
97
103
  private readonly limits;
98
104
  private readonly unsubscribeMetrics;
105
+ /** The effect observations the verifier finalizes with; the cards family registers into it. */
106
+ private readonly effects;
107
+ /** Card grants held for the issuer's authorization, and the authorizations that claimed one. */
108
+ private readonly cards;
109
+ /** The edge evaluator, when the configuration asks for it. */
110
+ private readonly edge;
99
111
  private readonly hasher;
100
112
  private recovery;
113
+ /** Bound before any await: one authorization id may claim only one request. */
114
+ private readonly cardClaims;
101
115
  private constructor();
102
116
  /**
103
117
  * Wires the boundary. `handlers` is the adopter's seam: it registers what
@@ -112,6 +126,12 @@ export declare class TrustedExecutorService {
112
126
  private static principals;
113
127
  get mode(): ExecutorMode;
114
128
  get escalationMode(): EscalationMode;
129
+ /**
130
+ * Loads the edge evaluator's first bundle and starts its refresh schedule.
131
+ * A first fetch that fails is not a refusal to start: until a bundle
132
+ * loads, decisions follow the configured `onUnavailable`.
133
+ */
134
+ startEdge(): Promise<void>;
115
135
  /** The actions this process can run, for `/ready`. */
116
136
  get actions(): readonly string[];
117
137
  /** Stops following credential rotation and closes every outbound connection; the service answers nothing new after this. */
@@ -148,6 +168,12 @@ export declare class TrustedExecutorService {
148
168
  private assertNotHalted;
149
169
  /** The refusal itself is evidence: the same shape the executor uses for a blocked run. */
150
170
  private recordRefusal;
171
+ /**
172
+ * One spendable hold per card: a purchase on a card that already has one
173
+ * waits until it is authorised or expires, refused before the authority is
174
+ * asked so the refusal costs no dossier and no grant.
175
+ */
176
+ private assertCardSpendable;
151
177
  /** The host's own ceilings, before the authority is asked and again before the run. */
152
178
  private assertWithinLimits;
153
179
  reconcile(input: unknown, caller?: Principal): Promise<ReconciliationResponse>;
@@ -158,6 +184,11 @@ export declare class TrustedExecutorService {
158
184
  * intent past its lifetime is refused before anything is asked.
159
185
  */
160
186
  resume(input: unknown, caller?: Principal): Promise<ActionResponse>;
187
+ /**
188
+ * A fresh decision on a resumed escalation: a card purchase's grant is held
189
+ * for the issuer, anything else runs once on an `ALLOW`.
190
+ */
191
+ private decide;
161
192
  /**
162
193
  * The attempt, on disk, before the executor may run it. A journal that
163
194
  * cannot take the record refuses the proposal rather than executing
@@ -187,6 +218,12 @@ export declare class TrustedExecutorService {
187
218
  * authority is asked, so a mismatch costs no dossier and no grant.
188
219
  */
189
220
  private bindBanking;
221
+ /**
222
+ * The cards binder: the purchase is read and refused here, a card number
223
+ * above all, and the target is derived from the card. What comes back is
224
+ * the expected-effect digest the authority binds its grant to.
225
+ */
226
+ private bindCard;
190
227
  /**
191
228
  * The two digests a banking intent is bound to, taken from the profile's
192
229
  * own arithmetic. This reaches nothing: `prepare` is pure, which is why
@@ -207,6 +244,39 @@ export declare class TrustedExecutorService {
207
244
  private presented;
208
245
  private observe;
209
246
  private enforce;
247
+ /**
248
+ * Admits a card purchase's decision exactly as a run would and holds its
249
+ * grant for the issuer's authorization, keyed by the card. Nothing is
250
+ * claimed and nothing runs; the hard ceilings are committed now, because
251
+ * this is the last moment this process decides anything about the amount.
252
+ * A refusal comes back as the executor's own blocked result.
253
+ */
254
+ private holdCard;
255
+ /**
256
+ * The issuer's real-time authorization hook. The answer has to come back in
257
+ * milliseconds, so the only network call is the claim itself: the match is
258
+ * pure, against a grant decided before the card was presented. A match
259
+ * claims the grant once, and a second authorization for it is a
260
+ * `NO_MATCH`; an issuer retrying the same authorization is given the same
261
+ * answer, with no second claim. What `NO_MATCH` means for the purchase is
262
+ * the issuer's policy, not this process's.
263
+ */
264
+ authorizeCard(input: unknown, caller?: Principal): Promise<CardAuthorizationAnswer>;
265
+ private claimCard;
266
+ /**
267
+ * What the issuer did with an authorization it was told to approve. An
268
+ * approval is the effect, compared with what the grant authorised; a
269
+ * decline is a refusal; and a result after the claim's lease is recorded
270
+ * as indeterminate, because the authority no longer accepts a commit for
271
+ * it. Recorded once.
272
+ */
273
+ settleCard(authorizationId: string, input: unknown, caller?: Principal): Promise<CardResultResponse>;
274
+ /** A card attempt's end, in the journal, so a restart does not ask about it again. */
275
+ private closeCardAttempt;
276
+ private noMatch;
277
+ /** A card request read, or the refusal that names why; a card number is its own refusal. */
278
+ private static cardRequest;
279
+ private static cardView;
210
280
  private response;
211
281
  /** A resumption that produced no new decision: still held, or refused. */
212
282
  private held;