@decionis/agentsafe 0.5.0 → 0.7.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 (211) hide show
  1. package/README.md +62 -19
  2. package/dist/Cli.js +18 -1
  3. package/dist/Cli.js.map +1 -1
  4. package/dist/Index.d.ts +9 -4
  5. package/dist/Index.d.ts.map +1 -1
  6. package/dist/Index.js +7 -2
  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/adapters/AdapterActionHandler.d.ts +36 -12
  12. package/dist/adapters/AdapterActionHandler.d.ts.map +1 -1
  13. package/dist/adapters/AdapterActionHandler.js +99 -100
  14. package/dist/adapters/AdapterActionHandler.js.map +1 -1
  15. package/dist/adapters/EffectAdapter.d.ts +7 -103
  16. package/dist/adapters/EffectAdapter.d.ts.map +1 -1
  17. package/dist/adapters/EffectAdapter.js +7 -18
  18. package/dist/adapters/EffectAdapter.js.map +1 -1
  19. package/dist/adapters/EffectAdapterExecutor.d.ts +93 -0
  20. package/dist/adapters/EffectAdapterExecutor.d.ts.map +1 -0
  21. package/dist/adapters/EffectAdapterExecutor.js +191 -0
  22. package/dist/adapters/EffectAdapterExecutor.js.map +1 -0
  23. package/dist/adapters/banking/BankingExecutor.d.ts +35 -0
  24. package/dist/adapters/banking/BankingExecutor.d.ts.map +1 -0
  25. package/dist/adapters/banking/BankingExecutor.js +64 -0
  26. package/dist/adapters/banking/BankingExecutor.js.map +1 -0
  27. package/dist/adapters/banking/BankingHandlers.d.ts.map +1 -1
  28. package/dist/adapters/banking/BankingHandlers.js +6 -3
  29. package/dist/adapters/banking/BankingHandlers.js.map +1 -1
  30. package/dist/adapters/cards/CardAuthorizationExecutor.d.ts +66 -0
  31. package/dist/adapters/cards/CardAuthorizationExecutor.d.ts.map +1 -0
  32. package/dist/adapters/cards/CardAuthorizationExecutor.js +116 -0
  33. package/dist/adapters/cards/CardAuthorizationExecutor.js.map +1 -0
  34. package/dist/adapters/mcp/McpGuard.d.ts +32 -3
  35. package/dist/adapters/mcp/McpGuard.d.ts.map +1 -1
  36. package/dist/adapters/mcp/McpGuard.js +29 -5
  37. package/dist/adapters/mcp/McpGuard.js.map +1 -1
  38. package/dist/adapters/mcp/McpIntentBinder.d.ts +18 -3
  39. package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -1
  40. package/dist/adapters/mcp/McpIntentBinder.js +48 -1
  41. package/dist/adapters/mcp/McpIntentBinder.js.map +1 -1
  42. package/dist/adapters/mcp/McpInvocation.d.ts +9 -2
  43. package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -1
  44. package/dist/adapters/mcp/McpInvocation.js.map +1 -1
  45. package/dist/cli/Actions.d.ts +14 -0
  46. package/dist/cli/Actions.d.ts.map +1 -0
  47. package/dist/cli/Actions.js +168 -0
  48. package/dist/cli/Actions.js.map +1 -0
  49. package/dist/cli/Arguments.d.ts +4 -0
  50. package/dist/cli/Arguments.d.ts.map +1 -1
  51. package/dist/cli/Arguments.js +12 -3
  52. package/dist/cli/Arguments.js.map +1 -1
  53. package/dist/cli/ConfigCommand.d.ts.map +1 -1
  54. package/dist/cli/ConfigCommand.js +5 -0
  55. package/dist/cli/ConfigCommand.js.map +1 -1
  56. package/dist/cli/Doctor.d.ts.map +1 -1
  57. package/dist/cli/Doctor.js +2 -1
  58. package/dist/cli/Doctor.js.map +1 -1
  59. package/dist/cli/Help.d.ts.map +1 -1
  60. package/dist/cli/Help.js +13 -1
  61. package/dist/cli/Help.js.map +1 -1
  62. package/dist/cli/Host.d.ts +5 -2
  63. package/dist/cli/Host.d.ts.map +1 -1
  64. package/dist/cli/Host.js +24 -2
  65. package/dist/cli/Host.js.map +1 -1
  66. package/dist/cli/Profile.d.ts +24 -0
  67. package/dist/cli/Profile.d.ts.map +1 -0
  68. package/dist/cli/Profile.js +168 -0
  69. package/dist/cli/Profile.js.map +1 -0
  70. package/dist/cli/Records.d.ts +15 -0
  71. package/dist/cli/Records.d.ts.map +1 -0
  72. package/dist/cli/Records.js +205 -0
  73. package/dist/cli/Records.js.map +1 -0
  74. package/dist/config/ConfigKeys.d.ts +2 -2
  75. package/dist/config/ConfigKeys.d.ts.map +1 -1
  76. package/dist/config/ConfigKeys.js +6 -0
  77. package/dist/config/ConfigKeys.js.map +1 -1
  78. package/dist/config/ExecutorConfig.d.ts +29 -0
  79. package/dist/config/ExecutorConfig.d.ts.map +1 -1
  80. package/dist/config/ExecutorConfig.js +53 -1
  81. package/dist/config/ExecutorConfig.js.map +1 -1
  82. package/dist/gateway/ForwardHandler.d.ts +22 -4
  83. package/dist/gateway/ForwardHandler.d.ts.map +1 -1
  84. package/dist/gateway/ForwardHandler.js +27 -10
  85. package/dist/gateway/ForwardHandler.js.map +1 -1
  86. package/dist/gateway/Gateway.d.ts +123 -3
  87. package/dist/gateway/Gateway.d.ts.map +1 -1
  88. package/dist/gateway/Gateway.js +513 -16
  89. package/dist/gateway/Gateway.js.map +1 -1
  90. package/dist/gateway/GatewayConfig.d.ts +109 -0
  91. package/dist/gateway/GatewayConfig.d.ts.map +1 -1
  92. package/dist/gateway/GatewayConfig.js +267 -9
  93. package/dist/gateway/GatewayConfig.js.map +1 -1
  94. package/dist/gateway/GatewayReport.d.ts +6 -2
  95. package/dist/gateway/GatewayReport.d.ts.map +1 -1
  96. package/dist/gateway/GatewayReport.js +3 -0
  97. package/dist/gateway/GatewayReport.js.map +1 -1
  98. package/dist/gateway/InterceptedRequest.d.ts +45 -1
  99. package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
  100. package/dist/gateway/InterceptedRequest.js +43 -1
  101. package/dist/gateway/InterceptedRequest.js.map +1 -1
  102. package/dist/gateway/PolicySelector.d.ts +5 -0
  103. package/dist/gateway/PolicySelector.d.ts.map +1 -0
  104. package/dist/gateway/PolicySelector.js +9 -0
  105. package/dist/gateway/PolicySelector.js.map +1 -0
  106. package/dist/gateway/RouteTable.d.ts +44 -7
  107. package/dist/gateway/RouteTable.d.ts.map +1 -1
  108. package/dist/gateway/RouteTable.js +58 -9
  109. package/dist/gateway/RouteTable.js.map +1 -1
  110. package/dist/gateway/SubjectSessions.d.ts +113 -0
  111. package/dist/gateway/SubjectSessions.d.ts.map +1 -0
  112. package/dist/gateway/SubjectSessions.js +219 -0
  113. package/dist/gateway/SubjectSessions.js.map +1 -0
  114. package/dist/gateway/Upstream.d.ts +11 -0
  115. package/dist/gateway/Upstream.d.ts.map +1 -1
  116. package/dist/gateway/Upstream.js +19 -2
  117. package/dist/gateway/Upstream.js.map +1 -1
  118. package/dist/hosted/TenantHost.d.ts +24 -5
  119. package/dist/hosted/TenantHost.d.ts.map +1 -1
  120. package/dist/hosted/TenantHost.js +39 -10
  121. package/dist/hosted/TenantHost.js.map +1 -1
  122. package/dist/hosted/TenantRegistry.d.ts +20 -0
  123. package/dist/hosted/TenantRegistry.d.ts.map +1 -1
  124. package/dist/hosted/TenantRegistry.js +47 -1
  125. package/dist/hosted/TenantRegistry.js.map +1 -1
  126. package/dist/http/GatewayHttpServer.d.ts.map +1 -1
  127. package/dist/http/GatewayHttpServer.js +46 -2
  128. package/dist/http/GatewayHttpServer.js.map +1 -1
  129. package/dist/identity/WorkloadJwtVerifier.d.ts +13 -0
  130. package/dist/identity/WorkloadJwtVerifier.d.ts.map +1 -1
  131. package/dist/identity/WorkloadJwtVerifier.js +40 -8
  132. package/dist/identity/WorkloadJwtVerifier.js.map +1 -1
  133. package/dist/incident/HaltSwitch.d.ts +10 -2
  134. package/dist/incident/HaltSwitch.d.ts.map +1 -1
  135. package/dist/incident/HaltSwitch.js +22 -2
  136. package/dist/incident/HaltSwitch.js.map +1 -1
  137. package/dist/incident/SecurityEvents.d.ts +18 -0
  138. package/dist/incident/SecurityEvents.d.ts.map +1 -1
  139. package/dist/incident/SecurityEvents.js +17 -0
  140. package/dist/incident/SecurityEvents.js.map +1 -1
  141. package/dist/journal/ExecutionJournal.d.ts +5 -120
  142. package/dist/journal/ExecutionJournal.d.ts.map +1 -1
  143. package/dist/journal/ExecutionJournal.js +5 -125
  144. package/dist/journal/ExecutionJournal.js.map +1 -1
  145. package/dist/journal/FileExecutionJournal.d.ts +1 -0
  146. package/dist/journal/FileExecutionJournal.d.ts.map +1 -1
  147. package/dist/journal/FileExecutionJournal.js +4 -1
  148. package/dist/journal/FileExecutionJournal.js.map +1 -1
  149. package/dist/journal/InMemoryExecutionJournal.d.ts +2 -1
  150. package/dist/journal/InMemoryExecutionJournal.d.ts.map +1 -1
  151. package/dist/journal/InMemoryExecutionJournal.js +4 -1
  152. package/dist/journal/InMemoryExecutionJournal.js.map +1 -1
  153. package/dist/limits/HardLimits.d.ts.map +1 -1
  154. package/dist/limits/HardLimits.js.map +1 -1
  155. package/dist/outcomes/CardOutcomeEvidence.d.ts +56 -0
  156. package/dist/outcomes/CardOutcomeEvidence.d.ts.map +1 -0
  157. package/dist/outcomes/CardOutcomeEvidence.js +211 -0
  158. package/dist/outcomes/CardOutcomeEvidence.js.map +1 -0
  159. package/dist/outcomes/CardOutcomeFact.d.ts +90 -0
  160. package/dist/outcomes/CardOutcomeFact.d.ts.map +1 -0
  161. package/dist/outcomes/CardOutcomeFact.js +76 -0
  162. package/dist/outcomes/CardOutcomeFact.js.map +1 -0
  163. package/dist/outcomes/CardOutcomeLedger.d.ts +26 -0
  164. package/dist/outcomes/CardOutcomeLedger.d.ts.map +1 -0
  165. package/dist/outcomes/CardOutcomeLedger.js +31 -0
  166. package/dist/outcomes/CardOutcomeLedger.js.map +1 -0
  167. package/dist/outcomes/CardOutcomeRecorder.d.ts +35 -0
  168. package/dist/outcomes/CardOutcomeRecorder.d.ts.map +1 -0
  169. package/dist/outcomes/CardOutcomeRecorder.js +84 -0
  170. package/dist/outcomes/CardOutcomeRecorder.js.map +1 -0
  171. package/dist/outcomes/CardOutcomes.d.ts +68 -0
  172. package/dist/outcomes/CardOutcomes.d.ts.map +1 -0
  173. package/dist/outcomes/CardOutcomes.js +191 -0
  174. package/dist/outcomes/CardOutcomes.js.map +1 -0
  175. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts +54 -0
  176. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts.map +1 -0
  177. package/dist/outcomes/CoreOutcomeEvidenceClient.js +116 -0
  178. package/dist/outcomes/CoreOutcomeEvidenceClient.js.map +1 -0
  179. package/dist/outcomes/FileCardOutcomeLedger.d.ts +36 -0
  180. package/dist/outcomes/FileCardOutcomeLedger.d.ts.map +1 -0
  181. package/dist/outcomes/FileCardOutcomeLedger.js +152 -0
  182. package/dist/outcomes/FileCardOutcomeLedger.js.map +1 -0
  183. package/dist/outcomes/OutcomeEvidence.d.ts +238 -0
  184. package/dist/outcomes/OutcomeEvidence.d.ts.map +1 -0
  185. package/dist/outcomes/OutcomeEvidence.js +130 -0
  186. package/dist/outcomes/OutcomeEvidence.js.map +1 -0
  187. package/dist/outcomes/OutcomeEvidencePublisher.d.ts +81 -0
  188. package/dist/outcomes/OutcomeEvidencePublisher.d.ts.map +1 -0
  189. package/dist/outcomes/OutcomeEvidencePublisher.js +189 -0
  190. package/dist/outcomes/OutcomeEvidencePublisher.js.map +1 -0
  191. package/dist/outcomes/OutcomeEvidenceStore.d.ts +57 -0
  192. package/dist/outcomes/OutcomeEvidenceStore.d.ts.map +1 -0
  193. package/dist/outcomes/OutcomeEvidenceStore.js +191 -0
  194. package/dist/outcomes/OutcomeEvidenceStore.js.map +1 -0
  195. package/dist/service/Requests.d.ts +6 -0
  196. package/dist/service/Requests.d.ts.map +1 -1
  197. package/dist/service/Requests.js +9 -1
  198. package/dist/service/Requests.js.map +1 -1
  199. package/dist/service/TrustedExecutorService.d.ts +21 -1
  200. package/dist/service/TrustedExecutorService.d.ts.map +1 -1
  201. package/dist/service/TrustedExecutorService.js +73 -23
  202. package/dist/service/TrustedExecutorService.js.map +1 -1
  203. package/dist/time/MonotonicClock.d.ts +4 -32
  204. package/dist/time/MonotonicClock.d.ts.map +1 -1
  205. package/dist/time/MonotonicClock.js +4 -49
  206. package/dist/time/MonotonicClock.js.map +1 -1
  207. package/dist/verify/VerifyingProvider.d.ts +32 -6
  208. package/dist/verify/VerifyingProvider.d.ts.map +1 -1
  209. package/dist/verify/VerifyingProvider.js +16 -2
  210. package/dist/verify/VerifyingProvider.js.map +1 -1
  211. package/package.json +6 -5
