@fantastic.dev/better-stripe 0.90.0 → 0.92.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 (239) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts +41 -0
  4. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.d.ts.map +1 -0
  5. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js +187 -0
  6. package/dist/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.js.map +1 -0
  7. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts +2 -23
  8. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js +1 -112
  10. package/dist/client/billing/renewalAttach/internal/acquisition/rawAcquisition.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts +8 -3
  12. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.d.ts.map +1 -1
  13. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js +1 -0
  14. package/dist/client/billing/renewalAttach/internal/acquisition/rawWireSource.js.map +1 -1
  15. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +1 -1
  16. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +14 -0
  17. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -0
  18. package/dist/client/billing/renewalAttach/internal/configure/actor.js +444 -0
  19. package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -0
  20. package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts +12 -0
  21. package/dist/client/billing/renewalAttach/internal/configure/capture.d.ts.map +1 -0
  22. package/dist/client/billing/renewalAttach/internal/configure/capture.js +99 -0
  23. package/dist/client/billing/renewalAttach/internal/configure/capture.js.map +1 -0
  24. package/dist/client/billing/renewalAttach/internal/configure/output.d.ts +16 -0
  25. package/dist/client/billing/renewalAttach/internal/configure/output.d.ts.map +1 -0
  26. package/dist/client/billing/renewalAttach/internal/configure/output.js +274 -0
  27. package/dist/client/billing/renewalAttach/internal/configure/output.js.map +1 -0
  28. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts +3 -0
  29. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts.map +1 -0
  30. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js +61 -0
  31. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js.map +1 -0
  32. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts +3 -0
  33. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
  34. package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
  35. package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
  36. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
  37. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
  38. package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
  39. package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
  40. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
  41. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
  42. package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
  43. package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
  44. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
  45. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
  46. package/dist/client/billing/renewalAttach/internal/observation/actor.js +383 -0
  47. package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
  48. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
  49. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
  50. package/dist/client/billing/renewalAttach/internal/observation/capture.js +216 -0
  51. package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
  52. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts +5 -0
  53. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts.map +1 -0
  54. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js +11 -0
  55. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js.map +1 -0
  56. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
  57. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
  58. package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
  59. package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
  60. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
  61. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
  62. package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
  63. package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
  64. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +84 -0
  65. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
  66. package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
  67. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
  68. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
  69. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
  70. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
  71. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
  72. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
  73. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
  74. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
  75. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
  76. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
  77. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
  78. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
  79. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
  80. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
  81. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
  82. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
  83. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
  84. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
  85. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
  86. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
  87. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
  88. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
  89. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
  90. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
  91. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
  92. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
  93. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
  94. package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
  95. package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
  96. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
  97. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
  98. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
  99. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
  100. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
  101. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
  102. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
  103. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
  104. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
  105. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
  106. package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
  107. package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
  108. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
  109. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
  110. package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
  111. package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
  112. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
  113. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
  114. package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
  115. package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
  116. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
  117. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
  118. package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
  119. package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
  120. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
  121. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
  122. package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
  123. package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
  124. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
  125. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
  126. package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
  127. package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
  128. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
  129. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
  130. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
  131. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
  132. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
  133. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
  134. package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
  135. package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
  136. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  137. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
  138. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  139. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  140. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  141. package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
  142. package/docs/renewal-context-reads.md +26 -8
  143. package/docs/renewal-material-observation.md +58 -0
  144. package/docs/renewal-phase-assembly.md +68 -0
  145. package/docs/renewal-raw-acquisition.md +19 -5
  146. package/package.json +1 -1
  147. package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
  148. package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
  149. package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
  150. package/src/client/billing/renewalAttach/internal/configure/actor.ts +586 -0
  151. package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
  152. package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
  153. package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
  154. package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
  155. package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
  156. package/src/client/billing/renewalAttach/internal/configure/ownedContinuation.ts +56 -0
  157. package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
  158. package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
  159. package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
  160. package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
  161. package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
  162. package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
  163. package/src/client/billing/renewalAttach/internal/observation/actor.ts +487 -0
  164. package/src/client/billing/renewalAttach/internal/observation/capture.ts +251 -0
  165. package/src/client/billing/renewalAttach/internal/observation/configureAcknowledgement.ts +20 -0
  166. package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
  167. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +36 -0
  168. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +48 -0
  169. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +44 -0
  170. package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +34 -0
  171. package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
  172. package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
  173. package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
  174. package/src/client/billing/renewalAttach/internal/observation/types.ts +107 -0
  175. package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
  176. package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
  177. package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
  178. package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
  179. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
  180. package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
  181. package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
  182. package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
  183. package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
  184. package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
  185. package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
  186. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
  187. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
  188. package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
  189. package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
  190. package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
  191. package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
  192. package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
  193. package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
  194. package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
  195. package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
  196. package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
  197. package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
  198. package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
  199. package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
  200. package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
  201. package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
  202. package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
  203. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
  204. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
  205. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
  206. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
  207. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
  208. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
  209. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
  210. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
  211. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
  212. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
  213. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +537 -0
  214. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
  215. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +325 -0
  216. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +38 -0
  217. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +471 -0
  218. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
  219. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +587 -0
  220. package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
  221. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +115 -0
  222. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +141 -0
  223. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +74 -0
  224. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +79 -0
  225. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +207 -0
  226. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +494 -0
  227. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +452 -0
  228. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +88 -0
  229. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +170 -0
  230. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +99 -0
  231. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +411 -0
  232. package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
  233. package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
  234. package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
  235. package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
  236. package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
  237. package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
  238. package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
  239. package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
