@dvmkit/sdk 0.1.5-rc.9 → 0.2.1-rc.9

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 (67) hide show
  1. package/README.md +14 -0
  2. package/dist/{chunk-MLRCSJYX.js → chunk-2D75MNNG.js} +178 -550
  3. package/dist/{chunk-BIFLRKMO.js → chunk-2KGG5ORW.js} +1 -1
  4. package/dist/{chunk-27V2ILSR.js → chunk-4A2RAKCW.js} +2 -2
  5. package/dist/{chunk-5URG56JJ.js → chunk-A4CM2BD3.js} +18 -2
  6. package/dist/{chunk-L4OYF4DQ.js → chunk-AJNFXR7J.js} +2 -2
  7. package/dist/{chunk-S3XAHZQY.js → chunk-COYKJRMM.js} +24 -3
  8. package/dist/{chunk-UP2F5RRT.js → chunk-D7YQYLLM.js} +1 -4
  9. package/dist/{chunk-CEOAHV2I.js → chunk-FDKRXOZO.js} +0 -5
  10. package/dist/{chunk-TQWGQCNV.js → chunk-FPOLJRBF.js} +5 -5
  11. package/dist/{chunk-BTZY7VPH.js → chunk-GAIPXGM3.js} +1 -1
  12. package/dist/{chunk-SSSZUVWM.js → chunk-JAHRF5X3.js} +89 -39
  13. package/dist/{chunk-5PBOA25N.js → chunk-JNKQZVZX.js} +472 -617
  14. package/dist/{chunk-U6M3ATSG.js → chunk-MD3H3BF7.js} +40 -6
  15. package/dist/{chunk-CGKZDODG.js → chunk-MG67KXU7.js} +0 -5
  16. package/dist/{chunk-KSQEFVFJ.js → chunk-MMCE7XSR.js} +1 -1
  17. package/dist/{chunk-JZWELPFH.js → chunk-N5B66UOS.js} +4 -16
  18. package/dist/{chunk-BIP6G74V.js → chunk-O6D72KYA.js} +10 -10
  19. package/dist/{chunk-KXCKFIJI.js → chunk-QX52F6IB.js} +1 -1
  20. package/dist/{chunk-RW5LP57K.js → chunk-SDK6KDJN.js} +0 -1
  21. package/dist/{chunk-KVEHHC7W.js → chunk-U5VNEALI.js} +24 -13
  22. package/dist/{chunk-FROTD5XQ.js → chunk-V5ZRATJH.js} +2 -3
  23. package/dist/{chunk-EVBK675R.js → chunk-VA7GT6C6.js} +31 -37
  24. package/dist/{chunk-2UUXIIOC.js → chunk-VIVXB4CD.js} +3 -3
  25. package/dist/{chunk-6BQM7TOW.js → chunk-XMDQOXHO.js} +11 -38
  26. package/dist/{chunk-DMNLFNTW.js → chunk-XRLKGCAW.js} +2 -2
  27. package/dist/{chunk-M7LHFJ5K.js → chunk-XZ7LW4S5.js} +2 -3
  28. package/dist/{chunk-E4EVGPDX.js → chunk-YO56VCTQ.js} +0 -6
  29. package/dist/{credit-ledger-2DFQHNLB.js → credit-ledger-MHA652TV.js} +2 -2
  30. package/dist/{credit-menu-enwMbn55.d.ts → credit-menu-kDA9RVzD.d.ts} +524 -1077
  31. package/dist/{fx-D860pZvP.d.ts → fx-DhyT1Cjh.d.ts} +38 -82
  32. package/dist/index.d.ts +11 -26
  33. package/dist/index.js +2 -2
  34. package/dist/internal/caller.d.ts +644 -2140
  35. package/dist/internal/caller.js +32 -66
  36. package/dist/internal/server.d.ts +40 -90
  37. package/dist/internal/server.js +16 -16
  38. package/dist/{job-store-BUGqvCfL.d.ts → job-store-D3CcZp_g.d.ts} +73 -66
  39. package/dist/{lightning-backend-BozcevPZ.d.ts → lightning-backend-BhsyrBLa.d.ts} +19 -41
  40. package/dist/{memory-credit-ledger-MNUOTQO5.js → memory-credit-ledger-BYBATRN3.js} +3 -3
  41. package/dist/{mpp-secret-state-WNAQQ6K4.js → mpp-secret-state-B5GCILVH.js} +1 -1
  42. package/dist/{mpp-setup-4FJD6ZHV.js → mpp-setup-MPP3ST5X.js} +1 -1
  43. package/dist/{payout-reporter-RG6XNGPI.js → payout-reporter-KEMUXEUO.js} +2 -2
  44. package/dist/{postgres-consumed-credential-store-VHBT4KEA.js → postgres-consumed-credential-store-6N2V5MJN.js} +2 -2
  45. package/dist/postgres-job-store-MZZZMS2B.js +7 -0
  46. package/dist/postgres-kv-store-DXGTKXLU.js +7 -0
  47. package/dist/{postgres-replay-store-UJXRT6VO.js → postgres-replay-store-ZF4JNZOW.js} +2 -2
  48. package/dist/{pricing-4CEB34RM.js → pricing-MU5GNUJZ.js} +1 -1
  49. package/dist/{processed-payment-store-HAA4SFNK.js → processed-payment-store-GKMAWOM3.js} +2 -2
  50. package/dist/revenue-reporter-O75BGYFK.js +7 -0
  51. package/dist/server/index.d.ts +47 -159
  52. package/dist/server/index.js +67 -138
  53. package/dist/{ssrf-DbFkpDv0.d.ts → ssrf-dMooihtY.d.ts} +1 -2
  54. package/dist/{step-cache-5dljDqrQ.d.ts → step-cache-v2yhyhSZ.d.ts} +617 -1532
  55. package/dist/{tempo-charge-store-RIFTALZK.js → tempo-charge-store-SDTUNTKA.js} +2 -2
  56. package/dist/{tempo-lifecycle-DFIXQ54Q.js → tempo-lifecycle-G5SB4HFC.js} +5 -5
  57. package/dist/{tempo-session-store-2JNOKJGX.js → tempo-session-store-WF3VZXNF.js} +2 -2
  58. package/dist/{tempo-wallet-4QKSV65O.js → tempo-wallet-ZFNUDFVO.js} +2 -2
  59. package/dist/testing/index.d.ts +5 -15
  60. package/dist/testing/index.js +4 -11
  61. package/dist/{usd-DoRuAckA.d.ts → usd-Cu9G6xv2.d.ts} +14 -16
  62. package/dist/{wallet-CJC8lwxx.d.ts → wallet-Dwjs5n_M.d.ts} +1 -1
  63. package/dist/{x402-5H27DCBE.js → x402-CI6PSHNO.js} +5 -5
  64. package/package.json +3 -2
  65. package/dist/postgres-job-store-3RAXMNSY.js +0 -7
  66. package/dist/postgres-kv-store-JFBDP5IP.js +0 -7
  67. package/dist/revenue-reporter-ASZ7SHHH.js +0 -7
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  PostgresTempoSessionStore
3
- } from "../chunk-UP2F5RRT.js";
3
+ } from "../chunk-D7YQYLLM.js";
4
4
  import {
5
5
  verifyX402Payment
6
- } from "../chunk-BIFLRKMO.js";
6
+ } from "../chunk-2KGG5ORW.js";
7
7
  import {
8
8
  RevenueReporter
9
- } from "../chunk-EVBK675R.js";
9
+ } from "../chunk-VA7GT6C6.js";
10
10
  import {
11
11
  PayoutReporter
12
- } from "../chunk-6BQM7TOW.js";
12
+ } from "../chunk-XMDQOXHO.js";
13
13
  import {
14
14
  PostgresTempoChargeStore
15
- } from "../chunk-JZWELPFH.js";
15
+ } from "../chunk-N5B66UOS.js";
16
16
  import "../chunk-YG7G4DPZ.js";