@@ -0,0 +1,68 @@
1
+ import type { CapturedIntent } from "@decionis/agent-safe-pipeline";
2
+ import type { CardOutcomesConfig } from "../config/ExecutorConfig.js";
3
+ import type { FetchLike } from "../handlers/HandlerRegistration.js";
4
+ import type { SecurityEvents } from "../incident/SecurityEvents.js";
5
+ import type { ActionResponse } from "../service/Requests.js";
6
+ import type { CardOutcomeLedger } from "./CardOutcomeLedger.js";
7
+ import { type OutcomeEvidenceSink } from "./CoreOutcomeEvidenceClient.js";
8
+ import { type OutcomePublishSummary } from "./OutcomeEvidencePublisher.js";
9
+ /** The state file the publisher keeps beside the facts. */
10
+ export declare const CARD_OUTCOMES_STATE_FILE = "card-outcomes-state.json";
11
+ export interface CardOutcomesOptions {
12
+ readonly config: CardOutcomesConfig;
13
+ /** The authority's normalized base URL: Core serves the meter beside it. */
14
+ readonly authorityUrl: string;
15
+ /** The producer token, read from its secret handle at each request. */
16
+ readonly token: () => string;
17
+ /** The guarded fetch. */
18
+ readonly fetch: FetchLike;
19
+ readonly events: SecurityEvents;
20
+ /** Test seams: the ledger, Core's resource, the clock and this replica's name. */
21
+ readonly ledger?: CardOutcomeLedger;
22
+ readonly sink?: OutcomeEvidenceSink;
23
+ readonly clock?: () => Date;
24
+ readonly replica?: string;
25
+ }
26
+ /**
27
+ * The card purchases' outcome evidence, as the executor runs it: a recorder the card path
28
+ * tells what each purchase came to once its answer is decided, and, when publishing, the
29
+ * publisher that states it to Decionis on its own timer. Every method the request path calls
30
+ * returns at once and never throws; none of them is awaited, so with outcomes on or off every
31
+ * authorization is answered exactly the same.
32
+ *
33
+ * What is recorded is read from what the path already holds (the captured intent, the answer,
34
+ * the claim, the issuer's result), and only identifiers, codes, times and the purchase's amount
35
+ * are kept: the card reference, the merchant and the authorization id stay where they are.
36
+ */
37
+ export declare class CardOutcomes {
38
+ private readonly recorder;
39
+ private readonly publisher;
40
+ private constructor();
41
+ /** Null when the configuration leaves outcomes off. */
42
+ static create(options: CardOutcomesOptions): CardOutcomes | null;
43
+ /** Starts publishing, when this deployment publishes. */
44
+ start(): void;
45
+ stop(): void;
46
+ /** Resolves once every fact recorded so far is written or dropped. */
47
+ flush(): Promise<void>;
48
+ /** One run now, for an operator or a test; never throws. */
49
+ publish(): Promise<OutcomePublishSummary | null>;
50
+ /**
51
+ * The first decision a card purchase was given: in enforcement the held grant or the hold, in
52
+ * shadow what would have been decided. A decision the authority never took (it did not
53
+ * answer, and the boundary refused on its own) is not a decision to measure.
54
+ */
55
+ decided(captured: CapturedIntent, answer: ActionResponse): void;
56
+ /**
57
+ * A fresh decision on an open escalation. Only an `ALLOW` or a `BLOCK` is a resolution: an
58
+ * answer still pending, or a hold that is still escalated, changes nothing yet.
59
+ */
60
+ resumed(captured: CapturedIntent, answer: ActionResponse, via: "ATTESTATION" | "PRESENCE"): void;
61
+ /** The issuer's authorization matched the hold and claimed its grant. */
62
+ claimed(intentId: string, grantId: string): void;
63
+ /** What the issuer said it did with the authorization that claimed the grant. */
64
+ settled(intentId: string, outcome: "COMMITTED" | "FAILED" | "INDETERMINATE", receiptDigest: string): void;
65
+ /** The held grant's expiry, when the answer held one for the issuer. */
66
+ private static heldUntil;
67
+ }
68
+ //# sourceMappingURL=CardOutcomes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardOutcomes.d.ts","sourceRoot":"","sources":["../../src/outcomes/CardOutcomes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAA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,CAAC,IAAI,CAAC;IAInC,4DAA4D;IAC/C,OAAO,IAAI,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAI7D;;;;OAIG;IACI,OAAO,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,GAAG,IAAI;IA0BtE;;;OAGG;IACI,OAAO,CACZ,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,cAAc,EACtB,GAAG,EAAE,aAAa,GAAG,UAAU,GAC9B,IAAI;IAqBP,yEAAyE;IAClE,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAcvD,iFAAiF;IAC1E,OAAO,CACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,GAAG,QAAQ,GAAG,eAAe,EACjD,aAAa,EAAE,MAAM,GACpB,IAAI;IAeP,wEAAwE;IACxE,OAAO,CAAC,MAAM,CAAC,SAAS;CAKzB"}
@@ -0,0 +1,191 @@
1
+ import { join } from "node:path";
2
+ import { cardPurchaseOf, isCardActionName } from "../adapters/cards/CardPurchase.js";
3
+ import { CardOutcomeEvidenceProvider } from "./CardOutcomeEvidence.js";
4
+ import { CARD_OUTCOME_FACT_VERSION } from "./CardOutcomeFact.js";
5
+ import { CardOutcomeRecorder } from "./CardOutcomeRecorder.js";
6
+ import { CoreOutcomeEvidenceClient, } from "./CoreOutcomeEvidenceClient.js";
7
+ import { FileCardOutcomeLedger } from "./FileCardOutcomeLedger.js";
8
+ import { OutcomeEvidencePublisher, } from "./OutcomeEvidencePublisher.js";
9
+ import { OutcomeEvidenceStore } from "./OutcomeEvidenceStore.js";
10
+ /** The state file the publisher keeps beside the facts. */
11
+ export const CARD_OUTCOMES_STATE_FILE = "card-outcomes-state.json";
12
+ /**
13
+ * The card purchases' outcome evidence, as the executor runs it: a recorder the card path
14
+ * tells what each purchase came to once its answer is decided, and, when publishing, the
15
+ * publisher that states it to Decionis on its own timer. Every method the request path calls
16
+ * returns at once and never throws; none of them is awaited, so with outcomes on or off every
17
+ * authorization is answered exactly the same.
18
+ *
19
+ * What is recorded is read from what the path already holds (the captured intent, the answer,
20
+ * the claim, the issuer's result), and only identifiers, codes, times and the purchase's amount
21
+ * are kept: the card reference, the merchant and the authorization id stay where they are.
22
+ */
23
+ export class CardOutcomes {
24
+ recorder;
25
+ publisher;
26
+ constructor(recorder, publisher) {
27
+ this.recorder = recorder;
28
+ this.publisher = publisher;
29
+ }
30
+ /** Null when the configuration leaves outcomes off. */
31
+ static create(options) {
32
+ const { config, events } = options;
33
+ if (config.mode === "off")
34
+ return null;
35
+ const ledger = options.ledger ??
36
+ new FileCardOutcomeLedger(config.dir, options.replica === undefined ? {} : { replica: options.replica });
37
+ const recorder = new CardOutcomeRecorder({
38
+ ledger,
39
+ onDropped: (count, code) => events.emit({ event: "CARD_OUTCOMES_DROPPED", count, code }),
40
+ });
41
+ if (config.mode === "record")
42
+ return new CardOutcomes(recorder, null);
43
+ const publisher = new OutcomeEvidencePublisher({
44
+ ledger,
45
+ provider: new CardOutcomeEvidenceProvider(),
46
+ store: new OutcomeEvidenceStore(join(config.dir, CARD_OUTCOMES_STATE_FILE)),
47
+ sink: options.sink ??
48
+ new CoreOutcomeEvidenceClient({
49
+ baseUrl: options.authorityUrl,
50
+ token: options.token,
51
+ fetch: options.fetch,
52
+ }),
53
+ orgId: config.orgId,
54
+ intervalMs: config.intervalSeconds * 1_000,
55
+ ...(options.clock === undefined ? {} : { clock: options.clock }),
56
+ report: (summary) => {
57
+ if (summary.submitted > 0) {
58
+ events.emit({
59
+ event: "CARD_OUTCOMES_PUBLISHED",
60
+ submitted: summary.submitted,
61
+ accepted: summary.accepted,
62
+ duplicates: summary.duplicates,
63
+ conflicts: summary.conflicts,
64
+ });
65
+ }
66
+ if (summary.refused !== null) {
67
+ events.emit({
68
+ event: "CARD_OUTCOMES_REFUSED",
69
+ code: summary.refused,
70
+ retry: summary.retry,
71
+ });
72
+ }
73
+ },
74
+ });
75
+ return new CardOutcomes(recorder, publisher);
76
+ }
77
+ /** Starts publishing, when this deployment publishes. */
78
+ start() {
79
+ this.publisher?.start();
80
+ }
81
+ stop() {
82
+ this.publisher?.stop();
83
+ }
84
+ /** Resolves once every fact recorded so far is written or dropped. */
85
+ async flush() {
86
+ await this.recorder.flush();
87
+ }
88
+ /** One run now, for an operator or a test; never throws. */
89
+ async publish() {
90
+ return this.publisher === null ? null : await this.publisher.publish();
91
+ }
92
+ /**
93
+ * The first decision a card purchase was given: in enforcement the held grant or the hold, in
94
+ * shadow what would have been decided. A decision the authority never took (it did not
95
+ * answer, and the boundary refused on its own) is not a decision to measure.
96
+ */
97
+ decided(captured, answer) {
98
+ try {
99
+ if (!isCardActionName(captured.intent.action))
100
+ return;
101
+ if (answer.verdict === null || answer.fail_closed)
102
+ return;
103
+ const purchase = cardPurchaseOf(captured.intent.parameters);
104
+ this.recorder.note({
105
+ version: CARD_OUTCOME_FACT_VERSION,
106
+ kind: "DECIDED",
107
+ at: new Date().toISOString(),
108
+ intent_id: captured.intent.intentId,
109
+ tenant_id: captured.intent.tenantId,
110
+ mode: answer.mode,
111
+ verdict: answer.verdict,
112
+ decision_id: answer.decision_id,
113
+ dossier_id: answer.dossier_id,
114
+ reason_codes: answer.reason_codes.slice(0, 50),
115
+ held_until: CardOutcomes.heldUntil(answer),
116
+ expires_at: captured.intent.expiresAt,
117
+ currency: purchase.currency,
118
+ amount_minor: purchase.amountMinor,
119
+ });
120
+ }
121
+ catch {
122
+ // Evidence after the fact; never the request's failure.
123
+ }
124
+ }
125
+ /**
126
+ * A fresh decision on an open escalation. Only an `ALLOW` or a `BLOCK` is a resolution: an
127
+ * answer still pending, or a hold that is still escalated, changes nothing yet.
128
+ */
129
+ resumed(captured, answer, via) {
130
+ try {
131
+ if (!isCardActionName(captured.intent.action))
132
+ return;
133
+ if (answer.verdict !== "ALLOW" && answer.verdict !== "BLOCK")
134
+ return;
135
+ this.recorder.note({
136
+ version: CARD_OUTCOME_FACT_VERSION,
137
+ kind: "RESUMED",
138
+ at: new Date().toISOString(),
139
+ intent_id: captured.intent.intentId,
140
+ via,
141
+ verdict: answer.verdict,
142
+ decision_id: answer.decision_id,
143
+ dossier_id: answer.dossier_id,
144
+ reason_codes: answer.reason_codes.slice(0, 50),
145
+ held_until: CardOutcomes.heldUntil(answer),
146
+ });
147
+ }
148
+ catch {
149
+ // Evidence after the fact; never the request's failure.
150
+ }
151
+ }
152
+ /** The issuer's authorization matched the hold and claimed its grant. */
153
+ claimed(intentId, grantId) {
154
+ try {
155
+ this.recorder.note({
156
+ version: CARD_OUTCOME_FACT_VERSION,
157
+ kind: "CLAIMED",
158
+ at: new Date().toISOString(),
159
+ intent_id: intentId,
160
+ grant_id: grantId,
161
+ });
162
+ }
163
+ catch {
164
+ // Evidence after the fact; never the request's failure.
165
+ }
166
+ }
167
+ /** What the issuer said it did with the authorization that claimed the grant. */
168
+ settled(intentId, outcome, receiptDigest) {
169
+ try {
170
+ this.recorder.note({
171
+ version: CARD_OUTCOME_FACT_VERSION,
172
+ kind: "SETTLED",
173
+ at: new Date().toISOString(),
174
+ intent_id: intentId,
175
+ outcome,
176
+ receipt_digest: /^sha256:[0-9a-f]{64}$/.test(receiptDigest) ? receiptDigest : null,
177
+ });
178
+ }
179
+ catch {
180
+ // Evidence after the fact; never the request's failure.
181
+ }
182
+ }
183
+ /** The held grant's expiry, when the answer held one for the issuer. */
184
+ static heldUntil(answer) {
185
+ if (answer.outcome !== "HELD_FOR_AUTHORIZATION")
186
+ return null;
187
+ const expires = answer.result?.expires_at;
188
+ return typeof expires === "string" ? expires : null;
189
+ }
190
+ }
191
+ //# sourceMappingURL=CardOutcomes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardOutcomes.js","sourceRoot":"","sources":["../../src/outcomes/CardOutcomes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MA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OutcomeEvidence.js";
3
+ export declare const CORE_OUTCOME_EVIDENCE_PATH = "/v1/outcomes/evidence";
4
+ /** Submissions carry up to a thousand subjects; Core's answer is two counts. */
5
+ export declare const OUTCOME_SUBMIT_TIMEOUT_MS = 15000;
6
+ /** Core's evidence resource, as the publisher sees it. */
7
+ export interface OutcomeEvidenceSink {
8
+ submit(submission: OutcomeEvidenceSubmission): Promise<{
9
+ readonly accepted: number;
10
+ readonly duplicates: number;
11
+ }>;
12
+ }
13
+ /**
14
+ * A refused submission. A `permanent` refusal is one the same submission cannot get past by
15
+ * being sent again (evidence Core refuses, a producer it does not know or does not allow); any
16
+ * other is retried later. `conflict` names a subject Core already holds at that revision with
17
+ * other content, which the next attempt states under a higher revision.
18
+ */
19
+ export declare class OutcomeEvidenceRefusal extends Error {
20
+ readonly code: string;
21
+ readonly permanent: boolean;
22
+ readonly conflict: string | null;
23
+ constructor(code: string, permanent: boolean, conflict?: string | null);
24
+ }
25
+ export interface CoreOutcomeEvidenceClientOptions {
26
+ /** The authority's base URL, already normalized: Core serves the meter beside it. */
27
+ readonly baseUrl: string;
28
+ /** The producer token, read at the moment of each request and never held. */
29
+ readonly token: () => string;
30
+ /** The guarded fetch: the authority's origin and trust anchors, and nothing else. */
31
+ readonly fetch: FetchLike;
32
+ readonly timeoutMs?: number;
33
+ }
34
+ /**
35
+ * `POST {DECIONIS_API_URL}/v1/outcomes/evidence` with AgentSafe's producer token, the credential
36
+ * Core's producer registry names with `outcomes: "agentsafe"`; a customer's own key is never a
37
+ * producer, so the bank's API key cannot feed the meter that measures it. A 503
38
+ * (`outcomes_disabled`, `outcomes_unavailable`), a timeout or an outage is retried later; a 409
39
+ * names the subject Core already holds at that revision. Core's body, the URL and the token
40
+ * never leave this class.
41
+ */
42
+ export declare class CoreOutcomeEvidenceClient implements OutcomeEvidenceSink {
43
+ private readonly options;
44
+ private readonly url;
45
+ private readonly timeoutMs;
46
+ constructor(options: CoreOutcomeEvidenceClientOptions);
47
+ submit(submission: OutcomeEvidenceSubmission): Promise<{
48
+ readonly accepted: number;
49
+ readonly duplicates: number;
50
+ }>;
51
+ /** Core's answer as an object, or an empty one when it is not one. */
52
+ private static object;
53
+ }
54
+ //# sourceMappingURL=CoreOutcomeEvidenceClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreOutcomeEvidenceClient.d.ts","sourceRoot":"","sources":["../../src/outcomes/CoreOutcomeEvidenceClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAmB,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEvF,eAAO,MAAM,0BAA0B,0BAA0B,CAAC;AAClE,gFAAgF;AAChF,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAEhD,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,MAAM,CACJ,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACxE;AAED;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aAE7B,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,OAAO;aAClB,QAAQ,EAAE,MAAM,GAAG,IAAI;gBAFvB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,OAAO,EAClB,QAAQ,GAAE,MAAM,GAAG,IAAW;CAKjD;AAiBD,MAAM,WAAW,gCAAgC;IAC/C,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,qBAAa,yBAA0B,YAAW,mBAAmB;IAIhD,OAAO,CAAC,QAAQ,CAAC,OAAO;IAH3C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEC,OAAO,EAAE,gCAAgC;IAKhE,MAAM,CACjB,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IA+CtE,sEAAsE;IACtE,OAAO,CAAC,MAAM,CAAC,MAAM;CAUtB"}
@@ -0,0 +1,116 @@
1
+ import { isOutcomeDigest } from "./OutcomeEvidence.js";
2
+ export const CORE_OUTCOME_EVIDENCE_PATH = "/v1/outcomes/evidence";
3
+ /** Submissions carry up to a thousand subjects; Core's answer is two counts. */
4
+ export const OUTCOME_SUBMIT_TIMEOUT_MS = 15_000;
5
+ /**
6
+ * A refused submission. A `permanent` refusal is one the same submission cannot get past by
7
+ * being sent again (evidence Core refuses, a producer it does not know or does not allow); any
8
+ * other is retried later. `conflict` names a subject Core already holds at that revision with
9
+ * other content, which the next attempt states under a higher revision.
10
+ */
11
+ export class OutcomeEvidenceRefusal extends Error {
12
+ code;
13
+ permanent;
14
+ conflict;
15
+ constructor(code, permanent, conflict = null) {
16
+ super(code);
17
+ this.code = code;
18
+ this.permanent = permanent;
19
+ this.conflict = conflict;
20
+ this.name = "OutcomeEvidenceRefusal";
21
+ }
22
+ }
23
+ /** Core's refusals a retry of the same submission cannot fix. */
24
+ const PERMANENT = {
25
+ 400: "OUTCOME_EVIDENCE_REFUSED",
26
+ 401: "OUTCOME_PRODUCER_REQUIRED",
27
+ 403: "OUTCOME_PRODUCER_NOT_ALLOWED",
28
+ 404: "OUTCOME_ROUTE_OR_ORGANIZATION_MISSING",
29
+ 413: "OUTCOME_EVIDENCE_REFUSED",
30
+ 422: "OUTCOME_EVIDENCE_REFUSED",
31
+ };
32
+ /** What Core's producer registry accepts as a token: printable ASCII, 32 to 512 characters. */
33
+ const TOKEN = /^[\x21-\x7e]{32,512}$/;
34
+ const count = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
35
+ /**
36
+ * `POST {DECIONIS_API_URL}/v1/outcomes/evidence` with AgentSafe's producer token, the credential
37
+ * Core's producer registry names with `outcomes: "agentsafe"`; a customer's own key is never a
38
+ * producer, so the bank's API key cannot feed the meter that measures it. A 503
39
+ * (`outcomes_disabled`, `outcomes_unavailable`), a timeout or an outage is retried later; a 409
40
+ * names the subject Core already holds at that revision. Core's body, the URL and the token
41
+ * never leave this class.
42
+ */
43
+ export class CoreOutcomeEvidenceClient {
44
+ options;
45
+ url;
46
+ timeoutMs;
47
+ constructor(options) {
48
+ this.options = options;
49
+ this.url = `${options.baseUrl}${CORE_OUTCOME_EVIDENCE_PATH}`;
50
+ this.timeoutMs = options.timeoutMs ?? OUTCOME_SUBMIT_TIMEOUT_MS;
51
+ }
52
+ async submit(submission) {
53
+ let token;
54
+ try {
55
+ token = this.options.token();
56
+ }
57
+ catch {
58
+ throw new OutcomeEvidenceRefusal("OUTCOME_PRODUCER_TOKEN_UNAVAILABLE", false);
59
+ }
60
+ if (!TOKEN.test(token))
61
+ throw new OutcomeEvidenceRefusal("OUTCOME_PRODUCER_TOKEN_INVALID", true);
62
+ const controller = new AbortController();
63
+ const timer = setTimeout(() => controller.abort(), this.timeoutMs);
64
+ let status;
65
+ let text;
66
+ try {
67
+ const response = await this.options.fetch(this.url, {
68
+ method: "POST",
69
+ headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
70
+ body: JSON.stringify(submission),
71
+ redirect: "error",
72
+ signal: controller.signal,
73
+ });
74
+ status = response.status;
75
+ text = await response.text();
76
+ }
77
+ catch {
78
+ throw new OutcomeEvidenceRefusal("OUTCOME_EVIDENCE_UNAVAILABLE", false);
79
+ }
80
+ finally {
81
+ clearTimeout(timer);
82
+ }
83
+ const answer = CoreOutcomeEvidenceClient.object(text);
84
+ if (status === 409) {
85
+ const subject = answer["subject_digest"];
86
+ if (answer["error"] === "evidence_revision_conflict" && isOutcomeDigest(subject)) {
87
+ throw new OutcomeEvidenceRefusal("OUTCOME_EVIDENCE_REVISION_CONFLICT", false, subject);
88
+ }
89
+ throw new OutcomeEvidenceRefusal("OUTCOME_EVIDENCE_CONFLICT", true);
90
+ }
91
+ const permanent = PERMANENT[status];
92
+ if (permanent !== undefined)
93
+ throw new OutcomeEvidenceRefusal(permanent, true);
94
+ if (status !== 200)
95
+ throw new OutcomeEvidenceRefusal("OUTCOME_EVIDENCE_UNAVAILABLE", false);
96
+ const accepted = answer["accepted"];
97
+ const duplicates = answer["duplicates"];
98
+ if (!count(accepted) || !count(duplicates)) {
99
+ throw new OutcomeEvidenceRefusal("OUTCOME_EVIDENCE_RESPONSE_INVALID", false);
100
+ }
101
+ return { accepted, duplicates };
102
+ }
103
+ /** Core's answer as an object, or an empty one when it is not one. */
104
+ static object(text) {
105
+ try {
106
+ const value = JSON.parse(text);
107
+ return value !== null && typeof value === "object" && !Array.isArray(value)
108
+ ? value
109
+ : {};
110
+ }
111
+ catch {
112
+ return {};
113
+ }
114
+ }
115
+ }
116
+ //# sourceMappingURL=CoreOutcomeEvidenceClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreOutcomeEvidenceClient.js","sourceRoot":"","sources":["../../src/outcomes/CoreOutcomeEvidenceClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAkC,MAAM,sBAAsB,CAAC;AAEvF,MAAM,CAAC,MAAM,0BAA0B,GAAG,uBAAuB,CAAC;AAClE,gFAAgF;AAChF,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAShD;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAE7B;IACA;IACA;IAHlB,YACkB,IAAY,EACZ,SAAkB,EAClB,WAA0B,IAAI;QAE9C,KAAK,CAAC,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AAI,sBAAsB,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAC;QACtE,CAAC;QACD,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,SAAS,KAAK,SAAS;YAAE,MAAM,IAAI,sBAAsB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC/E,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM,IAAI,sBAAsB,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;QAC5F,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,sBAAsB,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IAClC,CAAC;IAED,sEAAsE;IAC9D,MAAM,CAAC,MAAM,CAAC,IAAY;QAChC,IAAI,CAAC;YACH,MAAM,KAAK,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBACzE,CAAC,CAAE,KAAiC;gBACpC,CAAC,CAAC,EAAE,CAAC;QACT,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ import { type CardOutcomeFact } from "./CardOutcomeFact.js";
2
+ import { type CardOutcomeLedger } from "./CardOutcomeLedger.js";
3
+ /** The longest line a read takes for a fact; a longer one is skipped, never parsed. */
4
+ export declare const MAX_FACT_BYTES: number;
5
+ export interface FileCardOutcomeLedgerOptions {
6
+ /** This replica's name in its files; the host's name when absent. */
7
+ readonly replica?: string;
8
+ }
9
+ /**
10
+ * The outcome facts as append-only JSONL, one file per UTC day and per replica:
11
+ * `card-outcomes-<day>.<replica>.jsonl`. Replicas that share the directory (a volume every
12
+ * replica mounts) each write their own file, so no two processes append to one; the producer
13
+ * reads every replica's files and orders the facts by time, so a purchase held on one replica
14
+ * and claimed on another reads as one purchase.
15
+ *
16
+ * The directory is created private to this process, a path that is not a regular file is
17
+ * refused, and a line that is not a fact, or is longer than the bound, is skipped when read
18
+ * rather than trusted. Nothing here is deleted: older days are left for the operator's
19
+ * retention, and only the days a read asks for are opened.
20
+ */
21
+ export declare class FileCardOutcomeLedger implements CardOutcomeLedger {
22
+ private readonly directory;
23
+ private readonly replica;
24
+ constructor(directory: string, options?: FileCardOutcomeLedgerOptions);
25
+ /**
26
+ * A replica's name as a file may carry it: lowercase letters, digits and dashes, at most 63,
27
+ * so a pod name is kept as it reads and anything else becomes a dash. Linear, with no pattern
28
+ * a hostile name could make backtrack.
29
+ */
30
+ static replicaName(value: string): string;
31
+ append(facts: readonly CardOutcomeFact[]): Promise<void>;
32
+ since(from: Date): Promise<readonly CardOutcomeFact[]>;
33
+ /** One day's lines, appended in one write to a file that is a regular file and nothing else. */
34
+ private write;
35
+ }
36
+ //# sourceMappingURL=FileCardOutcomeLedger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileCardOutcomeLedger.d.ts","sourceRoot":"","sources":["../../src/outcomes/FileCardOutcomeLedger.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,wBAAwB,CAAC;AAEhC,uFAAuF;AACvF,eAAO,MAAM,cAAc,QAAY,CAAC;AAaxC,MAAM,WAAW,4BAA4B;IAC3C,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAI3D,OAAO,CAAC,QAAQ,CAAC,SAAS;IAH5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAGd,SAAS,EAAE,MAAM,EAClC,OAAO,GAAE,4BAAiC;IAW5C;;;;OAIG;WACW,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAiBnC,MAAM,CAAC,KAAK,EAAE,SAAS,eAAe,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxD,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAqCnE,gGAAgG;YAClF,KAAK;CAoBpB"}
@@ -0,0 +1,152 @@
1
+ import { constants, mkdirSync, statSync } from "node:fs";
2
+ import { open, readFile, readdir } from "node:fs/promises";
3
+ import { hostname } from "node:os";
4
+ import { join } from "node:path";
5
+ import { CardOutcomeFactSchema } from "./CardOutcomeFact.js";
6
+ import { CardOutcomeLedgerError, oldestFirst, } from "./CardOutcomeLedger.js";
7
+ /** The longest line a read takes for a fact; a longer one is skipped, never parsed. */
8
+ export const MAX_FACT_BYTES = 16 * 1024;
9
+ const FILE_PATTERN = /^card-outcomes-(\d{4}-\d{2}-\d{2})\.([a-z0-9-]{1,63})\.jsonl$/;
10
+ /**
11
+ * Append, create, write only; never through a symbolic link planted where the file should be,
12
+ * and never waiting on a pipe planted there either.
13
+ */
14
+ const APPEND_FLAGS = constants.O_WRONLY |
15
+ constants.O_APPEND |
16
+ constants.O_CREAT |
17
+ (constants.O_NOFOLLOW ?? 0) |
18
+ (constants.O_NONBLOCK ?? 0);
19
+ /**
20
+ * The outcome facts as append-only JSONL, one file per UTC day and per replica:
21
+ * `card-outcomes-<day>.<replica>.jsonl`. Replicas that share the directory (a volume every
22
+ * replica mounts) each write their own file, so no two processes append to one; the producer
23
+ * reads every replica's files and orders the facts by time, so a purchase held on one replica
24
+ * and claimed on another reads as one purchase.
25
+ *
26
+ * The directory is created private to this process, a path that is not a regular file is
27
+ * refused, and a line that is not a fact, or is longer than the bound, is skipped when read
28
+ * rather than trusted. Nothing here is deleted: older days are left for the operator's
29
+ * retention, and only the days a read asks for are opened.
30
+ */
31
+ export class FileCardOutcomeLedger {
32
+ directory;
33
+ replica;
34
+ constructor(directory, options = {}) {
35
+ this.directory = directory;
36
+ try {
37
+ mkdirSync(directory, { recursive: true, mode: 0o700 });
38
+ if (!statSync(directory).isDirectory())
39
+ throw new Error("not a directory");
40
+ }
41
+ catch {
42
+ throw new CardOutcomeLedgerError("CARD_OUTCOMES_DIRECTORY_UNUSABLE");
43
+ }
44
+ this.replica = FileCardOutcomeLedger.replicaName(options.replica ?? hostname());
45
+ }
46
+ /**
47
+ * A replica's name as a file may carry it: lowercase letters, digits and dashes, at most 63,
48
+ * so a pod name is kept as it reads and anything else becomes a dash. Linear, with no pattern
49
+ * a hostile name could make backtrack.
50
+ */
51
+ static replicaName(value) {
52
+ let name = "";
53
+ for (const character of value.toLowerCase()) {
54
+ const unit = character.charCodeAt(0);
55
+ const kept = character.length === 1 &&
56
+ ((unit >= 0x61 && unit <= 0x7a) || (unit >= 0x30 && unit <= 0x39));
57
+ name += kept ? character : "-";
58
+ if (name.length >= 63)
59
+ break;
60
+ }
61
+ let start = 0;
62
+ let end = name.length;
63
+ while (start < end && name[start] === "-")
64
+ start += 1;
65
+ while (end > start && name[end - 1] === "-")
66
+ end -= 1;
67
+ return start === end ? "local" : name.slice(start, end);
68
+ }
69
+ async append(facts) {
70
+ const days = new Map();
71
+ for (const fact of facts) {
72
+ const parsed = CardOutcomeFactSchema.safeParse(fact);
73
+ if (!parsed.success)
74
+ throw new CardOutcomeLedgerError("CARD_OUTCOMES_FACT_INVALID");
75
+ // The schema bounds every field, so a fact's line is always well inside the read bound.
76
+ const line = `${JSON.stringify(parsed.data)}\n`;
77
+ const day = new Date(parsed.data.at).toISOString().slice(0, 10);
78
+ const lines = days.get(day) ?? [];
79
+ lines.push(line);
80
+ days.set(day, lines);
81
+ }
82
+ for (const [day, lines] of days) {
83
+ await this.write(join(this.directory, `card-outcomes-${day}.${this.replica}.jsonl`), lines);
84
+ }
85
+ }
86
+ async since(from) {
87
+ const earliest = from.toISOString().slice(0, 10);
88
+ let entries;
89
+ try {
90
+ entries = await readdir(this.directory);
91
+ }
92
+ catch {
93
+ throw new CardOutcomeLedgerError("CARD_OUTCOMES_UNREADABLE");
94
+ }
95
+ const files = entries
96
+ .map((entry) => ({ entry, match: FILE_PATTERN.exec(entry) }))
97
+ .filter(({ match }) => match !== null && (match[1] ?? "") >= earliest)
98
+ .map(({ entry }) => entry)
99
+ .sort();
100
+ const facts = [];
101
+ for (const entry of files) {
102
+ let text;
103
+ try {
104
+ text = await readFile(join(this.directory, entry), "utf8");
105
+ }
106
+ catch {
107
+ // A file another replica is rotating, or one removed by retention: nothing to read.
108
+ continue;
109
+ }
110
+ for (const line of text.split("\n")) {
111
+ if (line.trim() === "" || line.length > MAX_FACT_BYTES)
112
+ continue;
113
+ let value;
114
+ try {
115
+ value = JSON.parse(line);
116
+ }
117
+ catch {
118
+ continue;
119
+ }
120
+ const fact = CardOutcomeFactSchema.safeParse(value);
121
+ if (fact.success)
122
+ facts.push(fact.data);
123
+ }
124
+ }
125
+ return oldestFirst(facts, from);
126
+ }
127
+ /** One day's lines, appended in one write to a file that is a regular file and nothing else. */
128
+ async write(path, lines) {
129
+ let handle;
130
+ try {
131
+ handle = await open(path, APPEND_FLAGS, 0o600);
132
+ }
133
+ catch {
134
+ throw new CardOutcomeLedgerError("CARD_OUTCOMES_UNWRITABLE");
135
+ }
136
+ try {
137
+ if (!(await handle.stat()).isFile()) {
138
+ throw new CardOutcomeLedgerError("CARD_OUTCOMES_NOT_A_FILE");
139
+ }
140
+ await handle.write(lines.join(""));
141
+ }
142
+ catch (error) {
143
+ throw error instanceof CardOutcomeLedgerError
144
+ ? error
145
+ : new CardOutcomeLedgerError("CARD_OUTCOMES_WRITE_FAILED");
146
+ }
147
+ finally {
148
+ await handle.close().catch(() => undefined);
149
+ }
150
+ }
151
+ }
152
+ //# sourceMappingURL=FileCardOutcomeLedger.js.map