@decionis/agentsafe 0.6.0 → 0.8.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 (288) hide show
  1. package/README.md +68 -20
  2. package/dist/Cli.js +30 -3
  3. package/dist/Cli.js.map +1 -1
  4. package/dist/Index.d.ts +5 -3
  5. package/dist/Index.d.ts.map +1 -1
  6. package/dist/Index.js +3 -1
  7. package/dist/Index.js.map +1 -1
  8. package/dist/TrustedExecutor.d.ts.map +1 -1
  9. package/dist/TrustedExecutor.js +2 -0
  10. package/dist/TrustedExecutor.js.map +1 -1
  11. package/dist/acceptance/AcceptancePlan.d.ts +109 -0
  12. package/dist/acceptance/AcceptancePlan.d.ts.map +1 -0
  13. package/dist/acceptance/AcceptancePlan.js +128 -0
  14. package/dist/acceptance/AcceptancePlan.js.map +1 -0
  15. package/dist/acceptance/AcceptanceReport.d.ts +596 -0
  16. package/dist/acceptance/AcceptanceReport.d.ts.map +1 -0
  17. package/dist/acceptance/AcceptanceReport.js +361 -0
  18. package/dist/acceptance/AcceptanceReport.js.map +1 -0
  19. package/dist/acceptance/AcceptanceRun.d.ts +118 -0
  20. package/dist/acceptance/AcceptanceRun.d.ts.map +1 -0
  21. package/dist/acceptance/AcceptanceRun.js +419 -0
  22. package/dist/acceptance/AcceptanceRun.js.map +1 -0
  23. package/dist/acceptance/Coverage.d.ts +12 -0
  24. package/dist/acceptance/Coverage.d.ts.map +1 -0
  25. package/dist/acceptance/Coverage.js +48 -0
  26. package/dist/acceptance/Coverage.js.map +1 -0
  27. package/dist/acceptance/OutageDoubles.d.ts +34 -0
  28. package/dist/acceptance/OutageDoubles.d.ts.map +1 -0
  29. package/dist/acceptance/OutageDoubles.js +67 -0
  30. package/dist/acceptance/OutageDoubles.js.map +1 -0
  31. package/dist/acceptance/ZoneProbes.d.ts +368 -0
  32. package/dist/acceptance/ZoneProbes.d.ts.map +1 -0
  33. package/dist/acceptance/ZoneProbes.js +488 -0
  34. package/dist/acceptance/ZoneProbes.js.map +1 -0
  35. package/dist/adapters/JcsDigest.d.ts +6 -5
  36. package/dist/adapters/JcsDigest.d.ts.map +1 -1
  37. package/dist/adapters/JcsDigest.js +9 -8
  38. package/dist/adapters/JcsDigest.js.map +1 -1
  39. package/dist/adapters/mcp/McpGuard.d.ts +32 -3
  40. package/dist/adapters/mcp/McpGuard.d.ts.map +1 -1
  41. package/dist/adapters/mcp/McpGuard.js +29 -5
  42. package/dist/adapters/mcp/McpGuard.js.map +1 -1
  43. package/dist/adapters/mcp/McpIntentBinder.d.ts +18 -3
  44. package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -1
  45. package/dist/adapters/mcp/McpIntentBinder.js +48 -1
  46. package/dist/adapters/mcp/McpIntentBinder.js.map +1 -1
  47. package/dist/adapters/mcp/McpInvocation.d.ts +9 -2
  48. package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -1
  49. package/dist/adapters/mcp/McpInvocation.js.map +1 -1
  50. package/dist/cli/Accept.d.ts +9 -0
  51. package/dist/cli/Accept.d.ts.map +1 -0
  52. package/dist/cli/Accept.js +209 -0
  53. package/dist/cli/Accept.js.map +1 -0
  54. package/dist/cli/Actions.d.ts +16 -0
  55. package/dist/cli/Actions.d.ts.map +1 -0
  56. package/dist/cli/Actions.js +194 -0
  57. package/dist/cli/Actions.js.map +1 -0
  58. package/dist/cli/Arguments.d.ts +4 -0
  59. package/dist/cli/Arguments.d.ts.map +1 -1
  60. package/dist/cli/Arguments.js +12 -3
  61. package/dist/cli/Arguments.js.map +1 -1
  62. package/dist/cli/Commands.d.ts +1 -1
  63. package/dist/cli/Commands.d.ts.map +1 -1
  64. package/dist/cli/Commands.js +5 -0
  65. package/dist/cli/Commands.js.map +1 -1
  66. package/dist/cli/ConfigCommand.d.ts.map +1 -1
  67. package/dist/cli/ConfigCommand.js +10 -0
  68. package/dist/cli/ConfigCommand.js.map +1 -1
  69. package/dist/cli/Doctor.d.ts.map +1 -1
  70. package/dist/cli/Doctor.js +67 -1
  71. package/dist/cli/Doctor.js.map +1 -1
  72. package/dist/cli/Help.d.ts.map +1 -1
  73. package/dist/cli/Help.js +18 -1
  74. package/dist/cli/Help.js.map +1 -1
  75. package/dist/cli/Host.d.ts +5 -2
  76. package/dist/cli/Host.d.ts.map +1 -1
  77. package/dist/cli/Host.js +24 -2
  78. package/dist/cli/Host.js.map +1 -1
  79. package/dist/cli/Identity.d.ts +13 -1
  80. package/dist/cli/Identity.d.ts.map +1 -1
  81. package/dist/cli/Identity.js +25 -2
  82. package/dist/cli/Identity.js.map +1 -1
  83. package/dist/cli/Profile.d.ts +24 -0
  84. package/dist/cli/Profile.d.ts.map +1 -0
  85. package/dist/cli/Profile.js +168 -0
  86. package/dist/cli/Profile.js.map +1 -0
  87. package/dist/cli/Records.d.ts +15 -0
  88. package/dist/cli/Records.d.ts.map +1 -0
  89. package/dist/cli/Records.js +205 -0
  90. package/dist/cli/Records.js.map +1 -0
  91. package/dist/cli/Status.d.ts +23 -0
  92. package/dist/cli/Status.d.ts.map +1 -1
  93. package/dist/cli/Status.js +80 -18
  94. package/dist/cli/Status.js.map +1 -1
  95. package/dist/cli/VerifyAcceptance.d.ts +38 -0
  96. package/dist/cli/VerifyAcceptance.d.ts.map +1 -0
  97. package/dist/cli/VerifyAcceptance.js +143 -0
  98. package/dist/cli/VerifyAcceptance.js.map +1 -0
  99. package/dist/config/ConfigKeys.d.ts +2 -2
  100. package/dist/config/ConfigKeys.d.ts.map +1 -1
  101. package/dist/config/ConfigKeys.js +6 -0
  102. package/dist/config/ConfigKeys.js.map +1 -1
  103. package/dist/config/ExecutorConfig.d.ts +35 -1
  104. package/dist/config/ExecutorConfig.d.ts.map +1 -1
  105. package/dist/config/ExecutorConfig.js +53 -1
  106. package/dist/config/ExecutorConfig.js.map +1 -1
  107. package/dist/egress/ZoneHttpClient.d.ts +3 -0
  108. package/dist/egress/ZoneHttpClient.d.ts.map +1 -0
  109. package/dist/egress/ZoneHttpClient.js +72 -0
  110. package/dist/egress/ZoneHttpClient.js.map +1 -0
  111. package/dist/exposure/DecionisExposureLedger.d.ts +44 -0
  112. package/dist/exposure/DecionisExposureLedger.d.ts.map +1 -0
  113. package/dist/exposure/DecionisExposureLedger.js +175 -0
  114. package/dist/exposure/DecionisExposureLedger.js.map +1 -0
  115. package/dist/exposure/ExposureDeclaration.d.ts +68 -0
  116. package/dist/exposure/ExposureDeclaration.d.ts.map +1 -0
  117. package/dist/exposure/ExposureDeclaration.js +83 -0
  118. package/dist/exposure/ExposureDeclaration.js.map +1 -0
  119. package/dist/exposure/ExposureFacts.d.ts +61 -0
  120. package/dist/exposure/ExposureFacts.d.ts.map +1 -0
  121. package/dist/exposure/ExposureFacts.js +201 -0
  122. package/dist/exposure/ExposureFacts.js.map +1 -0
  123. package/dist/exposure/ExposureGate.d.ts +144 -0
  124. package/dist/exposure/ExposureGate.d.ts.map +1 -0
  125. package/dist/exposure/ExposureGate.js +446 -0
  126. package/dist/exposure/ExposureGate.js.map +1 -0
  127. package/dist/exposure/ExposureLedger.d.ts +93 -0
  128. package/dist/exposure/ExposureLedger.d.ts.map +1 -0
  129. package/dist/exposure/ExposureLedger.js +24 -0
  130. package/dist/exposure/ExposureLedger.js.map +1 -0
  131. package/dist/gateway/AttemptStore.d.ts +83 -0
  132. package/dist/gateway/AttemptStore.d.ts.map +1 -0
  133. package/dist/gateway/AttemptStore.js +229 -0
  134. package/dist/gateway/AttemptStore.js.map +1 -0
  135. package/dist/gateway/ForwardHandler.d.ts +50 -6
  136. package/dist/gateway/ForwardHandler.d.ts.map +1 -1
  137. package/dist/gateway/ForwardHandler.js +58 -14
  138. package/dist/gateway/ForwardHandler.js.map +1 -1
  139. package/dist/gateway/Gateway.d.ts +347 -15
  140. package/dist/gateway/Gateway.d.ts.map +1 -1
  141. package/dist/gateway/Gateway.js +1524 -63
  142. package/dist/gateway/Gateway.js.map +1 -1
  143. package/dist/gateway/GatewayConfig.d.ts +295 -0
  144. package/dist/gateway/GatewayConfig.d.ts.map +1 -1
  145. package/dist/gateway/GatewayConfig.js +485 -13
  146. package/dist/gateway/GatewayConfig.js.map +1 -1
  147. package/dist/gateway/GatewayManifest.d.ts +18 -0
  148. package/dist/gateway/GatewayManifest.d.ts.map +1 -0
  149. package/dist/gateway/GatewayManifest.js +42 -0
  150. package/dist/gateway/GatewayManifest.js.map +1 -0
  151. package/dist/gateway/GatewayMetrics.d.ts +12 -4
  152. package/dist/gateway/GatewayMetrics.d.ts.map +1 -1
  153. package/dist/gateway/GatewayMetrics.js +5 -0
  154. package/dist/gateway/GatewayMetrics.js.map +1 -1
  155. package/dist/gateway/GatewayReport.d.ts +39 -2
  156. package/dist/gateway/GatewayReport.d.ts.map +1 -1
  157. package/dist/gateway/GatewayReport.js +14 -0
  158. package/dist/gateway/GatewayReport.js.map +1 -1
  159. package/dist/gateway/HoldStore.d.ts +89 -0
  160. package/dist/gateway/HoldStore.d.ts.map +1 -0
  161. package/dist/gateway/HoldStore.js +280 -0
  162. package/dist/gateway/HoldStore.js.map +1 -0
  163. package/dist/gateway/InterceptedRequest.d.ts +55 -1
  164. package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
  165. package/dist/gateway/InterceptedRequest.js +63 -1
  166. package/dist/gateway/InterceptedRequest.js.map +1 -1
  167. package/dist/gateway/PolicySelector.d.ts +5 -0
  168. package/dist/gateway/PolicySelector.d.ts.map +1 -0
  169. package/dist/gateway/PolicySelector.js +9 -0
  170. package/dist/gateway/PolicySelector.js.map +1 -0
  171. package/dist/gateway/RouteTable.d.ts +72 -7
  172. package/dist/gateway/RouteTable.d.ts.map +1 -1
  173. package/dist/gateway/RouteTable.js +133 -9
  174. package/dist/gateway/RouteTable.js.map +1 -1
  175. package/dist/gateway/ShadowLedger.d.ts +11 -0
  176. package/dist/gateway/ShadowLedger.d.ts.map +1 -1
  177. package/dist/gateway/ShadowLedger.js +11 -0
  178. package/dist/gateway/ShadowLedger.js.map +1 -1
  179. package/dist/gateway/SubjectSessions.d.ts +113 -0
  180. package/dist/gateway/SubjectSessions.d.ts.map +1 -0
  181. package/dist/gateway/SubjectSessions.js +219 -0
  182. package/dist/gateway/SubjectSessions.js.map +1 -0
  183. package/dist/gateway/TargetEffect.d.ts +74 -0
  184. package/dist/gateway/TargetEffect.d.ts.map +1 -0
  185. package/dist/gateway/TargetEffect.js +95 -0
  186. package/dist/gateway/TargetEffect.js.map +1 -0
  187. package/dist/gateway/TargetReader.d.ts +70 -0
  188. package/dist/gateway/TargetReader.d.ts.map +1 -0
  189. package/dist/gateway/TargetReader.js +106 -0
  190. package/dist/gateway/TargetReader.js.map +1 -0
  191. package/dist/gateway/Upstream.d.ts +26 -0
  192. package/dist/gateway/Upstream.d.ts.map +1 -1
  193. package/dist/gateway/Upstream.js +42 -3
  194. package/dist/gateway/Upstream.js.map +1 -1
  195. package/dist/hosted/TenantHost.d.ts +26 -6
  196. package/dist/hosted/TenantHost.d.ts.map +1 -1
  197. package/dist/hosted/TenantHost.js +45 -10
  198. package/dist/hosted/TenantHost.js.map +1 -1
  199. package/dist/hosted/TenantRegistry.d.ts +28 -0
  200. package/dist/hosted/TenantRegistry.d.ts.map +1 -1
  201. package/dist/hosted/TenantRegistry.js +60 -1
  202. package/dist/hosted/TenantRegistry.js.map +1 -1
  203. package/dist/http/GatewayHttpServer.d.ts +7 -0
  204. package/dist/http/GatewayHttpServer.d.ts.map +1 -1
  205. package/dist/http/GatewayHttpServer.js +103 -3
  206. package/dist/http/GatewayHttpServer.js.map +1 -1
  207. package/dist/identity/WorkloadJwtVerifier.d.ts +13 -0
  208. package/dist/identity/WorkloadJwtVerifier.d.ts.map +1 -1
  209. package/dist/identity/WorkloadJwtVerifier.js +40 -8
  210. package/dist/identity/WorkloadJwtVerifier.js.map +1 -1
  211. package/dist/incident/HaltSwitch.d.ts +10 -2
  212. package/dist/incident/HaltSwitch.d.ts.map +1 -1
  213. package/dist/incident/HaltSwitch.js +22 -2
  214. package/dist/incident/HaltSwitch.js.map +1 -1
  215. package/dist/incident/SecurityEvents.d.ts +18 -0
  216. package/dist/incident/SecurityEvents.d.ts.map +1 -1
  217. package/dist/incident/SecurityEvents.js +17 -0
  218. package/dist/incident/SecurityEvents.js.map +1 -1
  219. package/dist/limits/HardLimits.d.ts.map +1 -1
  220. package/dist/limits/HardLimits.js.map +1 -1
  221. package/dist/outcomes/CardOutcomeEvidence.d.ts +56 -0
  222. package/dist/outcomes/CardOutcomeEvidence.d.ts.map +1 -0
  223. package/dist/outcomes/CardOutcomeEvidence.js +211 -0
  224. package/dist/outcomes/CardOutcomeEvidence.js.map +1 -0
  225. package/dist/outcomes/CardOutcomeFact.d.ts +90 -0
  226. package/dist/outcomes/CardOutcomeFact.d.ts.map +1 -0
  227. package/dist/outcomes/CardOutcomeFact.js +76 -0
  228. package/dist/outcomes/CardOutcomeFact.js.map +1 -0
  229. package/dist/outcomes/CardOutcomeLedger.d.ts +26 -0
  230. package/dist/outcomes/CardOutcomeLedger.d.ts.map +1 -0
  231. package/dist/outcomes/CardOutcomeLedger.js +31 -0
  232. package/dist/outcomes/CardOutcomeLedger.js.map +1 -0
  233. package/dist/outcomes/CardOutcomeRecorder.d.ts +35 -0
  234. package/dist/outcomes/CardOutcomeRecorder.d.ts.map +1 -0
  235. package/dist/outcomes/CardOutcomeRecorder.js +84 -0
  236. package/dist/outcomes/CardOutcomeRecorder.js.map +1 -0
  237. package/dist/outcomes/CardOutcomes.d.ts +68 -0
  238. package/dist/outcomes/CardOutcomes.d.ts.map +1 -0
  239. package/dist/outcomes/CardOutcomes.js +191 -0
  240. package/dist/outcomes/CardOutcomes.js.map +1 -0
  241. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts +54 -0
  242. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts.map +1 -0
  243. package/dist/outcomes/CoreOutcomeEvidenceClient.js +116 -0
  244. package/dist/outcomes/CoreOutcomeEvidenceClient.js.map +1 -0
  245. package/dist/outcomes/FileCardOutcomeLedger.d.ts +36 -0
  246. package/dist/outcomes/FileCardOutcomeLedger.d.ts.map +1 -0
  247. package/dist/outcomes/FileCardOutcomeLedger.js +152 -0
  248. package/dist/outcomes/FileCardOutcomeLedger.js.map +1 -0
  249. package/dist/outcomes/OutcomeEvidence.d.ts +238 -0
  250. package/dist/outcomes/OutcomeEvidence.d.ts.map +1 -0
  251. package/dist/outcomes/OutcomeEvidence.js +130 -0
  252. package/dist/outcomes/OutcomeEvidence.js.map +1 -0
  253. package/dist/outcomes/OutcomeEvidencePublisher.d.ts +81 -0
  254. package/dist/outcomes/OutcomeEvidencePublisher.d.ts.map +1 -0
  255. package/dist/outcomes/OutcomeEvidencePublisher.js +189 -0
  256. package/dist/outcomes/OutcomeEvidencePublisher.js.map +1 -0
  257. package/dist/outcomes/OutcomeEvidenceStore.d.ts +57 -0
  258. package/dist/outcomes/OutcomeEvidenceStore.d.ts.map +1 -0
  259. package/dist/outcomes/OutcomeEvidenceStore.js +191 -0
  260. package/dist/outcomes/OutcomeEvidenceStore.js.map +1 -0
  261. package/dist/posture/ActionSpaceDrift.d.ts +40 -0
  262. package/dist/posture/ActionSpaceDrift.d.ts.map +1 -0
  263. package/dist/posture/ActionSpaceDrift.js +67 -0
  264. package/dist/posture/ActionSpaceDrift.js.map +1 -0
  265. package/dist/posture/DeploymentFingerprint.d.ts +88 -0
  266. package/dist/posture/DeploymentFingerprint.d.ts.map +1 -0
  267. package/dist/posture/DeploymentFingerprint.js +78 -0
  268. package/dist/posture/DeploymentFingerprint.js.map +1 -0
  269. package/dist/secrets/SecretStore.d.ts +6 -1
  270. package/dist/secrets/SecretStore.d.ts.map +1 -1
  271. package/dist/secrets/SecretStore.js.map +1 -1
  272. package/dist/service/EscalationResolver.d.ts +6 -6
  273. package/dist/service/EscalationResolver.d.ts.map +1 -1
  274. package/dist/service/EscalationResolver.js +8 -4
  275. package/dist/service/EscalationResolver.js.map +1 -1
  276. package/dist/service/Requests.d.ts +6 -0
  277. package/dist/service/Requests.d.ts.map +1 -1
  278. package/dist/service/Requests.js +9 -1
  279. package/dist/service/Requests.js.map +1 -1
  280. package/dist/service/TrustedExecutorService.d.ts +21 -1
  281. package/dist/service/TrustedExecutorService.d.ts.map +1 -1
  282. package/dist/service/TrustedExecutorService.js +54 -13
  283. package/dist/service/TrustedExecutorService.js.map +1 -1
  284. package/dist/verify/VerifyingProvider.d.ts +32 -6
  285. package/dist/verify/VerifyingProvider.d.ts.map +1 -1
  286. package/dist/verify/VerifyingProvider.js +16 -2
  287. package/dist/verify/VerifyingProvider.js.map +1 -1
  288. package/package.json +7 -6