17
17
  import {
18
18
  DEFAULT_LOCK_PUBKEY_GRACE_SECONDS,
@@ -65,13 +65,13 @@ import {
65
65
  verifyUpfrontPayment,
66
66
  x402RequiredUsdcMicro,
67
67
  x402SettledShare
68
- } from "../chunk-5PBOA25N.js";
69
- import "../chunk-DMNLFNTW.js";
68
+ } from "../chunk-JNKQZVZX.js";
69
+ import "../chunk-XRLKGCAW.js";
70
70
  import {
71
71
  settleWithFacilitator,
72
72
  verifyWithFacilitator
73
73
  } from "../chunk-BQ2NMWKE.js";
74
- import "../chunk-KVEHHC7W.js";
74
+ import "../chunk-U5VNEALI.js";
75
75
  import {
76
76
  SIGNED_ENVELOPE_FIELDS,
77
77
  SIGNED_ENVELOPE_TYPES,
@@ -88,18 +88,18 @@ import {
88
88
  isYieldMessage,
89
89
  providerMessage,
90
90
  toJobRecord
91
- } from "../chunk-U6M3ATSG.js";
91
+ } from "../chunk-MD3H3BF7.js";
92
92
  import {
93
93
  toLockPubkey
94
- } from "../chunk-KXCKFIJI.js";
94
+ } from "../chunk-QX52F6IB.js";
95
95
  import "../chunk-Z4BNLUZF.js";