@@ -0,0 +1,207 @@
1
+ import assert from "node:assert/strict";
2
+ import { vi } from "vitest";
3
+ import { data } from "./configurePreflightControls.js";
4
+ import type { ConfigureACKLifecycleDeclaration } from "./observationConfigureACKLifecycleDeclarations.js";
5
+
6
+ /** TEST-only fault observers. No History, map, returned-flag setter or Source registrar. */
7
+ export function installConfigureACKLifecycleInstrumentation(
8
+ d: ConfigureACKLifecycleDeclaration,
9
+ ) {
10
+ const pending: Promise<unknown>[] = [];
11
+ const state = {
12
+ admitted: null as unknown,
13
+ admissions: 0,
14
+ outputAborts: 0,
15
+ receiptCalls: 0,
16
+ receiptFulfilled: 0,
17
+ receiptRejected: 0,
18
+ wrongACK: 0,
19
+ retirements: 0,
20
+ factoryPairs: 0,
21
+ sourceBindingTrue: 0,
22
+ reservationTrue: 0,
23
+ sameReadTransport: false,
24
+ discardEntered: 0,
25
+ discardCompleted: 0,
26
+ };
27
+ vi.doMock("../configure/output.js", async () => {
28
+ const actual = await vi.importActual<
29
+ typeof import("../configure/output.js")
30
+ >("../configure/output.js");
31
+ return {
32
+ ...actual,
33
+ admitConfigureACK(
34
+ this: unknown,
35
+ ...args: Parameters<typeof actual.admitConfigureACK>
36
+ ) {
37
+ const result = Reflect.apply(
38
+ actual.admitConfigureACK,
39
+ this,
40
+ args,
41
+ ) as ReturnType<typeof actual.admitConfigureACK>;
42
+ state.admissions++;
43
+ state.admitted = result;
44
+ if (d.controlCase === "L01-output-abort") {
45
+ state.outputAborts++;
46
+ throw Error(d.faults.output);
47
+ }
48
+ return result;
49
+ },
50
+ };
51
+ });
52
+ vi.doMock("../c10/configureEvents.js", async () => {
53
+ const actual = await vi.importActual<
54
+ typeof import("../c10/configureEvents.js")
55
+ >("../c10/configureEvents.js");
56
+ const { OWNER } = await import("../originalOwner.js");
57
+ return {
58
+ ...actual,
59
+ createConfigureEventCompiler(
60
+ this: unknown,
61
+ ...args: Parameters<typeof actual.createConfigureEventCompiler>
62
+ ) {
63
+ let selected = args;
64
+ if (d.controlCase === "L02-receipt-ACK-fault") {
65
+ const options = data(args[1]);
66
+ const send = options.send;
67
+ assert(typeof send === "function");
68
+ const faulted = {
69
+ ...options,
70
+ send(record: unknown, acknowledge: (value: unknown) => void) {
71
+ const receipt = data(record).sequence === 3;
72
+ const ack = receipt
73
+ ? (value: unknown) => {
74
+ state.wrongACK++;
75
+ acknowledge({ ...data(value), binding: "wrong" });
76
+ }
77
+ : acknowledge;
78
+ return Reflect.apply(send, options, [record, ack]);
79
+ },
80
+ };
81
+ selected = [args[0], faulted];
82
+ }
83
+ const compiler = Reflect.apply(
84
+ actual.createConfigureEventCompiler,
85
+ this,
86
+ selected,
87
+ ) as ReturnType<typeof actual.createConfigureEventCompiler>;
88
+ const forwarded = {
89
+ ...compiler,
90
+ dispatch(...values: Parameters<typeof compiler.dispatch>) {
91
+ return Reflect.apply(
92
+ compiler.dispatch,
93
+ compiler,
94
+ values,
95
+ ) as ReturnType<typeof compiler.dispatch>;
96
+ },
97
+ response(...values: Parameters<typeof compiler.response>) {
98
+ return Reflect.apply(
99
+ compiler.response,
100
+ compiler,
101
+ values,
102
+ ) as ReturnType<typeof compiler.response>;
103
+ },
104
+ receipt(...values: Parameters<typeof compiler.receipt>) {
105
+ state.receiptCalls++;
106
+ const promise = Reflect.apply(
107
+ compiler.receipt,
108
+ compiler,
109
+ values,
110
+ ) as ReturnType<typeof compiler.receipt>;
111
+ pending.push(
112
+ promise.then(
113
+ () => {
114
+ state.receiptFulfilled++;
115
+ if (d.controlCase === "L06-receipt-ACK-retire") {
116
+ state.retirements++;
117
+ OWNER.retire();
118
+ }
119
+ },
120
+ () => {
121
+ state.receiptRejected++;
122
+ },
123
+ ),
124
+ );
125
+ return promise;
126
+ },
127
+ };
128
+ return Object.freeze(forwarded);
129
+ },
130
+ };
131
+ });
132
+ if (d.controlCase === "L03-final-discard-abort")
133
+ vi.doMock("../configure/transport.js", async () => {
134
+ const actual = await vi.importActual<
135
+ typeof import("../configure/transport.js")
136
+ >("../configure/transport.js");
137
+ return {
138
+ ...actual,
139
+ createConfigureWriteTransport(
140
+ this: unknown,
141
+ ...args: Parameters<typeof actual.createConfigureWriteTransport>
142
+ ) {
143
+ const pair = Reflect.apply(
144
+ actual.createConfigureWriteTransport,
145
+ this,
146
+ args,
147
+ ) as ReturnType<typeof actual.createConfigureWriteTransport>;
148
+ state.factoryPairs++;
149
+ const capability = Object.fromEntries(
150
+ Object.entries(pair.capability).map(([key, method]) => [
151
+ key,
152
+ (...values: unknown[]) => {
153
+ if (key !== "discardFulfilledQuarantine") {
154
+ const result: unknown = Reflect.apply(
155
+ method,
156
+ pair.capability,
157
+ values,
158
+ );
159
+ if (key === "assertSourceOperationBinding" && result === true)
160
+ state.sourceBindingTrue++;
161
+ if (key === "reserveAcquisition" && result === true)
162
+ state.reservationTrue++;
163
+ return result;
164
+ }
165
+ state.discardEntered++;
166
+ assert.equal(values.length, 0);
167
+ const result: unknown = Reflect.apply(
168
+ method,
169
+ pair.capability,
170
+ values,
171
+ );
172
+ assert.equal(result, undefined);
173
+ state.discardCompleted++;
174
+ throw Error(d.faults.discard);
175
+ },
176
+ ]),
177
+ ) as typeof pair.capability;
178
+ const wrapped = Object.freeze({
179
+ ...pair,
180
+ capability: Object.freeze(capability),
181
+ });
182
+ state.sameReadTransport =
183
+ wrapped.transport === pair.transport &&
184
+ wrapped.transport.readTransport === pair.transport.readTransport;
185
+ return wrapped;
186
+ },
187
+ };
188
+ });
189
+ return {
190
+ state,
191
+ pending,
192
+ async join() {
193
+ await Promise.all(pending);
194
+ },
195
+ cleanup() {
196
+ for (const path of [
197
+ "../configure/output.js",
198
+ "../c10/configureEvents.js",
199
+ "../configure/transport.js",
200
+ "../configure/actor.js",
201
+ "../observation/record.js",
202
+ "../../../renewalV2/observation.js",
203
+ ])
204
+ vi.doUnmock(path);
205
+ },
206
+ };
207
+ }
@@ -0,0 +1,494 @@
1
+ import assert from "node:assert/strict";
2
+ import { vi } from "vitest";
3
+ import * as api from "../../../renewalV2/index.js";
4
+ import * as observer from "../../../renewalV2/observation.js";
5
+ import { configureWriteFixture } from "./configureWriteOperation.js";
6
+ import {
7
+ assertConfigureACK,
8
+ assertProviderFailure,
9
+ } from "./configureWriteAssertions.js";
10
+ import { assertFit } from "./configurePreflightAssertions.js";
11
+ import { data } from "./configurePreflightControls.js";
12
+ import {
13
+ declareConfigureACKLifecycle,
14
+ type ConfigureACKLifecycleCase,
15
+ } from "./observationConfigureACKLifecycleDeclarations.js";
16
+ import { installConfigureACKLifecycleInstrumentation } from "./observationConfigureACKLifecycleInstrumentation.js";
17
+
18
+ /** Negative lifecycle chain. Oracle/admission DATA is never relabeled a returned ACK. */
19
+ export async function configureACKLifecycleFixture(
20
+ controlCase: ConfigureACKLifecycleCase,
21
+ ) {
22
+ const declaration = declareConfigureACKLifecycle(controlCase);
23
+ const instruments = installConfigureACKLifecycleInstrumentation(declaration);
24
+ const pending: Promise<unknown>[] = [];
25
+ let writer: Awaited<ReturnType<typeof configureWriteFixture>> | undefined;
26
+ let originalWriter: Promise<unknown> | undefined;
27
+ let settled = false;
28
+ let lastC6: unknown = null;
29
+ const counters = {
30
+ source: 0,
31
+ target: 0,
32
+ captureEntered: 0,
33
+ captureCompleted: 0,
34
+ C6: 0,
35
+ C3: 0,
36
+ C9: 0,
37
+ lookup: 0,
38
+ lookupReturned: 0,
39
+ lookupThrew: 0,
40
+ observer: 0,
41
+ coverage: 0,
42
+ delegateEntered: 0,
43
+ };
44
+ const calls: { method: string; path: string }[] = [];
45
+ const promises: Promise<unknown>[] = [];
46
+ const clean = async () => {
47
+ writer?.writeGates.release("post");
48
+ try {
49
+ if (originalWriter) await originalWriter.catch(() => {});
50
+ await Promise.all(pending);
51
+ await instruments.join();
52
+ } finally {
53
+ try {
54
+ if (writer) await writer.cleanup();
55
+ } finally {
56
+ instruments.cleanup();
57
+ }
58
+ }
59
+ };
60
+ try {
61
+ writer = await configureWriteFixture(declaration.writerMode);
62
+ const w = writer;
63
+ assert.deepEqual(w.write, declaration.writer);
64
+ assert.equal(
65
+ instruments.state.admissions,
66
+ 0,
67
+ "fixture oracle is not operation admission",
68
+ );
69
+ const basis = w.OWNER.basis;
70
+ const savedOriginalRecord = structuredClone(w.expectedRecord);
71
+ const savedOracleACK = structuredClone(w.expectedACK);
72
+ const actualOperation = w.fixedAOperation();
73
+ originalWriter = w.captureWriter().invoke();
74
+ const observedWriter = originalWriter.then(
75
+ (value) => {
76
+ settled = true;
77
+ return { ok: true as const, value };
78
+ },
79
+ (error: unknown) => {
80
+ settled = true;
81
+ return { ok: false as const, error };
82
+ },
83
+ );
84
+ pending.push(observedWriter.then(() => {}));
85
+ let publicWriterACK: unknown = null;
86
+ if (controlCase === "L04-POST-pending") {
87
+ await w.writeGates.entered("post", originalWriter);
88
+ assert.equal(settled, false);
89
+ } else {
90
+ const outcome = await observedWriter;
91
+ if (controlCase === "L05-POST-unknown") {
92
+ assert.equal(outcome.ok, false);
93
+ if (!outcome.ok) assertProviderFailure(w, outcome.error, "post");
94
+ } else {
95
+ assert.equal(outcome.ok, true);
96
+ if (!outcome.ok) assert.fail("EXPECTED_FIXED_WRITER_OUTCOME");
97
+ if (controlCase === "L07-C6Failure-priority") {
98
+ publicWriterACK = outcome.value;
99
+ assertConfigureACK(w, publicWriterACK);
100
+ assert.equal(publicWriterACK, instruments.state.admitted);
101
+ } else assert.deepEqual(outcome.value, declaration.expectedUnknown);
102
+ }
103
+ }
104
+ const writerBefore = Object.freeze({
105
+ records: w.writeState.records.length,
106
+ POST: w.writeState.calls.filter((row) => row.method === "POST").length,
107
+ C9: w.writeState.explicitC9,
108
+ });
109
+ assert.deepEqual(writerBefore, declaration.expectedWriterAtRefusal);
110
+ assert.equal(
111
+ w.writeState.calls.length,
112
+ 5 + w.write.currentBundle.couponReads.length,
113
+ );
114
+ const setupBefore = Object.freeze({
115
+ records: w.state.records.length,
116
+ POST: w.state.calls.filter((row) => row.method === "POST").length,
117
+ });
118
+ assert.deepEqual(setupBefore, { records: 3, POST: 1 });
119
+ const stages = instruments.state;
120
+ if (controlCase === "L01-output-abort") {
121
+ assert.equal(stages.admissions, 1);
122
+ assert.equal(stages.outputAborts, 1);
123
+ assert.equal(stages.receiptCalls, 0);
124
+ }
125
+ if (controlCase === "L02-receipt-ACK-fault") {
126
+ assert.equal(stages.admissions, 1);
127
+ assert.equal(stages.wrongACK, 1);
128
+ assert.equal(stages.receiptCalls, 1);
129
+ assert.equal(stages.receiptRejected, 1);
130
+ assert.equal(stages.receiptFulfilled, 0);
131
+ }
132
+ if (controlCase === "L03-final-discard-abort") {
133
+ assert.equal(stages.admissions, 1);
134
+ assert.equal(stages.factoryPairs, 1);
135
+ assert.equal(stages.sourceBindingTrue, 1);
136
+ assert.equal(stages.reservationTrue, 1);
137
+ assert.equal(stages.sameReadTransport, true);
138
+ assert.equal(stages.receiptCalls, 1);
139
+ assert.equal(stages.receiptFulfilled, 1);
140
+ assert.equal(stages.receiptRejected, 0);
141
+ assert.equal(stages.discardEntered, 1);
142
+ assert.equal(stages.discardCompleted, 1);
143
+ assert.equal(w.OWNER.check().retired, false);
144
+ }
145
+ if (controlCase === "L06-receipt-ACK-retire") {
146
+ assert.equal(stages.admissions, 1);
147
+ assert.equal(stages.receiptFulfilled, 1);
148
+ assert.equal(stages.retirements, 1);
149
+ assert.throws(() => w.OWNER.basis, { message: "ORIGINAL_OWNER_STOP" });
150
+ }
151
+ if (
152
+ controlCase === "L04-POST-pending" ||
153
+ controlCase === "L05-POST-unknown"
154
+ ) {
155
+ assert.equal(stages.admissions, 0);
156
+ assert.equal(stages.receiptCalls, 0);
157
+ }
158
+ const candidate =
159
+ controlCase === "L07-C6Failure-priority"
160
+ ? publicWriterACK
161
+ : declaration.known
162
+ ? stages.admitted
163
+ : w.expectedACK;
164
+ assert(candidate !== null && typeof candidate === "object");
165
+ assert.deepEqual(candidate, w.expectedACK);
166
+ assert(Object.isFrozen(candidate));
167
+ const candidateRecord =
168
+ controlCase === "L07-C6Failure-priority"
169
+ ? Object.freeze({
170
+ ...w.expectedRecord,
171
+ configuration: Object.freeze({
172
+ ...w.expectedRecord.configuration,
173
+ apiVersion: declaration.invalidAPI,
174
+ }),
175
+ })
176
+ : w.expectedRecord;
177
+ let directFailure: unknown = null;
178
+ const realRecord = await vi.importActual<
179
+ typeof import("../observation/record.js")
180
+ >("../observation/record.js");
181
+ if (controlCase === "L07-C6Failure-priority") {
182
+ realRecord.captureObservationRecord(candidateRecord);
183
+ directFailure = await Reflect.apply(
184
+ api.projectRenewalConfigurationV2,
185
+ api,
186
+ [candidateRecord.configuration],
187
+ );
188
+ const failure = data(directFailure);
189
+ assert.equal(failure.status, "conflict");
190
+ assert.equal(failure.reason, declaration.expectedC6FailureReason);
191
+ assert.notEqual(candidateRecord, w.expectedRecord);
192
+ assert.deepEqual(w.expectedRecord, savedOriginalRecord);
193
+ }
194
+ const prerequisiteMetrics = {
195
+ originalRecord: assertFit(w.expectedRecord),
196
+ candidateRecord: assertFit(candidateRecord),
197
+ candidateDATA: assertFit(candidate),
198
+ };
199
+ const source = await import("../operations/sourceOperations.js");
200
+ const originalEntry = actualOperation.originalEntry;
201
+ const origin = actualOperation.originAssociation;
202
+ assert.equal(actualOperation.owner, w.OWNER);
203
+ assert.equal(
204
+ actualOperation.actualAttachAcknowledgement,
205
+ w.acknowledgement,
206
+ );
207
+ assert.equal(source.ORIGINAL_ORIGIN_ASSOCIATION, origin);
208
+ assert(source.COMPILED_INITIAL_ENTRIES.includes(originalEntry));
209
+ const readonly = declaration.readonly;
210
+ vi.stubGlobal("fetch", async (input: unknown, init: RequestInit) => {
211
+ const row = readonly.rows[calls.length];
212
+ assert(row);
213
+ const url = new URL(String(input));
214
+ assert.equal(url.origin, "https://api.stripe.com");
215
+ assert.equal(url.pathname + url.search, row.path);
216
+ assert.equal(init.method, "GET");
217
+ assert.equal(init.body, undefined);
218
+ assert.equal(init.redirect, "error");
219
+ const headers = new Headers(init.headers);
220
+ assert.equal(
221
+ headers.get("stripe-version"),
222
+ declaration.writer.baseline.apiVersion,
223
+ );
224
+ assert.equal(headers.get("stripe-account"), null);
225
+ calls.push({ method: "GET", path: row.path });
226
+ return new Response(JSON.stringify(row.body), {
227
+ status: 200,
228
+ headers: {
229
+ "content-type": "application/json",
230
+ "request-id": "req_SYNTHETIC_LIFECYCLE",
231
+ },
232
+ });
233
+ });
234
+ const readTransport = Object.freeze({
235
+ rawRequest(...args: unknown[]) {
236
+ counters.delegateEntered++;
237
+ w.OWNER.check();
238
+ const row = readonly.rows[promises.length];
239
+ assert(row);
240
+ assert.deepEqual(args, ["GET", row.path, undefined, row.options]);
241
+ const promise = w.readFixedA(...args);
242
+ promises.push(promise);
243
+ pending.push(
244
+ promise.then(
245
+ () => {},
246
+ () => {},
247
+ ),
248
+ );
249
+ return promise;
250
+ },
251
+ });
252
+ const observationEntry = Object.freeze({
253
+ originalEntry,
254
+ coversObservation() {
255
+ counters.coverage++;
256
+ throw Error("LIFECYCLE_COVERAGE_MUST_NOT_BE_REACHED");
257
+ },
258
+ });
259
+ const operation = Object.freeze({
260
+ owner: w.OWNER,
261
+ originAssociation: origin,
262
+ originalEntry,
263
+ observationEntry,
264
+ record: candidateRecord,
265
+ actualAttachAcknowledgement: w.acknowledgement,
266
+ readTransport,
267
+ configureOperation: actualOperation,
268
+ configureAcknowledgement: candidate,
269
+ });
270
+ const writerActor = await import("../configure/actor.js");
271
+ const lookup = writerActor.readOwnedConfigureAcknowledgement;
272
+ vi.doMock("../configure/actor.js", () => ({
273
+ ...writerActor,
274
+ readOwnedConfigureAcknowledgement(
275
+ this: unknown,
276
+ ...args: Parameters<typeof lookup>
277
+ ) {
278
+ counters.lookup++;
279
+ try {
280
+ const result = Reflect.apply(lookup, this, args) as ReturnType<
281
+ typeof lookup
282
+ >;
283
+ counters.lookupReturned++;
284
+ return result;
285
+ } catch (error) {
286
+ counters.lookupThrew++;
287
+ throw error;
288
+ }
289
+ },
290
+ }));
291
+ vi.doMock("../observation/record.js", () => ({
292
+ ...realRecord,
293
+ captureObservationRecord(
294
+ this: unknown,
295
+ ...args: Parameters<typeof realRecord.captureObservationRecord>
296
+ ) {
297
+ counters.captureEntered++;
298
+ const result = Reflect.apply(
299
+ realRecord.captureObservationRecord,
300
+ this,
301
+ args,
302
+ ) as ReturnType<typeof realRecord.captureObservationRecord>;
303
+ counters.captureCompleted++;
304
+ return result;
305
+ },
306
+ }));
307
+ vi.doMock("../operations/sourceOperations.js", () => ({
308
+ ...source,
309
+ COMPILED_OBSERVATION_ENTRIES: Object.freeze([observationEntry]),
310
+ loadFixedObservationOperation() {
311
+ assert.equal(arguments.length, 0);
312
+ counters.source++;
313
+ return operation;
314
+ },
315
+ }));
316
+ const keep = <T>(promise: Promise<T>) => {
317
+ pending.push(
318
+ promise.then(
319
+ () => {},
320
+ () => {},
321
+ ),
322
+ );
323
+ return promise;
324
+ };
325
+ vi.doMock("../../../renewalV2/index.js", () => ({
326
+ ...api,
327
+ projectRenewalConfigurationV2(
328
+ ...args: Parameters<typeof api.projectRenewalConfigurationV2>
329
+ ) {
330
+ counters.C6++;
331
+ const promise = Reflect.apply(
332
+ api.projectRenewalConfigurationV2,
333
+ api,
334
+ args,
335
+ ) as ReturnType<typeof api.projectRenewalConfigurationV2>;
336
+ pending.push(
337
+ promise.then(
338
+ (value) => {
339
+ lastC6 = value;
340
+ },
341
+ () => {},
342
+ ),
343
+ );
344
+ return keep(promise);
345
+ },
346
+ constructRenewalScheduleAttachmentReceiptV2(
347
+ ...args: Parameters<
348
+ typeof api.constructRenewalScheduleAttachmentReceiptV2
349
+ >
350
+ ) {
351
+ counters.C3++;
352
+ return keep(
353
+ Reflect.apply(
354
+ api.constructRenewalScheduleAttachmentReceiptV2,
355
+ api,
356
+ args,
357
+ ) as ReturnType<
358
+ typeof api.constructRenewalScheduleAttachmentReceiptV2
359
+ >,
360
+ );
361
+ },
362
+ constructRenewalConfigurationReceiptV2(
363
+ ...args: Parameters<typeof api.constructRenewalConfigurationReceiptV2>
364
+ ) {
365
+ counters.C9++;
366
+ return keep(
367
+ Reflect.apply(
368
+ api.constructRenewalConfigurationReceiptV2,
369
+ api,
370
+ args,
371
+ ) as ReturnType<typeof api.constructRenewalConfigurationReceiptV2>,
372
+ );
373
+ },
374
+ }));
375
+ vi.doMock("../../../renewalV2/observation.js", () => ({
376
+ ...observer,
377
+ inspectRenewalScheduleMaterialV2(
378
+ ...args: Parameters<typeof observer.inspectRenewalScheduleMaterialV2>
379
+ ) {
380
+ counters.observer++;
381
+ return keep(
382
+ Reflect.apply(
383
+ observer.inspectRenewalScheduleMaterialV2,
384
+ observer,
385
+ args,
386
+ ) as ReturnType<typeof observer.inspectRenewalScheduleMaterialV2>,
387
+ );
388
+ },
389
+ }));
390
+ const actor = await import("../observation/actor.js");
391
+ assert.equal(calls.length, 0);
392
+ assert.equal(promises.length, 0);
393
+ assert.deepEqual(counters, {
394
+ source: 0,
395
+ target: 0,
396
+ captureEntered: 0,
397
+ captureCompleted: 0,
398
+ C6: 0,
399
+ C3: 0,
400
+ C9: 0,
401
+ lookup: 0,
402
+ lookupReturned: 0,
403
+ lookupThrew: 0,
404
+ observer: 0,
405
+ coverage: 0,
406
+ delegateEntered: 0,
407
+ });
408
+ console.log(
409
+ JSON.stringify({
410
+ kind: "OPTIONAL_ACK_LIFECYCLE_PREREQUISITES",
411
+ controlCase,
412
+ actualInitialACK: true,
413
+ actualOwnedPreflight: true,
414
+ operationC9Known:
415
+ declaration.known || controlCase === "L07-C6Failure-priority",
416
+ operationReturnedACK: controlCase === "L07-C6Failure-priority",
417
+ candidateKind: declaration.candidateKind,
418
+ writerBefore,
419
+ setupBefore,
420
+ stageMarkers: {
421
+ admissions: stages.admissions,
422
+ receiptFulfilled: stages.receiptFulfilled,
423
+ receiptRejected: stages.receiptRejected,
424
+ wrongACK: stages.wrongACK,
425
+ sourceBindingTrue: stages.sourceBindingTrue,
426
+ discardCompleted: stages.discardCompleted,
427
+ },
428
+ prerequisiteMetrics,
429
+ operationalAuthority: false,
430
+ }),
431
+ );
432
+ return {
433
+ declaration,
434
+ writer: w,
435
+ instruments,
436
+ writerBefore,
437
+ setupBefore,
438
+ basis,
439
+ savedOriginalRecord,
440
+ savedOracleACK,
441
+ operation,
442
+ directFailure,
443
+ counters,
444
+ calls,
445
+ promises,
446
+ lastC6: () => lastC6,
447
+ writerSettled: () => settled,
448
+ capture() {
449
+ const handle = actor.captureOwnedRenewalObservationV2();
450
+ return Object.freeze({
451
+ invoke() {
452
+ counters.target++;
453
+ const promise = Reflect.apply(
454
+ handle.invoke,
455
+ handle,
456
+ [],
457
+ ) as ReturnType<typeof handle.invoke>;
458
+ pending.push(
459
+ promise.then(
460
+ () => {},
461
+ () => {},
462
+ ),
463
+ );
464
+ return promise;
465
+ },
466
+ });
467
+ },
468
+ async finishPendingWriter() {
469
+ assert.equal(controlCase, "L04-POST-pending");
470
+ w.writeGates.release("post");
471
+ const late = await observedWriter;
472
+ assert.equal(late.ok, true);
473
+ if (late.ok) assertConfigureACK(w, late.value);
474
+ console.log(
475
+ JSON.stringify({
476
+ kind: "LIFECYCLE_POST_RELEASE_JOIN",
477
+ operationReturnedACKNow: true,
478
+ writerC9: w.writeState.explicitC9,
479
+ writerRecords: w.writeState.records.length,
480
+ earlierRefusalHadReturnedACK: false,
481
+ operationalAuthority: false,
482
+ }),
483
+ );
484
+ },
485
+ cleanup: clean,
486
+ };
487
+ } catch (error) {
488
+ try {
489
+ await clean();
490
+ } finally {
491
+ throw error;
492
+ }
493
+ }
494
+ }