@@ -1,16 +1,37 @@
1
1
  import { z } from "zod";
2
- import { JsonValueSchema, PreDispatchRefusal, ProviderRefusal, } from "@decionis/agent-safe-pipeline";
2
+ import { JsonValueSchema, preconditionOf, PreDispatchRefusal, ProviderRefusal, } from "@decionis/agent-safe-pipeline";
3
3
  import { EFFECT_RECEIPT_HEADER } from "../verify/EffectReceipt.js";
4
4
  import { dispatchBudgetMs, MonotonicDeadline } from "../time/MonotonicClock.js";
5
5
  import { CONSEQUENTIAL_METHODS } from "./GatewayConfig.js";
6
- import { bodyDigest, requestDigest, } from "./InterceptedRequest.js";
6
+ import { PolicyIdSchema, PolicyVersionSchema } from "./PolicySelector.js";
7
+ import { bodyDigest, keyedRequestDigest, requestDigest, } from "./InterceptedRequest.js";
7
8
  /** The parameters an HTTP action carries; anything else the registry refuses before a grant is spent. */
8
9
  export const HttpActionParametersSchema = z.strictObject({
9
10
  method: z.enum(CONSEQUENTIAL_METHODS),
10
11
  path: z.string().min(1).max(500),
11
12
  query: z.record(z.string(), z.union([z.string(), z.array(z.string())])),
12
13
  body: JsonValueSchema.optional(),
14
+ policy_id: PolicyIdSchema.optional(),
15
+ policy_version: PolicyVersionSchema.optional(),
13
16
  });