96
- import "../chunk-5URG56JJ.js";
96
+ import "../chunk-A4CM2BD3.js";
97
97
  import "../chunk-MKI6OVW4.js";
98
98
  import "../chunk-KXZUCCEY.js";
99
- import "../chunk-E4EVGPDX.js";
99
+ import "../chunk-YO56VCTQ.js";
100
100
  import "../chunk-66HGCPBU.js";
101
101
  import "../chunk-FUJ36YDV.js";
102
- import "../chunk-27V2ILSR.js";
102
+ import "../chunk-4A2RAKCW.js";
103
103
  import "../chunk-AT6V3SY7.js";
104
104
  import {
105
105
  NON_CHANNEL_BITCOIN_RAILS,
@@ -110,13 +110,13 @@ import {
110
110
  isNonChannelBitcoinRail,
111
111
  lotOwedSats,
112
112
  netOwedSats
113
- } from "../chunk-MLRCSJYX.js";
114
- import "../chunk-S3XAHZQY.js";
113
+ } from "../chunk-2D75MNNG.js";
114
+ import "../chunk-COYKJRMM.js";
115
115
  import "../chunk-C3MTFLC6.js";
116
116
  import {
117
117
  _testing,
118
118
  wrapMppx
119
- } from "../chunk-M7LHFJ5K.js";
119
+ } from "../chunk-XZ7LW4S5.js";
120
120
  export {
121
121
  DEFAULT_LOCK_PUBKEY_GRACE_SECONDS,
122
122
  JobCancelledError,
@@ -1,14 +1,12 @@
1
1
  import { ProofLike } from '@cashu/cashu-ts';
2
- import { a1 as Message, ah as FundingMethod, X as FundingReceipt, bO as CreditSnapshot, Y as JobReceipt, ax as StepRecord, a2 as MessageType } from './step-cache-5dljDqrQ.js';
2
+ import { a1 as Message, ah as FundingMethod, X as FundingReceipt, bO as CreditSnapshot, Y as JobReceipt, ax as StepRecord, a2 as MessageType } from './step-cache-v2yhyhSZ.js';
3
3
 
4
- /** Job status values that can be persisted. */
5
4
  type JobStatus = "processing" | "completed" | "failed" | "awaiting-input" | "cancelled" | "working";
6
- /** Serializable snapshot of a job's persistent state. */
7
5
  interface JobRecord {
8
6
  id: string;
9
7
  tags: string[];
10
8
  /**
11
- * Capability name this job dispatches to (internal-review). Populated from the
9
+ * Capability name this job dispatches to. Populated from the
12
10
  * `POST /v1/job` body's `capability` field at submission time; persisted
13
11
  * so reactivation on another machine routes to the same handler.
14
12
  */
@@ -18,7 +16,7 @@ interface JobRecord {
18
16
  requesterId: string;
19
17
  /**
20
18
  * SHA-256 hex of the per-job opaque token issued at creation time for
21
- * anonymous requesters (internal-review). When set, all `/v1/job/:id/*` reads/writes
19
+ * anonymous requesters. When set, all `/v1/job/:id/*` reads/writes
22
20
  * gate on the caller presenting the matching `X-Job-Token` header — this is
23
21
  * the mechanism that prevents cross-caller transcript leaks for free DVMs
24
22
  * where every caller otherwise resolves to `requesterId === "anonymous"`.
@@ -27,7 +25,7 @@ interface JobRecord {
27
25
  */
28
26
  requesterTokenHash?: string;
29
27
  /**
30
- * The `job_token` itself, in the clear (internal-review). Kept so a caller whose
28
+ * The `job_token` itself, in the clear. Kept so a caller whose
31
29
  * paid submit timed out can replay it and be handed back the very token the
32
30
  * lost response carried — the alternative (minting a fresh one) would be
33
31
  * rejected by whichever machine is still running the job, since its
@@ -41,14 +39,14 @@ interface JobRecord {
41
39
  */
42
40
  requesterToken?: string;
43
41
  /**
44
- * Fingerprint of the submission that created this job (internal-review) — see
42
+ * Fingerprint of the submission that created this job — see
45
43
  * `requestFingerprint`. The replay gate: a retried paid submit is handed the
46
44
  * original job only when it reproduces this.
47
45
  */
48
46
  requestFingerprint?: string;
49
47
  /**
50
48
  * secp256k1 x-only pubkey of the caller that signed the submission, on
51
- * DVMs with descriptor-level auth (internal-review). Second half of the replay
49
+ * DVMs with descriptor-level auth. Second half of the replay
52
50
  * gate — the signature envelope is re-minted on every resume attempt, so
53
51
  * the identity behind it is pinned here instead.
54
52
  */
@@ -58,32 +56,44 @@ interface JobRecord {
58
56
  /** HTTP path whose live auth gate accepted the persisted caller proof. */
59
57
  authRequestPath?: string;
60
58
  status: JobStatus;
59
+ /** False on jobs accepted before complete lifecycle timing was available. */
60
+ timingKnown?: boolean;
61
+ /** SDK terminal attribution; never accepted from a handler. */
62
+ endedBy?: "caller" | "provider";
63
+ /** Unix ms when the terminal status committed; immutable afterwards. */
64
+ terminalAtMs?: number;
65
+ /** Accumulated awaiting-input time, excluding the currently open stretch. */
66
+ callerWaitMs?: number;
67
+ /** Unix ms at which the current awaiting-input stretch began. */
68
+ awaitingInputAtMs?: number;
61
69
  summary?: string;
62
70
  messages: Message[];
63
71
  seq: number;
64
72
  paidMsats: number;
65
73
  paymentMint?: string;
66
- /** Rail of the most recent successful credit (cashu / x402 / mpp). */
74
+ /** Rail of the most recent successful credit (cashu / x402 / tempo). */
67
75
  paymentRail?: FundingMethod;
68
76
  /**
69
77
  * Settlement reference threaded into the platform revenue ledger
70
78
  * (`revenue_events.tx_hash`). EVM tx hash for x402, mppx `challenge.id`
71
- * for mpp (internal-review); cashu accumulator path sets this to the
72
- * `X-Cashu-Request-Id` UUID (internal-review). Persisted so it survives durable
79
+ * for mpp; cashu accumulator path sets this to the
80
+ * `X-Cashu-Request-Id` UUID. Persisted so it survives durable
73
81
  * replay.
74
82
  */
75
83
  paymentTxHash?: string;
76
84
  /** Chain transaction returned to callers recovering x402 or Tempo acceptance. */
77
85
  paymentTransactionHash?: string;
78
- /** Rail-native upfront amount (sats / USDC microunits). internal-review. */
86
+ /**
87
+ * Accumulated same-rail stablecoin micro-units for Tempo/x402; resets when the rail changes.
88
+ * Cashu revenue uses paidMsats.
89
+ */
79
90
  nativeAmount?: number;
80
- /** Native asset tag — paired with `nativeAmount`. internal-review. */
91
+ /** Native asset tag paired with `nativeAmount`. */
81
92
  nativeAsset?: "sats" | "usdc" | "usdc.e" | "usd-cents";
82
- /** Cashu flow discriminator written into `revenue_events.metadata.cashu_flow` (internal-review). */
83
93
  cashuFlow?: "p2pk_accumulator";
84
94
  /**
85
95
  * What this job cost the **builder** to serve, in 1e-6 of
86
- * {@link JobRecord.costCurrency} (internal-review). Mirror of
96
+ * {@link JobRecord.costCurrency}. Mirror of
87
97
  * `ServerJob.costAmountMicro`; see that field. Absent means unreported,
88
98
  * which the platform treats differently from a declared zero.
89
99
  */
@@ -97,12 +107,12 @@ interface JobRecord {
97
107
  */
98
108
  costRevision?: number;
99
109
  /**
100
- * Credit the upfront payment funded/drew (internal-review). The terminal funnel
110
+ * Credit the upfront payment funded/drew. The terminal funnel
101
111
  * settles the draw on success and releases it on failure/cancel, and the
102
112
  * receipt countersigns the `ReceiptCredit` block from it.
103
113
  */
104
114
  creditId?: string;
105
- /** The draw placed for this job on `creditId` (internal-review). */
115
+ /** The draw placed for this job on `creditId`. */
106
116
  drawId?: string;
107
117
  /** Funding-time evidence returned on explicit fund-and-draw submissions. */
108
118
  fundingReceipt?: FundingReceipt;
@@ -110,11 +120,11 @@ interface JobRecord {
110
120
  receivedProofs: ProofLike[];
111
121
  pendingPaymentMsats?: number;
112
122
  /**
113
- * Per-job MPP credential binding (internal-review). Challenge ids issued in the
123
+ * Per-job MPP credential binding. Challenge ids issued in the
114
124
  * most-recent `requestPayment` yield; the SDK rejects mid-job credentials
115
125
  * whose `challenge.id` isn't in this set.
116
126
  *
117
- * Keeps its `mpp` spelling past internal-review's rail rename (internal-review). The ids
127
+ * Keeps its `mpp` spelling past rail rename. The ids
118
128
  * are mppx challenge ids — objects of the MPP envelope the Tempo rail rides,
119
129
  * which is not itself a rail — and this is server-internal anti-replay state
120
130
  * that is never serialised to a caller. It persists as
@@ -122,7 +132,7 @@ interface JobRecord {
122
132
  */
123
133
  pendingMppChallengeIds?: string[];
124
134
  /**
125
- * Per-job x402 credential binding (internal-review). 0x-prefixed 32-byte hex nonce
135
+ * Per-job x402 credential binding. 0x-prefixed 32-byte hex nonce
126
136
  * issued in the most-recent `requestPayment` yield; the SDK rejects mid-job
127
137
  * x402 payments whose decoded `authorization.nonce` differs from this value.
128
138
  */
@@ -135,7 +145,7 @@ interface JobRecord {
135
145
  pendingX402AmountUsdcMicro?: string;
136
146
  /**
137
147
  * The outstanding `requestPayment` ask denominated in fiat micro-units, pinned
138
- * when the payment-request was emitted (internal-review) — the mid-job analogue of
148
+ * when the payment-request was emitted — the mid-job analogue of
139
149
  * `resolvePriceFiat` pinning the quote. The ledger is fiat-denominated, so the
140
150
  * top-up's `fund` + `growDraw` need a figure that doesn't move with the BTC/USD
141
151
  * rate between the ask and the payment. Absent when the ask couldn't be priced
@@ -146,7 +156,7 @@ interface JobRecord {
146
156
  pendingPaymentFiatCurrency?: string;
147
157
  /**
148
158
  * What this job has **cumulatively** asked for mid-job, in fiat micro-units
149
- * of {@link askedTopUpCurrency} (internal-review) — the ceiling `growDraw` caps the
159
+ * of {@link askedTopUpCurrency} — the ceiling `growDraw` caps the
150
160
  * job's draw growth at. Monotonic: written by the same Tx A that emits each
151
161
  * payment-request, and never decremented, which is exactly what
152
162
  * `pendingPaymentFiatMicro` is not (Tx C drains it as payments land). A cap
@@ -154,7 +164,7 @@ interface JobRecord {
154
164
  * in the window before Tx C see a full ask that the winner had already
155
165
  * bought.
156
166
  *
157
- * `-1` is a sticky "not expressible" sentinel — after internal-review the one door
167
+ * `-1` is a sticky "not expressible" sentinel — after the one door
158
168
  * left to it is an ask the rate provider was down for. Undefined means no
159
169
  * mid-job ask has been recorded (including a row written before this
160
170
  * existed). Either way the cap is skipped and growth is unbounded, as it was
@@ -163,13 +173,13 @@ interface JobRecord {
163
173
  askedTopUpMicro?: number;
164
174
  /**
165
175
  * Currency of {@link askedTopUpMicro} (lowercase ISO-4217) — and, from
166
- * internal-review, the job's own ask denomination: first-write-wins, and read back
176
+ * the job's own ask denomination: first-write-wins, and read back
167
177
  * by `ctx.requestPayment` so every later ask pins in it too. That is what
168
178
  * makes a mid-job currency switch unexpressible rather than merely unlikely.
169
179
  */
170
180
  askedTopUpCurrency?: string;
171
181
  /**
172
- * Why this job's draw growth is **not** capped, when it isn't (internal-review) —
182
+ * Why this job's draw growth is **not** capped, when it isn't —
173
183
  * the durable half of the `-1` sentinel, so an operator can list the affected
174
184
  * jobs after the fact rather than reconstruct them from log lines. Sticky
175
185
  * first-writer-wins, like the sentinel itself. Null on every job whose ceiling
@@ -179,7 +189,7 @@ interface JobRecord {
179
189
  /** Price the job was charged at (msats). Used to detect overpayment for change/melt gating. */
180
190
  requiredMsats?: number;
181
191
  /**
182
- * The DVM-signed proof of this job's outcome (internal-review). Written once at the
192
+ * The DVM-signed proof of this job's outcome. Written once at the
183
193
  * terminal transition via `saveReceipt` and never rewritten — `save` leaves
184
194
  * the column alone so a stale in-memory snapshot can't clear it. Absent on
185
195
  * non-terminal jobs, and on every job when the DVM has no receipt key wired.
@@ -194,8 +204,8 @@ interface JobRecord {
194
204
  }
195
205
  /**
196
206
  * Counter snapshot used by the NOTIFY-driven resolver and the
197
- * `verifyAndCredit` flow (internal-review). Carries just the handler-visible state
198
- * needed to decide whether a pending payment yield can resolve, plus (internal-review)
207
+ * `verifyAndCredit` flow. Carries just the handler-visible state
208
+ * needed to decide whether a pending payment yield can resolve, plus
199
209
  * the terminal reason so a machine adopting another machine's cancel can hand
200
210
  * the caller's own words to `ctx.signal.reason` and the `onCancel` hook.
201
211
  */
@@ -211,7 +221,7 @@ interface JobCounters {
211
221
  summary?: string;
212
222
  }
213
223
  /**
214
- * Credit delta written inside the Tx C transaction (internal-review) when an
224
+ * Credit delta written inside the Tx C transaction when an
215
225
  * inbound payment verifies. Fields mirror what the rails produce in
216
226
  * `payment.ts`; `paidMsatsDelta` is the only required key.
217
227
  */
@@ -230,7 +240,7 @@ interface PaymentCreditDelta {
230
240
  /** Clear the pending nonce + advertised amount after an x402 credit succeeds. */
231
241
  clearPendingX402Binding?: boolean;
232
242
  /**
233
- * Credit this payment funded (internal-review). Only ever set when the mid-job
243
+ * Credit this payment funded. Only ever set when the mid-job
234
244
  * top-up minted a *fresh* implicit credit — a free-then-paid job whose
235
245
  * upfront leg placed no draw. Written set-if-null: a job already bound to a
236
246
  * credit keeps that binding, because the top-up grew its existing draw
@@ -242,12 +252,14 @@ interface PaymentCreditDelta {
242
252
  }
243
253
  /** Atomic side effects applied with an outgoing provider message. */
244
254
  interface AppendOutgoingOptions {
255
+ /** A suspending SDK prompt/payment yield; event-driven messages leave status unchanged. */
256
+ awaitingInput?: boolean;
245
257
  pendingPaymentDelta?: number;
246
258
  pendingMppChallengeIds?: string[];
247
259
  pendingX402Nonce?: string;
248
260
  pendingX402AmountUsdcMicro?: string;
249
261
  /**
250
- * Fiat envelope pinned for this ask (internal-review). Accumulates alongside
262
+ * Fiat envelope pinned for this ask. Accumulates alongside
251
263
  * `pendingPaymentDelta` when the currency matches what's already recorded,
252
264
  * and replaces it when it doesn't — the same shape `pending_payment_msats`
253
265
  * uses, so stacked asks stay summable.
@@ -256,16 +268,16 @@ interface AppendOutgoingOptions {
256
268
  pendingPaymentFiatCurrency?: string;
257
269
  }
258
270
  /**
259
- * Why a job's cumulative ask total can't bound its draw growth (internal-review).
271
+ * Why a job's cumulative ask total can't bound its draw growth.
260
272
  *
261
273
  * - `ask_unpriceable` — an ask the rate provider was down for, or one whose
262
- * fiat figure isn't a safe integer. The only door left after internal-review, and
263
- * deliberately still open: failing the charge to protect a ledger comparison
264
- * would break a payment that doesn't need the rate to be quoted or collected.
274
+ * fiat figure isn't a safe integer. The only door left after and
275
+ * deliberately still open: failing the charge to protect a ledger comparison
276
+ * would break a payment that doesn't need the rate to be quoted or collected.
265
277
  * - `ask_currency_switch` — two asks on one job in different denominations.
266
- * Unreachable through `ctx.requestPayment`, which pins every ask in the job's
267
- * own sticky denomination; kept as the backstop for a record written by an
268
- * older build, and because the accumulator must not silently sum two units.
278
+ * Unreachable through `ctx.requestPayment`, which pins every ask in the job's
279
+ * own sticky denomination; kept as the backstop for a record written by an
280
+ * older build, and because the accumulator must not silently sum two units.
269
281
  */
270
282
  type TopUpCapUnenforcedReason = "ask_unpriceable" | "ask_currency_switch";
271
283
  /**
@@ -278,7 +290,7 @@ interface VerifyAndCreditResult {
278
290
  alreadyVerified: boolean;
279
291
  /**
280
292
  * The credit the job row holds **after** this call — the authoritative
281
- * answer, read back rather than assumed (internal-review).
293
+ * answer, read back rather than assumed.
282
294
  *
283
295
  * {@link PaymentCreditDelta.creditId} is written set-if-null, so a caller
284
296
  * that passes one cannot know whether it won the bind: on a free-then-paid
@@ -313,12 +325,10 @@ interface RequestIdClaimResult {
313
325
  /** True when the durable identity binding existed before this lock acquisition. */
314
326
  replayed: boolean;
315
327
  }
316
- /** Persistent backing store for job records. */
317
328
  interface JobStore {
318
- /** Retrieve a job record by ID. Returns undefined if not found. */
319
329
  get(id: string): Promise<JobRecord | undefined>;
320
330
  /**
321
- * Retrieve the job a settlement reference paid for (internal-review). On the cashu
331
+ * Retrieve the job a settlement reference paid for. On the cashu
322
332
  * accumulator path `paymentTxHash` is the caller's `X-Cashu-Request-Id`, so
323
333
  * this is what makes a retried paid submit idempotent: the replay finds the
324
334
  * job its (already-spent) payment created instead of a bare 409.
@@ -345,9 +355,7 @@ interface JobStore {
345
355
  * durable caller/fingerprint/job binding remains retained.
346
356
  */
347
357
  releaseRequestIdClaim?(claim: RequestIdClaim): Promise<void>;
348
- /** Upsert a job record. */
349
358
  save(record: JobRecord): Promise<void>;
350
- /** Delete a job record. */
351
359
  delete(id: string): Promise<void>;
352
360
  }
353
361
  /** Total-order cursor for terminal job retention scans. */
@@ -356,7 +364,7 @@ interface JobRetentionCursor {
356
364
  id: string;
357
365
  }
358
366
  /**
359
- * JobStore extension for signed job receipts (internal-review). Implemented by both
367
+ * JobStore extension for signed job receipts. Implemented by both
360
368
  * container-tier stores (`MemoryJobStore`, `PostgresJobStore`); the isolate
361
369
  * tier's `IsolateJobStore` deliberately doesn't, which is what keeps the
362
370
  * out-of-scope isolate gap a compile-time fact rather than a runtime surprise.
@@ -385,24 +393,24 @@ interface ReceiptIssuingStore {
385
393
  saveReceipt(jobId: string, receipt: JobReceipt): Promise<JobReceipt | undefined>;
386
394
  }
387
395
  /**
388
- * JobStore extension for cross-machine message streaming + the internal-review
396
+ * JobStore extension for cross-machine message streaming + the
389
397
  * transactional model (Tx A / Tx B / Tx C).
390
398
  *
391
399
  * Tx A — outgoing message + immediate counter consequence (`appendOutgoing`).
392
- * Single tx: server-allocate seq, append `job_messages` row with
393
- * `status='verified'`, bump `pending_payment_msats` for payment-request
394
- * messages, and `pg_notify`.
400
+ * Single tx: server-allocate seq, append `job_messages` row with
401
+ * `status='verified'`, bump `pending_payment_msats` for payment-request
402
+ * messages, and `pg_notify`.
395
403
  *
396
404
  * Tx B — incoming message marked `pending-verification` (`recordInbound`).
397
- * Single tx: server-allocate seq, append `job_messages` row with
398
- * `status='pending-verification'`, and `pg_notify`. External verification
399
- * (Cashu mint, x402 facilitator, MPP server) runs OUTSIDE the tx.
405
+ * Single tx: server-allocate seq, append `job_messages` row with
406
+ * `status='pending-verification'`, and `pg_notify`. External verification
407
+ * (Cashu mint, x402 facilitator, MPP server) runs OUTSIDE the tx.
400
408
  *
401
409
  * Tx C — verification outcome + credit (`verifyAndCredit`). Single tx:
402
- * flip the `job_messages.status` to `'verified'`, bump `paid_msats` /
403
- * clear `pending_payment_msats` per the credit delta, and `pg_notify`.
404
- * Idempotent — a repeat call returns `alreadyVerified: true` without
405
- * re-crediting.
410
+ * flip the `job_messages.status` to `'verified'`, bump `paid_msats` /
411
+ * clear `pending_payment_msats` per the credit delta, and `pg_notify`.
412
+ * Idempotent — a repeat call returns `alreadyVerified: true` without
413
+ * re-crediting.
406
414
  */
407
415
  interface StreamableJobStore extends JobStore {
408
416
  /**
@@ -430,7 +438,7 @@ interface StreamableJobStore extends JobStore {
430
438
  verifyAndCredit(jobId: string, seq: number, credit: PaymentCreditDelta | null): Promise<VerifyAndCreditResult>;
431
439
  /**
432
440
  * Read back what Tx C committed for an inbound message, without opening a
433
- * transaction of its own (internal-review).
441
+ * transaction of its own.
434
442
  *
435
443
  * A `verifyAndCredit` that throws is ambiguous: the error may have been
436
444
  * raised at or after its COMMIT, in which case the write is durable and the
@@ -454,7 +462,7 @@ interface StreamableJobStore extends JobStore {
454
462
  /** Read the counters used by the resolver (status / paid / pending). */
455
463
  getCounters(jobId: string): Promise<JobCounters | undefined>;
456
464
  /**
457
- * Single-execution claim (internal-review). Atomically flip a job from
465
+ * Single-execution claim. Atomically flip a job from
458
466
  * `awaiting-input` to `processing`, returning `true` only for the caller
459
467
  * that won the transition. After a mid-job payment lands cross-machine, the
460
468
  * live original handler (woken via NOTIFY) and a reactivation replay on the
@@ -490,13 +498,13 @@ interface StreamableJobStore extends JobStore {
490
498
  /**
491
499
  * Subscribe to raw NOTIFY events for a job. Fires once per `pg_notify`
492
500
  * delivery; no message decoding. Used by `Context.requestPayment` to
493
- * re-read counters when cross-machine credit lands (internal-review).
501
+ * re-read counters when cross-machine credit lands.
494
502
  */
495
503
  subscribeNotifications(jobId: string, onNotify: () => void): Promise<() => void>;
496
504
  /** Read messages from the `job_messages` table for a job. */
497
505
  getMessages(jobId: string, afterSeq: number): Promise<Message[]>;
498
506
  /**
499
- * Find stale non-terminal jobs (internal-review / internal-review). Two status-aware
507
+ * Find stale non-terminal jobs. Two status-aware
500
508
  * cutoffs (both Unix ms): `processing`/`working` rows older than
501
509
  * `processingThresholdMs` (worker-liveness watchdog — the SDK heartbeats
502
510
  * live workers, so a frozen `last_activity_at` here means the worker died),
@@ -515,7 +523,7 @@ interface StreamableJobStore extends JobStore {
515
523
  /**
516
524
  * Atomically transition a stale job to `terminalStatus` (`failed` for a
517
525
  * dead worker, `cancelled` for an idle caller-wait) and append a final
518
- * `cancel` message in the same transaction (internal-review / internal-review). The
526
+ * `cancel` message in the same transaction. The
519
527
  * `expectedActivityBefore` clause is an optimistic CAS — the flip only
520
528
  * lands when the job is still non-terminal AND `last_activity_at <=
521
529
  * expectedActivityBefore`. Returns true when this caller claimed the
@@ -525,8 +533,8 @@ interface StreamableJobStore extends JobStore {
525
533
  */
526
534
  cancelStaleJob(jobId: string, expectedActivityBefore: number, reason: string, terminalStatus: "failed" | "cancelled"): Promise<boolean>;
527
535
  /**
528
- * Atomically cancel a job from a machine that isn't running its handler
529
- * (internal-review). Same transaction shape as {@link cancelStaleJob} minus the
536
+ * Atomically cancel a job from a machine that isn't running its handler.
537
+ * Same transaction shape as {@link cancelStaleJob} minus the
530
538
  * activity cutoff — the CAS guards only on the job still being non-terminal,
531
539
  * so this replaces the read-then-`save` the DELETE route used to do (a TOCTOU
532
540
  * against a concurrent terminal write).
@@ -541,7 +549,7 @@ interface StreamableJobStore extends JobStore {
541
549
  cancelJob(jobId: string, reason: string): Promise<boolean>;
542
550
  /**
543
551
  * Bump `last_activity_at` to `now` (Unix ms) for the given jobs that are
544
- * still in `processing`/`working` (internal-review worker heartbeat). Called on a
552
+ * still in `processing`/`working`. Called on a
545
553
  * tick by the `JobManager` for its locally-active jobs so a live worker's
546
554
  * row stays fresh and the processing watchdog only fires when the process
547
555
  * has actually died. A no-op for rows that have since gone terminal or
@@ -571,7 +579,7 @@ interface OutgoingMessage {
571
579
  */
572
580
  declare function isStreamableJobStore(store: JobStore): store is StreamableJobStore;
573
581
  /**
574
- * The stale-job reaper surface (internal-review) — the two methods a sweeper needs to
582
+ * The stale-job reaper surface — the two methods a sweeper needs to
575
583
  * find and atomically reap worker-stranded jobs. A strict subset of
576
584
  * `StreamableJobStore`: `MemoryJobStore` and `PostgresJobStore` satisfy it via
577
585
  * the full streamable interface, and the platform's `IsolateJobStore` (a plain
@@ -585,7 +593,6 @@ interface StaleJobReapable {
585
593
  /** See {@link StreamableJobStore.cancelStaleJob}. */
586
594
  cancelStaleJob(jobId: string, expectedActivityBefore: number, reason: string, terminalStatus: "failed" | "cancelled"): Promise<boolean>;
587
595
  }
588
- /** Runtime type guard for StaleJobReapable. */
589
596
  declare function isStaleJobReapable(store: JobStore): store is JobStore & StaleJobReapable;
590
597
 
591
598
  export { type AppendOutgoingOptions as A, type JobRecord as J, type OutgoingMessage as O, type PaymentCreditDelta as P, type ReceiptIssuingStore as R, type StaleJobReapable as S, type TopUpCapUnenforcedReason as T, type VerifyAndCreditResult as V, type JobStatus as a, type JobStore as b, type StreamableJobStore as c, type RequestIdClaim as d, type RequestIdClaimResult as e, type JobRetentionCursor as f, type JobCounters as g, isStreamableJobStore as h, isStaleJobReapable as i };