17
+ /** A facts-only HTTP action's parameters: the profile operation and its template, nothing more. */
18
+ export const HttpFactsParametersSchema = z.strictObject({
19
+ method: z.enum(CONSEQUENTIAL_METHODS),
20
+ operation: z.string().min(1).max(120),
21
+ path_template: z.string().min(1).max(500),
22
+ });
23
+ /** What the registry admits an HTTP action's parameters against: either shape, nothing else. */
24
+ export const HttpParametersSchema = z.union([
25
+ HttpActionParametersSchema,
26
+ HttpFactsParametersSchema,
27
+ ]);
28
+ /**
29
+ * The header a write carries the target version its intent bound in, as a
30
+ * verifying hop sets it after checking an attestation: an upstream that takes
31
+ * writes only through the gateway's credential, and honours it, refuses a
32
+ * write whose target has moved since the decision.
33
+ */
34
+ export const EXPECTED_STATE_VERSION_HEADER = "x-agent-safe-expected-state-version";
14
35
  /** Thrown after dispatch when the upstream answered with a server error: the effect is unknown. */
15
36
  class UpstreamIndeterminate extends Error {
16
37
  constructor() {
@@ -25,8 +46,14 @@ class UpstreamIndeterminate extends Error {
25
46
  */
26
47
  export class RequestHolder {
27
48
  held = new Map();
28
- hold(intentId, request, extraHeaders) {
29
- this.held.set(intentId, { request, extraHeaders, outcome: { response: null, failure: null } });
49
+ hold(intentId, request, extraHeaders, landed = null, before = null) {
50
+ this.held.set(intentId, {
51
+ request,
52
+ extraHeaders,
53
+ landed,
54
+ before,
55
+ outcome: { response: null, failure: null },
56
+ });
30
57
  }
31
58
  /** @internal */
32
59
  get(intentId) {
@@ -48,38 +75,50 @@ export class RequestHolder {
48
75
  * changed between the two is a failure before dispatch, not an execution.
49
76
  * The upstream's status is the attempt's outcome: `2xx` and `3xx` commit,
50
77
  * `4xx` is the provider's own refusal, `5xx` and a lost connection are
51
- * unknown.
78
+ * unknown. A facts-only intent carries no path to compare: the held request
79
+ * is bound by its keyed digest instead, which covers the same bytes. When
80
+ * the intent bound its target's version, the write says so to the upstream,
81
+ * and a `2xx` is handed to whoever held the request before the runner
82
+ * finalizes the attempt.
52
83
  */
53
- export function httpForwardHandler(upstream, holder) {
84
+ export function httpForwardHandler(upstream, holder, digestKey) {
54
85
  return {
55
- parametersSchema: HttpActionParametersSchema,
86
+ parametersSchema: HttpParametersSchema,
56
87
  execute: async ({ intent, parameters, authorization, dispatch }) => {
57
88
  const held = holder.get(intent.intent.intentId);
58
89
  if (held === undefined)
59
90
  throw new Error("REQUEST_NOT_HELD");
60
91
  const request = held.request;
61
92
  const context = intent.intent.context;
62
- if (request.method.toUpperCase() !== parameters.method ||
63
- request.path !== parameters.path ||
64
- context["request_sha256"] !== requestDigest(request) ||
65
- context["body_bytes"] !== request.body.length ||
66
- context["body_sha256"] !== bodyDigest(request.body)) {
93
+ const bound = "operation" in parameters
94
+ ? context["request_hmac_sha256"] === keyedRequestDigest(request, digestKey)
95
+ : request.path === parameters.path &&
96
+ context["request_sha256"] === requestDigest(request) &&
97
+ context["body_bytes"] === request.body.length &&
98
+ context["body_sha256"] === bodyDigest(request.body);
99
+ if (request.method.toUpperCase() !== parameters.method || !bound) {
67
100
  throw new PreDispatchRefusal("PAYLOAD_BINDING_MISMATCH");
68
101
  }
102
+ // The gateway's own last check runs on the bytes just verified, and
103
+ // before the dispatch budget is taken, so its time is not the upstream's.
104
+ if (held.before !== null)
105
+ await held.before(authorization);
106
+ const precondition = preconditionOf(context);
69
107
  const headers = upstream.headersFor(request, {
70
108
  ...held.extraHeaders,
71
109
  "x-agent-safe-intent-hash": intent.intentHash,
72
110
  "x-agent-safe-decision-id": authorization.decisionId,
73
111
  "x-agent-safe-dossier-id": authorization.dossierId,
112
+ ...(precondition === null ? {} : { [EXPECTED_STATE_VERSION_HEADER]: precondition.version }),
74
113
  });
75
114
  // The upstream is never given more time than the authorization has
76
115
  // left, and the budget is monotonic, so a clock change cannot extend it.
77
116
  const deadline = MonotonicDeadline.after(dispatchBudgetMs(upstream.timeoutMs, authorization));
78
- return await dispatch.run(async () => {
117
+ const answered = await dispatch.run(async () => {
79
118
  // Everything after this line is the point of no return.
80
119
  let response;
81
120
  try {
82
- response = await upstream.send(parameters.method, parameters.path, request.search, headers, request.body, upstream.signal(deadline.remainingMs));
121
+ response = await upstream.send(parameters.method, request.path, request.search, headers, request.body, upstream.signal(deadline.remainingMs));
83
122
  }
84
123
  catch (error) {
85
124
  held.outcome = {
@@ -110,6 +149,11 @@ export function httpForwardHandler(upstream, holder) {
110
149
  held.outcome = { response, failure: null };
111
150
  return response;
112
151
  });
152
+ // Past the point of no return: what follows observes the write, and
153
+ // can change neither its outcome nor whether it happened.
154
+ if (answered.status < 300)
155
+ await held.landed?.(authorization);
156
+ return answered;
113
157
  },
114
158
  };
115
159
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ForwardHandler.js","sourceRoot":"","sources":["../../src/gateway/ForwardHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,eAAe,GAGhB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EACL,UAAU,EACV,aAAa,GAGd,MAAM,yBAAyB,CAAC;AAGjC,yGAAyG;AACzG,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,YAAY,CAAC;IACvD,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,qBAAqB,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;IACvE,IAAI,EAAE,eAAe,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC;AAUH,mGAAmG;AACnG,MAAM,qBAAsB,SAAQ,KAAK;IACvC;QACE,KAAK,CA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C;YAClB,CAAC,CAAC,CAAC;YACH,oEAAoE;YACpE,0DAA0D;YAC1D,IAAI,QAAQ,CAAC,MAAM,GAAG,GAAG;gBAAE,MAAM,IAAI,CAAC,MAAM,EAAE,CAAC,aAAa,CAAC,CAAC;YAC9D,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,mBAAmB,CACjC,QAAwB,EACxB,OAA0B,EAC1B,OAAsD;IAEtD,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC"}
@@ -1,10 +1,15 @@
1
1
  import { type WorkloadSignal } from "@decionis/agent-safe-pipeline";
2
2
  import { type EnforcementBoundary } from "../boundary/BoundaryIdentity.js";
3
3
  import { type ProvenanceProvider } from "../provenance/ProvenanceProvider.js";
4
+ import { type AcceptanceSigningKey } from "../acceptance/AcceptanceReport.js";
5
+ import { type Admission, type RunAnswer } from "../acceptance/AcceptanceRun.js";
4
6
  import { HashChain } from "../audit/HashChain.js";
7
+ import type { ExposureLedger } from "../exposure/ExposureLedger.js";
5
8
  import { type AddressResolver } from "../egress/GuardedFetch.js";
6
9
  import type { FetchLike } from "../handlers/HandlerRegistration.js";
7
- import type { SecretStore } from "../secrets/SecretStore.js";
10
+ import { type SecretStore } from "../secrets/SecretStore.js";
11
+ import { type ActionSpaceStatus } from "../posture/ActionSpaceDrift.js";
12
+ import { type DeploymentFingerprint, type DeploymentFingerprintDocument } from "../posture/DeploymentFingerprint.js";
8
13
  import { ActivationFunnel, type ActivationMilestone } from "./Activation.js";
9
14
  import { type DemoAuthorityHandle } from "./DemoAuthority.js";
10
15
  import { type GatewayConfig } from "./GatewayConfig.js";
@@ -49,6 +54,8 @@ export interface GatewayDependencies {
49
54
  readonly upstreamResolve?: AddressResolver;
50
55
  /** TXT lookup for the upstream's proof; the system resolver's when absent. */
51
56
  readonly upstreamResolveTxt?: TxtResolver;
57
+ /** The transport under the guard for the identity provider's key set; `node:https` when absent. */
58
+ readonly subjectJwksFetch?: FetchLike;
52
59
  readonly secrets?: SecretStore;
53
60
  readonly demoAuthority?: () => Promise<DemoAuthorityHandle>;
54
61
  readonly clock?: () => number;
@@ -75,6 +82,12 @@ export interface GatewayDependencies {
75
82
  * stands then.
76
83
  */
77
84
  readonly continues?: GatewayContinuation;
85
+ /**
86
+ * The exposure ledger a route that releases money reserves against; the
87
+ * Decionis ledger, through the authority's egress and key, when absent.
88
+ * Asked only when a route declares `exposure`.
89
+ */
90
+ readonly exposureLedger?: ExposureLedger;
78
91
  }
79
92
  /**
80
93
  * A gateway's chains and adoption funnel, handed to the gateway built to
@@ -86,6 +99,8 @@ export interface GatewayContinuation {
86
99
  readonly gateway: HashChain;
87
100
  readonly security: HashChain;
88
101
  readonly activation: ActivationFunnel;
102
+ /** The replaced gateway's fingerprint digest: the replacement records its own only when it differs. */
103
+ readonly fingerprint?: string;
89
104
  }
90
105
  /** Where a hosted gateway's configuration came from, when a host built it from a tenant registry. */
91
106
  export interface RegistrySource {
@@ -115,6 +130,18 @@ export interface GatewayStatus {
115
130
  readonly surface: InstallSurface | null;
116
131
  /** In shadow, what the authority would have decided so far, by verdict and action; null in enforcement. */
117
132
  readonly shadow: ShadowSummary | null;
133
+ /** What this gateway is (`agent-safe.deployment-fingerprint/1`) and its digest; absent from an older gateway. */
134
+ readonly fingerprint?: {
135
+ readonly digest: string;
136
+ readonly document: DeploymentFingerprintDocument;
137
+ };
138
+ /** The action space it loaded against the one the deciding release was checked against; absent from an older gateway. */
139
+ readonly action_space?: ActionSpaceStatus;
140
+ /** The key acceptance reports are signed with, when the gateway serves runs; null when it does not; absent from an older gateway. */
141
+ readonly acceptance?: {
142
+ readonly kid: string;
143
+ readonly public_jwk: AcceptanceSigningKey["publicJwk"];
144
+ } | null;
118
145
  /**
119
146
  * A hosted gateway's tenant, the tenant keys it admits now, each as a
120
147
  * short prefix of its digest and never the digest, and the registry it was
@@ -127,10 +154,20 @@ export interface GatewayStatus {
127
154
  readonly registry: RegistrySource | null;
128
155
  /** Where the upstream's proof stands, when the gateway requires one; never its text. */
129
156
  readonly upstream_proof: ProofSnapshot | null;
157
+ /** Whether this gateway is the only one its process serves, as an enforcing one must be. */
158
+ readonly dedicated: boolean;
159
+ /** The header the gateway presents its upstream credential in; never the value. */
160
+ readonly upstream_credential: {
161
+ readonly header: string;
162
+ } | null;
163
+ /** Whether the gateway sends its upstream a gateway token; never the token. */
164
+ readonly gateway_token: boolean;
130
165
  } | null;
131
166
  }
132
167
  /** How much of a `sha256:` digest a readback shows: enough to tell two apart, never the digest. */
133
168
  export declare function shortDigest(digest: string): string;
169
+ /** The response header that names the dossier of the INDETERMINATE attempt a request retries. */
170
+ export declare const RETRY_OF_HEADER = "agentsafe-retry-of";
134
171
  /** Why a caller cannot see or resume a hold: nothing is held, or the token is not the holder's. */
135
172
  type HoldRefusal = "ESCALATION_NOT_HELD" | "RESUME_TOKEN_INVALID";
136
173
  /** Why a tenant key refuses a request: none was presented, or not one of the tenant's. */
@@ -140,15 +177,6 @@ export type TenantKeyRefusal = "TENANT_KEY_MISSING" | "TENANT_KEY_INVALID";
140
177
  * are what proxies, access logs and this gateway's own report write down.
141
178
  */
142
179
  export declare const RESUME_TOKEN_HEADER = "agentsafe-resume-token";
143
- /**
144
- * The HTTP-interception ingress over the unchanged lifecycle. A request the
145
- * route table calls consequential becomes a captured intent; the authority
146
- * decides; on `ALLOW` the executor claims the grant and the forwarding
147
- * handler sends the exact bytes the intent bound; the outcome is finalized
148
- * and every step is chained evidence. In shadow the request goes through
149
- * unchanged while the authority is asked what it would have decided.
150
- * Nothing here decides ALLOW, BLOCK or ESCALATE; it asks, enforces and records.
151
- */
152
180
  export declare class Gateway {
153
181
  readonly config: GatewayConfig;
154
182
  private readonly upstream;
@@ -167,8 +195,43 @@ export declare class Gateway {
167
195
  readonly boundary: EnforcementBoundary;
168
196
  readonly workload: WorkloadSignal | null;
169
197
  private readonly proof;
170
- private readonly held;
198
+ private readonly sessions;
199
+ private readonly jwks;
200
+ private readonly effects;
201
+ /** The digest of the gateway this one replaces, when it replaces one. */
202
+ private readonly replaced;
203
+ private readonly acceptance;
204
+ /** The requests held for a person's decision: in memory, or in a directory every replica shares. */
205
+ private readonly holds;
206
+ /** The INDETERMINATE attempts a retry with the same idempotency key is linked to: kept where the holds are. */
207
+ private readonly attempts;
208
+ /**
209
+ * For each governed request whose operation names where the subject sits
210
+ * in its answer: the session and operation the answer is checked against,
211
+ * wherever it is relayed (enforced, observed in shadow, forwarded failing
212
+ * open, or after a resumed escalation, which holds the same request).
213
+ */
214
+ private readonly answerScopes;
171
215
  private readonly holder;
216
+ /**
217
+ * What the gateway read of each captured write's target before the
218
+ * authority was asked, for the reads after it: once the write lands, or
219
+ * once it is refused. Keyed by the captured intent, which a held
220
+ * escalation keeps, so a resumed write is read back too.
221
+ */
222
+ private readonly plans;
223
+ /** The reads after a refusal still waiting for their window; the stop waits for them. */
224
+ private readonly observing;
225
+ /** A profiled write's target reads, in enforcement only; null otherwise. */
226
+ private readonly reader;
227
+ /**
228
+ * The key of the facts-only request digest, so the digest an authority
229
+ * receives confirms nothing about the request to anyone without it:
230
+ * derived from the tenant's key in custody (`interception.digestKeyFile`),
231
+ * the same on every replica; otherwise made here and held only here, so a
232
+ * held escalation is resumed by this same gateway.
233
+ */
234
+ private readonly digestKey;
172
235
  private readonly capture;
173
236
  private readonly executor;
174
237
  private readonly shadow;
@@ -184,7 +247,24 @@ export declare class Gateway {
184
247
  /** The tenant keys admitted now: the configuration's, until a host replaces them in place. */
185
248
  private admitted;
186
249
  private registry;
250
+ /** What this gateway is: computed once, since nothing it is built from changes while it runs. */
251
+ readonly fingerprint: DeploymentFingerprint;
252
+ private readonly actionSpace;
253
+ /** Acceptance runs, when the configuration names their key and token; null otherwise. */
254
+ private readonly runs;
255
+ /** The plan write each request a run sent is, by request. */
256
+ private readonly acceptanceWrites;
257
+ /** The cumulative-limit check, when a route releases money; null otherwise. */
258
+ private readonly exposure;
187
259
  private constructor();
260
+ /**
261
+ * The facts-only digest key: derived from the custody file for this
262
+ * tenant (HKDF-SHA-256, the tenant as salt), so every replica that mounts
263
+ * the file derives the same key and no other use of the file's key shares
264
+ * it; 32 random bytes of this process's own without one. The file's
265
+ * contents are never logged: a refusal names the setting only.
266
+ */
267
+ private static digestKeyOf;
188
268
  /**
189
269
  * Assembles the gateway: the secrets it needs opened, the demo authority
190
270
  * started when chosen, the guarded egress sealed to the authority, the
@@ -198,6 +278,13 @@ export declare class Gateway {
198
278
  * this one replaces (`takeOver`).
199
279
  */
200
280
  private static upstreamProof;
281
+ /**
282
+ * The identity provider's key set, when the gateway pins subjects: the file
283
+ * when there is one, else one fetch from the address at start, refused by
284
+ * name when it fails; refreshed from the address through the guarded
285
+ * egress, sealed to its origin, with the last good set kept on a failure.
286
+ */
287
+ private static subjectKeys;
201
288
  /** TXT through the system's resolver, bounded, so a check never waits on DNS for long. */
202
289
  private static systemTxt;
203
290
  get authorityLabel(): string;
@@ -213,7 +300,9 @@ export declare class Gateway {
213
300
  * and once a day has passed since the last report.
214
301
  */
215
302
  private shadowReportOnCadence;
216
- plan(method: string, path: string): RoutePlan;
303
+ plan(method: string, path: string, search?: string): RoutePlan;
304
+ /** A query for planning only; a name the intent contract forbids is left out, and refused later. */
305
+ private static queryOf;
217
306
  readiness(): {
218
307
  readonly ready: boolean;
219
308
  readonly body: Record<string, unknown>;
@@ -280,8 +369,40 @@ export declare class Gateway {
280
369
  * that came through the gateway from one that never reached it.
281
370
  */
282
371
  passthrough(request: InterceptedRequest): Promise<GatewayResponse>;
283
- /** A consequential request, through the whole lifecycle. */
372
+ /**
373
+ * A consequential request, through the whole lifecycle. When the gateway
374
+ * pins subjects, a session the request presents is resolved first: one
375
+ * that does not stand is refused before anything else, and the subject of
376
+ * one that does is stated to the authority as `session.subject`, so a
377
+ * write's policy can compare a fact with it.
378
+ */
284
379
  govern(request: InterceptedRequest, action: string): Promise<GatewayResponse>;
380
+ /**
381
+ * Where an enforced request stands among its idempotency key's attempts:
382
+ * null without a key, or in shadow, which forwards every request as it
383
+ * came and so links none.
384
+ */
385
+ private retryLink;
386
+ /**
387
+ * The same idempotency key with another request, while the key's last
388
+ * attempt is INDETERMINATE: the key promised one operation, which may
389
+ * already have happened, so this one is refused and never forwarded.
390
+ */
391
+ private keyReused;
392
+ /**
393
+ * The reservation key of the INDETERMINATE attempt this request retries:
394
+ * the same idempotency key and the same request, so the same payment.
395
+ * Undefined when it retries none, or none that reserved.
396
+ */
397
+ private retriedReservation;
398
+ /**
399
+ * After an enforced execution, what its idempotency key remembers: an
400
+ * INDETERMINATE attempt is recorded for a retry to be linked to; a
401
+ * definite outcome (forwarded and answered, or answered with a refusal)
402
+ * settles the key, so a later request is not linked to an attempt that
403
+ * is no longer unknown. Anything that sent nothing leaves the record.
404
+ */
405
+ private settleAttempt;
285
406
  /**
286
407
  * Why a request's tenant key refuses it, or null when it admits it: always
287
408
  * admitted when the gateway has no keys; otherwise only a key that hashes
@@ -311,7 +432,179 @@ export declare class Gateway {
311
432
  */
312
433
  resume(intentId: string, resumeToken: string | null): Promise<GatewayResponse>;
313
434
  close(): Promise<void>;
435
+ /** Whether this gateway serves acceptance runs: its configuration names their key and token. */
436
+ get servesAcceptance(): boolean;
437
+ /**
438
+ * Whether a bearer is the acceptance runs' operator token: compared by
439
+ * digest, in constant time, against the file as it is now, so a rotated
440
+ * token takes effect at once. Never an agent's credential.
441
+ */
442
+ acceptanceToken(presented: string | undefined): boolean;
443
+ openAcceptance(body: unknown): RunAnswer;
444
+ decideAcceptance(runId: string, write: string): Promise<RunAnswer>;
445
+ closeAcceptance(runId: string, zone: unknown): Promise<RunAnswer>;
446
+ /**
447
+ * Whether a request carrying the run header is a write the open run names,
448
+ * sent as named: tracked when it is, refused when it is not. A gateway that
449
+ * serves no run refuses every request carrying the header.
450
+ */
451
+ admitAcceptance(request: InterceptedRequest, tag: string | undefined): Admission;
452
+ /** The answer to a write a run sent, for one the gateway refused before capturing it. */
453
+ answeredAcceptance(request: InterceptedRequest, answer: GatewayResponse): void;
454
+ /** What this gateway lends a run: its routes, its reads, its chain and its key. */
455
+ private acceptanceHost;
456
+ /** A plan's write as the listener would have handed it over. */
457
+ private static acceptanceRequest;
458
+ private acceptanceRoute;
459
+ /**
460
+ * A plan's write decided in shadow: captured as its route captures it, with
461
+ * no read of its target, asked of the authority in shadow, and forwarded
462
+ * nowhere. The shadow pipeline records the decision on the evidence chain.
463
+ */
464
+ private acceptanceDecide;
465
+ /**
466
+ * A plan's write through a second gateway built from this configuration,
467
+ * its authority unreachable and its upstream recording, closed after: what
468
+ * it answered, and how many writes reached its upstream.
469
+ */
470
+ private static acceptanceOutage;
471
+ /**
472
+ * The configuration the outage case's second gateway is built from: this
473
+ * one, with nothing it could write to or wait on outside the process. No
474
+ * evidence file or journal (the deployed gateway's chains are its own), no
475
+ * upstream proof or public-only resolution, no subject keys to fetch, no
476
+ * reads after a refusal, and no acceptance runs of its own.
477
+ */
478
+ private static outageConfig;
479
+ /** The deployed gateway's secrets, lent: the second gateway reads them and never closes them. */
480
+ private static borrowed;
314
481
  private captureIntent;
482
+ /**
483
+ * Facts-only privacy: the authority receives the profile operation that
484
+ * named the call, its path template and the facts it names, and the keyed
485
+ * digest that binds the held request. No path, query, header or body byte
486
+ * of the request is in the intent; a call the profile does not describe
487
+ * never reaches here, because the route table refused it.
488
+ */
489
+ private captureFacts;
490
+ /**
491
+ * What a captured write binds of its target, exactly as an executor binds
492
+ * it: the version read before the authority is asked, stamped by the
493
+ * capture into the hashed context as `agent_safe.precondition`, and the
494
+ * digest of the effect the call asks for, which the grant then commits to.
495
+ * Nothing for a write whose operation names no read.
496
+ */
497
+ private static targetBinding;
498
+ /**
499
+ * The read a profiled write's operation names, made before the authority
500
+ * is asked, in enforcement only; null when there is none to make: no
501
+ * profile, a call the profile does not name as this action, or an
502
+ * operation that names no read.
503
+ */
504
+ private targetPlan;
505
+ /**
506
+ * A write whose target stated no usable version: refused before the
507
+ * authority is asked, as an executor's is, rather than decided against no
508
+ * version at all. A report line, a line on the evidence chain naming the
509
+ * reason, and the gateway's own `502`, since it is the upstream's answer
510
+ * that could not be read.
511
+ */
512
+ private targetUnreadable;
513
+ /**
514
+ * After a refusal of a write whose operation names a read: the target read
515
+ * again once the window has passed, and a chained `REFUSAL_OBSERVATION`
516
+ * naming the version before the decision, the version after and both
517
+ * instants. An unchanged version says no write landed on that resource
518
+ * between the two reads, by any route; nothing about another resource or
519
+ * another time. The caller's answer never waits for it; the stop does.
520
+ */
521
+ private observeRefusal;
522
+ /**
523
+ * The pinned subject as the authority reads it: the fact `session.subject`.
524
+ * A verified claim of the identity provider, never a value of the request;
525
+ * absent, never null, when the request presented no session.
526
+ */
527
+ /**
528
+ * What the intent says of the INDETERMINATE attempt it retries: that
529
+ * attempt's dossier, so policy can decide a retry of a write that may
530
+ * already have happened, and the new dossier names the earlier one.
531
+ */
532
+ private static retryContext;
533
+ private static sessionContext;
534
+ /** The session a request presents, when the gateway pins subjects; null when it presents none. */
535
+ private sessionOf;
536
+ /**
537
+ * A read a profile operation names, checked against the session's subject
538
+ * and never decided. Before it is sent: the request must present a session
539
+ * that stands, and when the operation says where the subject sits in the
540
+ * call, it must be the session's. After: when the operation says where the
541
+ * subject sits in each item of a successful answer, every item must name
542
+ * the session's subject, or the whole answer is refused and none of it is
543
+ * relayed; nothing is filtered, since a partial answer would look complete.
544
+ * An answer that is not a success is relayed as it came. Every refusal is
545
+ * a reason code and a line on the gateway's evidence chain.
546
+ */
547
+ check(request: InterceptedRequest, operationId: string): Promise<GatewayResponse>;
548
+ /**
549
+ * Why a successful answer may not be relayed for this session, or null when
550
+ * it may: every item the operation's response pointer reaches must name the
551
+ * session's subject, and beside a list only the envelope's keys may stand.
552
+ * An answer that is not a success is relayed as it came.
553
+ */
554
+ private answerRefusal;
555
+ /**
556
+ * A forwarded answer, relayed: as it came, or, when the request's operation
557
+ * names where the subject sits in its answer and the answer names another
558
+ * subject, withheld. The effect, if any, has happened; the response says
559
+ * the call reached the upstream (`WITHHELD`) and with what status, so a
560
+ * caller never takes it for a call that was not made.
561
+ */
562
+ private answer;
563
+ /** The profile operation that named a governed call, when it names a subject; else null. */
564
+ private scopedOperation;
565
+ /**
566
+ * A checked read's query, decoded as RFC 3986 writes it: each name and
567
+ * value percent-decoded once, and a `+` refused rather than read as a space
568
+ * or a plus, since an upstream may read it either way and a subject check
569
+ * must see what the upstream sees. Null when a component does not decode,
570
+ * holds a `+`, or is a name the intent contract forbids.
571
+ */
572
+ private static strictQuery;
573
+ /**
574
+ * RFC 8693 token exchange at the gateway: the identity provider's subject
575
+ * token in, a session token for this gateway out. The answer is the RFC's,
576
+ * never cached; issuing and refusing are both lines on the evidence chain,
577
+ * with the session's short digest and never a token or the subject.
578
+ */
579
+ exchange(form: URLSearchParams): Promise<GatewayResponse>;
580
+ /** An OAuth token endpoint's answer: JSON, never stored by anything between. */
581
+ private oauth;
582
+ /**
583
+ * A subject refusal: the gateway's own answer, a report line and a line on
584
+ * the evidence chain naming the operation, the reason and the session by
585
+ * its short digest. `WITHHELD`, with the upstream's status, when the call
586
+ * reached the upstream and its answer was not relayed; `NOT_FORWARDED`
587
+ * otherwise.
588
+ */
589
+ private subjectRefused;
590
+ /**
591
+ * The facts the gateway's API profile names for this call, when the profile
592
+ * named its action: each at the top level of the trusted context, beside the
593
+ * operation, exactly as a native executor reading the same profile states
594
+ * them. The body is read for facts whether or not it is embedded.
595
+ */
596
+ private profileFacts;
597
+ private profile;
598
+ /** What the gateway's API profile says about a call, its JSON body read when there is one. */
599
+ private profileMatch;
600
+ /** A call as the gateway's API profile reads it; null when the gateway has no profile. */
601
+ private profileRequest;
602
+ /**
603
+ * The observation, when it has settled by now or settles within `waitMs`;
604
+ * otherwise null. With 0 it never waits: an already settled promise wins
605
+ * the race against the resolved sentinel because it is listed first.
606
+ */
607
+ private static settledWithin;
315
608
  private principalOf;
316
609
  private observe;
317
610
  private enforce;
@@ -319,7 +612,47 @@ export declare class Gateway {
319
612
  private unavailable;
320
613
  /** An ALLOW: the grant claimed, the exact request sent once, the outcome finalized and relayed. */
321
614
  private execute;
615
+ /**
616
+ * The route's money declaration and what the request states for it, when
617
+ * the request is governed by a route that releases money; null otherwise,
618
+ * and always null for a gateway with no such route.
619
+ */
620
+ private moneyOf;
621
+ /**
622
+ * The check run after the grant is claimed and before the payment is sent:
623
+ * reserve against every covering limit, and refuse, sending nothing, when
624
+ * one would be exceeded or, unless the route fails open, when the ledger
625
+ * cannot be asked. What it found is left in `reserved` for the outcome.
626
+ */
627
+ private beforeDispatch;
628
+ /** What a report and an answer say about a payment's reservations; null for a route that releases none. */
629
+ private static exposureReport;
630
+ /**
631
+ * The gateway's answer to a payment its cumulative limits refused: the
632
+ * authority allowed it and its grant was claimed, but nothing was sent.
633
+ * A limit that escalates is refused as one that holds: the claimed grant
634
+ * cannot be held for a person, so the answer names the limit and its
635
+ * `on_exceed`, and a new request is decided afresh once the limit allows.
636
+ */
637
+ private exposureRefused;
638
+ /**
639
+ * In shadow, after the authority would have allowed a payment: what the
640
+ * ledger would have said, without counting it.
641
+ */
642
+ private observeExposure;
643
+ /**
644
+ * What a forwarded write's report says of its effect: what the read after
645
+ * it said, or why nothing was read. A write that names no read, or no
646
+ * effect, holds only the upstream's acknowledgement.
647
+ */
648
+ private effectOf;
322
649
  private hold;
650
+ /**
651
+ * The request as a hold keeps it: without the gateway's own credentials
652
+ * (they end here, and the caller was admitted when it was held) or the
653
+ * upstream credential, which the gateway sets again when it forwards.
654
+ */
655
+ private holdable;
323
656
  /**
324
657
  * The hold under an id, for the caller presenting its token. A refusal is
325
658
  * linked to the evidence stream, because a wrong token for a live hold is
@@ -328,7 +661,6 @@ export declare class Gateway {
328
661
  private heldFor;
329
662
  private static resumeDigest;
330
663
  private release;
331
- private expireHeld;
332
664
  private holdBody;
333
665
  /** The handoff without the intent, which the gateway holds itself. */
334
666
  private handoffBody;
@@ -360,7 +692,7 @@ export declare class Gateway {
360
692
  /** A response the gateway itself makes: JSON, protective headers, the wire version. */
361
693
  private own;
362
694
  private report;
363
- /** One chained line on the gateway's own stream. */
695
+ /** One chained line on the gateway's own stream, and where it went. */
364
696
  private link;
365
697
  private count;
366
698
  }