@fantastic.dev/better-stripe 0.90.0 → 0.91.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 (216) hide show
  1. package/CHANGELOG.md +6 -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 +8 -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 +454 -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/replay.d.ts +3 -0
  29. package/dist/client/billing/renewalAttach/internal/configure/replay.d.ts.map +1 -0
  30. package/dist/client/billing/renewalAttach/internal/configure/replay.js +9 -0
  31. package/dist/client/billing/renewalAttach/internal/configure/replay.js.map +1 -0
  32. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts +39 -0
  33. package/dist/client/billing/renewalAttach/internal/configure/request.d.ts.map +1 -0
  34. package/dist/client/billing/renewalAttach/internal/configure/request.js +245 -0
  35. package/dist/client/billing/renewalAttach/internal/configure/request.js.map +1 -0
  36. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +88 -0
  37. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -0
  38. package/dist/client/billing/renewalAttach/internal/configure/transport.js +289 -0
  39. package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -0
  40. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts +16 -0
  41. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -0
  42. package/dist/client/billing/renewalAttach/internal/observation/actor.js +362 -0
  43. package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -0
  44. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts +9 -0
  45. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -0
  46. package/dist/client/billing/renewalAttach/internal/observation/capture.js +215 -0
  47. package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -0
  48. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts +7 -0
  49. package/dist/client/billing/renewalAttach/internal/observation/profile.d.ts.map +1 -0
  50. package/dist/client/billing/renewalAttach/internal/observation/profile.js +190 -0
  51. package/dist/client/billing/renewalAttach/internal/observation/profile.js.map +1 -0
  52. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts +5 -0
  53. package/dist/client/billing/renewalAttach/internal/observation/record.d.ts.map +1 -0
  54. package/dist/client/billing/renewalAttach/internal/observation/record.js +317 -0
  55. package/dist/client/billing/renewalAttach/internal/observation/record.js.map +1 -0
  56. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +79 -0
  57. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -0
  58. package/dist/client/billing/renewalAttach/internal/observation/types.js +27 -0
  59. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -0
  60. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts +18 -0
  61. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -0
  62. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +229 -0
  63. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -0
  64. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts +163 -0
  65. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.d.ts.map +1 -0
  66. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js +443 -0
  67. package/dist/client/billing/renewalAttach/internal/operations/fixedTransport.js.map +1 -0
  68. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts +8 -0
  69. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -0
  70. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +467 -0
  71. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -0
  72. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts +6 -0
  73. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.d.ts.map +1 -0
  74. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js +59 -0
  75. package/dist/client/billing/renewalAttach/internal/operations/ownedAwait.js.map +1 -0
  76. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts +10 -0
  77. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.d.ts.map +1 -0
  78. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js +48 -0
  79. package/dist/client/billing/renewalAttach/internal/operations/providerFailure.js.map +1 -0
  80. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts +20 -0
  81. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.d.ts.map +1 -0
  82. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js +44 -0
  83. package/dist/client/billing/renewalAttach/internal/operations/sourceOperations.js.map +1 -0
  84. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts +42 -0
  85. package/dist/client/billing/renewalAttach/internal/operations/types.d.ts.map +1 -0
  86. package/dist/client/billing/renewalAttach/internal/operations/types.js +158 -0
  87. package/dist/client/billing/renewalAttach/internal/operations/types.js.map +1 -0
  88. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts +5 -0
  89. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.d.ts.map +1 -0
  90. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js +214 -0
  91. package/dist/client/billing/renewalAttach/internal/preflight/configurePreflight.js.map +1 -0
  92. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts +33 -0
  93. package/dist/client/billing/renewalAttach/internal/preflight/grammar.d.ts.map +1 -0
  94. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +208 -0
  95. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -0
  96. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts +4 -0
  97. package/dist/client/billing/renewalAttach/internal/preflight/output.d.ts.map +1 -0
  98. package/dist/client/billing/renewalAttach/internal/preflight/output.js +25 -0
  99. package/dist/client/billing/renewalAttach/internal/preflight/output.js.map +1 -0
  100. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts +16 -0
  101. package/dist/client/billing/renewalAttach/internal/preflight/record.d.ts.map +1 -0
  102. package/dist/client/billing/renewalAttach/internal/preflight/record.js +93 -0
  103. package/dist/client/billing/renewalAttach/internal/preflight/record.js.map +1 -0
  104. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts +7 -0
  105. package/dist/client/billing/renewalAttach/internal/preflight/relations.d.ts.map +1 -0
  106. package/dist/client/billing/renewalAttach/internal/preflight/relations.js +153 -0
  107. package/dist/client/billing/renewalAttach/internal/preflight/relations.js.map +1 -0
  108. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts +22 -0
  109. package/dist/client/billing/renewalAttach/internal/recovery/material.d.ts.map +1 -0
  110. package/dist/client/billing/renewalAttach/internal/recovery/material.js +221 -0
  111. package/dist/client/billing/renewalAttach/internal/recovery/material.js.map +1 -0
  112. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts +8 -0
  113. package/dist/client/billing/renewalAttach/internal/recovery/output.d.ts.map +1 -0
  114. package/dist/client/billing/renewalAttach/internal/recovery/output.js +101 -0
  115. package/dist/client/billing/renewalAttach/internal/recovery/output.js.map +1 -0
  116. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts +12 -0
  117. package/dist/client/billing/renewalAttach/internal/recovery/record.d.ts.map +1 -0
  118. package/dist/client/billing/renewalAttach/internal/recovery/record.js +186 -0
  119. package/dist/client/billing/renewalAttach/internal/recovery/record.js.map +1 -0
  120. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts +5 -0
  121. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.d.ts.map +1 -0
  122. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js +498 -0
  123. package/dist/client/billing/renewalAttach/internal/recovery/recoveryActor.js.map +1 -0
  124. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts +21 -0
  125. package/dist/client/billing/renewalAttach/internal/recovery/relation.d.ts.map +1 -0
  126. package/dist/client/billing/renewalAttach/internal/recovery/relation.js +119 -0
  127. package/dist/client/billing/renewalAttach/internal/recovery/relation.js.map +1 -0
  128. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  129. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  130. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  131. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  132. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  133. package/dist/component/payoutRelease/queries.d.ts +2 -2
  134. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  135. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  136. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  137. package/docs/renewal-context-reads.md +26 -8
  138. package/docs/renewal-material-observation.md +37 -0
  139. package/docs/renewal-phase-assembly.md +68 -0
  140. package/docs/renewal-raw-acquisition.md +19 -5
  141. package/package.json +1 -1
  142. package/src/client/billing/renewalAttach/internal/acquisition/ownedAcquisition.ts +304 -0
  143. package/src/client/billing/renewalAttach/internal/acquisition/rawAcquisition.ts +2 -160
  144. package/src/client/billing/renewalAttach/internal/acquisition/rawWireSource.ts +15 -3
  145. package/src/client/billing/renewalAttach/internal/configure/actor.ts +575 -0
  146. package/src/client/billing/renewalAttach/internal/configure/capture.ts +117 -0
  147. package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +32 -0
  148. package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +510 -0
  149. package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +207 -0
  150. package/src/client/billing/renewalAttach/internal/configure/output.ts +372 -0
  151. package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +148 -0
  152. package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +173 -0
  153. package/src/client/billing/renewalAttach/internal/configure/replay.ts +13 -0
  154. package/src/client/billing/renewalAttach/internal/configure/request.ts +312 -0
  155. package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +507 -0
  156. package/src/client/billing/renewalAttach/internal/configure/transport.ts +348 -0
  157. package/src/client/billing/renewalAttach/internal/observation/actor.ts +444 -0
  158. package/src/client/billing/renewalAttach/internal/observation/capture.ts +250 -0
  159. package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +220 -0
  160. package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +60 -0
  161. package/src/client/billing/renewalAttach/internal/observation/profile.ts +264 -0
  162. package/src/client/billing/renewalAttach/internal/observation/record.ts +408 -0
  163. package/src/client/billing/renewalAttach/internal/observation/types.ts +102 -0
  164. package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +285 -0
  165. package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +69 -0
  166. package/src/client/billing/renewalAttach/internal/operations/fixedTransport.ts +574 -0
  167. package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +34 -0
  168. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +535 -0
  169. package/src/client/billing/renewalAttach/internal/operations/ownedAwait.ts +63 -0
  170. package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +61 -0
  171. package/src/client/billing/renewalAttach/internal/operations/providerFailure.ts +66 -0
  172. package/src/client/billing/renewalAttach/internal/operations/sourceOperations.ts +50 -0
  173. package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +116 -0
  174. package/src/client/billing/renewalAttach/internal/operations/types.ts +223 -0
  175. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +285 -0
  176. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.ts +258 -0
  177. package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +139 -0
  178. package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +257 -0
  179. package/src/client/billing/renewalAttach/internal/preflight/output.ts +42 -0
  180. package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +82 -0
  181. package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +354 -0
  182. package/src/client/billing/renewalAttach/internal/preflight/record.ts +127 -0
  183. package/src/client/billing/renewalAttach/internal/preflight/relations.ts +209 -0
  184. package/src/client/billing/renewalAttach/internal/recovery/material.ts +311 -0
  185. package/src/client/billing/renewalAttach/internal/recovery/output.ts +136 -0
  186. package/src/client/billing/renewalAttach/internal/recovery/record.ts +230 -0
  187. package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +463 -0
  188. package/src/client/billing/renewalAttach/internal/recovery/recoveryActor.ts +599 -0
  189. package/src/client/billing/renewalAttach/internal/recovery/relation.ts +175 -0
  190. package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +217 -0
  191. package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +226 -0
  192. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +556 -0
  193. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +180 -0
  194. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +144 -0
  195. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +122 -0
  196. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +330 -0
  197. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +139 -0
  198. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +513 -0
  199. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +344 -0
  200. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +278 -0
  201. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +17 -0
  202. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +533 -0
  203. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +125 -0
  204. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +314 -0
  205. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +463 -0
  206. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +515 -0
  207. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +600 -0
  208. package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +211 -0
  209. package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +192 -0
  210. package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +197 -0
  211. package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +269 -0
  212. package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +262 -0
  213. package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +319 -0
  214. package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +94 -0
  215. package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +16 -0
  216. package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +21 -0
@@ -0,0 +1,319 @@
1
+ import assert from "node:assert/strict";
2
+ import { vi } from "vitest";
3
+ import type { ObservationDeclaration } from "./observationDeclarations.js";
4
+ import type { ObservationState } from "./observationObservations.js";
5
+
6
+ export const MISSING_OBSERVATION_PORT =
7
+ "BTS306_REPOSITORY_OBSERVATION_ORCHESTRATION_MISSING";
8
+ /** Exact TEST missing-feature frontier. Never a fabricated successful actor. */
9
+ export function captureMissingObservationPort(state: { targetCalls: number }) {
10
+ assert.equal(arguments.length, 1);
11
+ let consumed = false;
12
+ return Object.freeze({
13
+ async invoke() {
14
+ assert.equal(arguments.length, 0);
15
+ assert.equal(consumed, false);
16
+ consumed = true;
17
+ state.targetCalls++;
18
+ throw Error(MISSING_OBSERVATION_PORT);
19
+ },
20
+ });
21
+ }
22
+ export const deferredLexicalProbe = Object.freeze({
23
+ normalPort:
24
+ "Await actual repository business Source; no copy body exists yet",
25
+ additivePort: "Await exact actor; require full import-only/additive inverses",
26
+ noExportedAuthority: true,
27
+ });
28
+
29
+ /** TEST diagnostics only. Does not inspect/unmask the normalized business error. */
30
+ export async function logObservationFailureFrontier(
31
+ h: import("./observationOperation.js").ObservationFixture,
32
+ ) {
33
+ const descriptor = {
34
+ present: false,
35
+ data: false,
36
+ getter: false,
37
+ setter: false,
38
+ enumerable: false,
39
+ configurable: false,
40
+ inspectionFailed: false,
41
+ };
42
+ try {
43
+ // Same literal resolved module as the actor; inspect metadata without invoking getter.
44
+ const namespace = await import("../material/classifiers.js");
45
+ const own = Object.getOwnPropertyDescriptor(
46
+ namespace,
47
+ "classifyOwnedRetainedInitialAttachment",
48
+ );
49
+ descriptor.present = own !== undefined;
50
+ if (own) {
51
+ descriptor.data = Object.prototype.hasOwnProperty.call(own, "value");
52
+ descriptor.getter = typeof own.get === "function";
53
+ descriptor.setter = typeof own.set === "function";
54
+ descriptor.enumerable = own.enumerable === true;
55
+ descriptor.configurable = own.configurable === true;
56
+ }
57
+ } catch {
58
+ // Diagnostics must not replace the original failed test with an import error.
59
+ descriptor.inspectionFailed = true;
60
+ }
61
+ console.log(
62
+ JSON.stringify({
63
+ kind: "REPOSITORY_OBSERVATION_FAILURE_FRONTIER",
64
+ targetCalls: h.state.targetCalls,
65
+ sourceLoads: h.state.sourceLoads,
66
+ C6Entries: h.state.ownedC6,
67
+ C3Entries: h.state.ownedC3,
68
+ C3Fulfilled: h.state.C3Fulfilled,
69
+ C3Rejected: h.state.C3Rejected,
70
+ recordVerificationEntered: h.state.recordVerificationEntered,
71
+ recordVerificationCompleted: h.state.recordVerificationCompleted,
72
+ observerEntries: h.state.ownedObserver,
73
+ coverageEntries: h.state.coverage,
74
+ C9Entries: h.state.ownedC9,
75
+ readonlyHTTP: h.http.calls.length,
76
+ delegateArgCalls: h.http.argsSeen.length,
77
+ delegateEntriesAfterOwner: h.http.delegateEntriesAfterOwner(),
78
+ originalReadPromises: h.http.originals.length,
79
+ originalAPIPromises: h.state.originals.length,
80
+ registeredAPISideObservers: h.state.pending.length,
81
+ finalReadSampleRecorded: h.http.finalSample() !== null,
82
+ preflightPairLoads: h.prerequisite.state.pairLoads,
83
+ preflightReadonlyCalls: h.prerequisite.state.readonlyCalls,
84
+ appendedRecords: h.prerequisite.deltas().records,
85
+ POSTs: h.prerequisite.deltas().POST,
86
+ classifierExportDescriptor: descriptor,
87
+ operationalAuthority: false,
88
+ }),
89
+ );
90
+ }
91
+
92
+ /** Source fault recipes are selected before constructors; only this new TEST tuple changes. */
93
+ export function controlOperation<
94
+ T extends {
95
+ owner: unknown;
96
+ originAssociation: unknown;
97
+ originalEntry: unknown;
98
+ observationEntry: unknown;
99
+ actualAttachAcknowledgement: unknown;
100
+ record: Pick<
101
+ import("../preflight/grammar.js").PreflightRecord,
102
+ "configuration" | "request"
103
+ >;
104
+ readTransport: unknown;
105
+ },
106
+ >(op: T, d: ObservationDeclaration, s: ObservationState): unknown {
107
+ const mode = d.controlCase;
108
+ if (mode === "G02-owner") return Object.freeze({ ...op, owner: d.foreign });
109
+ if (mode === "G02-origin")
110
+ return Object.freeze({ ...op, originAssociation: d.foreign });
111
+ if (mode === "G02-entry")
112
+ return Object.freeze({ ...op, originalEntry: d.foreign });
113
+ if (mode === "G02-observation-entry")
114
+ return Object.freeze({ ...op, observationEntry: d.foreign });
115
+ if (mode === "G02-ack-clone")
116
+ return Object.freeze({
117
+ ...op,
118
+ actualAttachAcknowledgement: structuredClone(
119
+ op.actualAttachAcknowledgement,
120
+ ),
121
+ });
122
+ if (mode === "G02-tuple-proxy")
123
+ return new Proxy(op, {
124
+ get(target, key, receiver) {
125
+ s.tupleTraps++;
126
+ return Reflect.get(target, key, receiver);
127
+ },
128
+ ownKeys(target) {
129
+ s.tupleTraps++;
130
+ return Reflect.ownKeys(target);
131
+ },
132
+ getPrototypeOf(target) {
133
+ s.tupleTraps++;
134
+ return Reflect.getPrototypeOf(target);
135
+ },
136
+ getOwnPropertyDescriptor(target, key) {
137
+ s.tupleTraps++;
138
+ return Reflect.getOwnPropertyDescriptor(target, key);
139
+ },
140
+ });
141
+ if (mode === "G02-method-getter") {
142
+ const delegate = {};
143
+ Object.defineProperty(delegate, "rawRequest", {
144
+ enumerable: true,
145
+ get() {
146
+ s.methodGetterCalls++;
147
+ throw Error("TEST_UNEXPECTED_UNTRUSTED_GETTER");
148
+ },
149
+ });
150
+ return Object.freeze({ ...op, readTransport: Object.freeze(delegate) });
151
+ }
152
+ if (mode === "G02-optional-undefined")
153
+ return Object.freeze({ ...op, configureAcknowledgement: undefined });
154
+ if (mode === "G02-optional-null")
155
+ return Object.freeze({ ...op, configureAcknowledgement: null });
156
+ if (mode === "G02-optional-present")
157
+ return Object.freeze({
158
+ ...op,
159
+ configureAcknowledgement: Object.freeze({
160
+ declared: "UNBOUND_OPTIONAL_ACK",
161
+ }),
162
+ });
163
+ if (mode === "G03-failure" || mode === "G03-retire") {
164
+ const original = op.record.request.logicalBinding;
165
+ const binding =
166
+ original.slice(0, -1) + (original.endsWith("a") ? "b" : "a");
167
+ return Object.freeze({
168
+ ...op,
169
+ record: Object.freeze({
170
+ ...op.record,
171
+ configuration: { ...op.record.configuration, apiVersion: d.invalidAPI },
172
+ request: { ...op.record.request, logicalBinding: binding },
173
+ }),
174
+ });
175
+ }
176
+ if (mode === "G03-structural") {
177
+ const configuration: Record<string, unknown> = {
178
+ ...op.record.configuration,
179
+ };
180
+ delete configuration.preparation;
181
+ return Object.freeze({ ...op, record: { ...op.record, configuration } });
182
+ }
183
+ return op;
184
+ }
185
+
186
+ /** EMPTY is tested without constructing any initial fixture or client. */
187
+ export async function assertEmptyObservation() {
188
+ vi.resetModules();
189
+ const effects = {
190
+ source: 0,
191
+ owner: 0,
192
+ sample: 0,
193
+ client: 0,
194
+ record: 0,
195
+ api: 0,
196
+ read: 0,
197
+ };
198
+ const poison = (key: keyof typeof effects) => () => {
199
+ effects[key]++;
200
+ throw Error("EMPTY_EFFECT_" + key);
201
+ };
202
+ vi.doMock("../operations/sourceOperations.js", async () => {
203
+ const actual = await vi.importActual<
204
+ typeof import("../operations/sourceOperations.js")
205
+ >("../operations/sourceOperations.js");
206
+ return { ...actual, loadFixedObservationOperation: poison("source") };
207
+ });
208
+ vi.doMock("../originalOwner.js", () => ({
209
+ OWNER: Object.freeze({
210
+ check: poison("owner"),
211
+ sample: poison("sample"),
212
+ subscribe: poison("owner"),
213
+ retire: poison("owner"),
214
+ get basis() {
215
+ return poison("owner")();
216
+ },
217
+ }),
218
+ }));
219
+ vi.doMock("../observation/record.js", async () => {
220
+ const actual = await vi.importActual<
221
+ typeof import("../observation/record.js")
222
+ >("../observation/record.js");
223
+ return { ...actual, captureObservationRecord: poison("record") };
224
+ });
225
+ vi.doMock("../../../renewalV2/index.js", async () => {
226
+ const actual = await vi.importActual<
227
+ typeof import("../../../renewalV2/index.js")
228
+ >("../../../renewalV2/index.js");
229
+ return {
230
+ ...actual,
231
+ projectRenewalConfigurationV2: poison("api"),
232
+ constructRenewalScheduleAttachmentReceiptV2: poison("api"),
233
+ constructRenewalConfigurationReceiptV2: poison("api"),
234
+ };
235
+ });
236
+ vi.doMock("../../../renewalV2/observation.js", async () => {
237
+ const actual = await vi.importActual<
238
+ typeof import("../../../renewalV2/observation.js")
239
+ >("../../../renewalV2/observation.js");
240
+ return { ...actual, inspectRenewalScheduleMaterialV2: poison("api") };
241
+ });
242
+ vi.doMock("../../../../helpers.js", async () => {
243
+ const actual = await vi.importActual<
244
+ typeof import("../../../../helpers.js")
245
+ >("../../../../helpers.js");
246
+ return { ...actual, getStripeClient: poison("client") };
247
+ });
248
+ vi.stubGlobal("fetch", poison("read"));
249
+ try {
250
+ const source = await import("../operations/sourceOperations.js");
251
+ assert.deepEqual(source.COMPILED_OBSERVATION_ENTRIES, []);
252
+ assert(Object.isFrozen(source.COMPILED_OBSERVATION_ENTRIES));
253
+ const actor = await import("../observation/actor.js");
254
+ const handle = actor.captureOwnedRenewalObservationV2();
255
+ assert.deepEqual(await handle.invoke(), {
256
+ status: "not_dispatched",
257
+ reason: "OWNED_OBSERVATION_SOURCE_UNBOUND",
258
+ operationalAuthority: false,
259
+ });
260
+ assert.deepEqual(effects, {
261
+ source: 0,
262
+ owner: 0,
263
+ sample: 0,
264
+ client: 0,
265
+ record: 0,
266
+ api: 0,
267
+ read: 0,
268
+ });
269
+ } finally {
270
+ for (const path of [
271
+ "../operations/sourceOperations.js",
272
+ "../originalOwner.js",
273
+ "../observation/record.js",
274
+ "../../../renewalV2/index.js",
275
+ "../../../renewalV2/observation.js",
276
+ "../../../../helpers.js",
277
+ ])
278
+ vi.doUnmock(path);
279
+ vi.unstubAllGlobals();
280
+ vi.resetModules();
281
+ }
282
+ }
283
+
284
+ /** TEST-only finite latch; no clock or owner replacement. */
285
+ export function observationLatch() {
286
+ const deferred = () => {
287
+ let resolve!: () => void;
288
+ const promise = new Promise<void>((done) => {
289
+ resolve = done;
290
+ });
291
+ return { promise, resolve };
292
+ };
293
+ return { entered: deferred(), release: deferred() };
294
+ }
295
+ export async function retireObservationHeld(
296
+ h: import("./observationOperation.js").ObservationFixture,
297
+ promise: ReturnType<ReturnType<typeof h.capture>["invoke"]>,
298
+ ) {
299
+ const observed = promise.then(
300
+ (value) => ({ ok: true as const, value }),
301
+ (error: unknown) => ({ ok: false as const, error }),
302
+ );
303
+ try {
304
+ const frontier = await Promise.race([
305
+ h.http.hold.entered.promise.then(() => "entered" as const),
306
+ observed.then(() => "settled" as const),
307
+ ]);
308
+ assert.equal(
309
+ frontier,
310
+ "entered",
311
+ "actual held HTTP frontier must precede settlement",
312
+ );
313
+ assert.equal(h.http.originals.length, h.declaration.transport.ordinal);
314
+ h.OWNER.retire();
315
+ } finally {
316
+ h.http.hold.release.resolve();
317
+ }
318
+ return observed;
319
+ }
@@ -0,0 +1,94 @@
1
+ import { vi } from "vitest";
2
+ import { input } from "../../../../../../tests/renewalAggregate/rawRetention.js";
3
+ import { installReadRejection } from "./stockHttp.js";
4
+
5
+ /** TEST-only fixed Source bindings, declared before importing the actual singleton. */
6
+ export async function ownedReadFailureFixture() {
7
+ const api = await import("../../../renewalV2/index.js");
8
+ const preparation: Parameters<
9
+ typeof api.prepareRenewalPriceReplacementV2
10
+ >[0] = input();
11
+ const prepared = await api.prepareRenewalPriceReplacementV2(preparation);
12
+ const firstDispatchedAt = prepared.expected.periodStart + 1;
13
+ const request = await api.prepareRenewalScheduleAttachmentV2({
14
+ prepared,
15
+ apiVersion: "2026-09-30.endive",
16
+ attachKey: "attach:owned-wire-test",
17
+ firstDispatchedAt,
18
+ });
19
+ const wallMs = firstDispatchedAt * 1000,
20
+ ns = BigInt(wallMs) * 1_000_000n;
21
+ const source = Object.freeze({
22
+ clock: Object.freeze({
23
+ basis: Object.freeze({
24
+ startWallMs: wallMs,
25
+ startNs: ns,
26
+ workEndWallMs: wallMs + 180000,
27
+ workEndNs: ns + 180000000000n,
28
+ endWallMs: wallMs + 210000,
29
+ endNs: ns + 210000000000n,
30
+ }),
31
+ sample: () => ({ wallMs, ns }),
32
+ subscribeRetirement: () => () => {},
33
+ }),
34
+ originalPolicy: Object.freeze({
35
+ firstDispatchedAt,
36
+ periodStart: prepared.expected.periodStart,
37
+ periodEnd: prepared.expected.periodEnd,
38
+ }),
39
+ originAssociation: Object.freeze({}),
40
+ });
41
+ const query = String(
42
+ new URLSearchParams(
43
+ ["discounts", "items.data.discounts", "items.data.price"].map((v, i) => [
44
+ "expand[" + i + "]",
45
+ v,
46
+ ]),
47
+ ),
48
+ );
49
+ const path =
50
+ "/v1/subscriptions/" + prepared.expected.subscriptionId + "?" + query;
51
+ const http = installReadRejection("https://api.stripe.com" + path);
52
+ const { getStripeClient } = await import("../../../../helpers.js");
53
+ const client = getStripeClient("sk_test_owned_wire", "2026-09-30.endive", {
54
+ singleAttempt: true,
55
+ });
56
+ vi.doMock("../sourceBindings.js", () => ({
57
+ loadOwnedOriginalSource: () => source,
58
+ loadFixedStockClient: () => client,
59
+ }));
60
+ const { OWNER } = await import("../originalOwner.js");
61
+ const { createSourceStockRawDelegate } =
62
+ await import("../stockRawDelegate.js");
63
+ const delegate = createSourceStockRawDelegate();
64
+ const readPlan = [
65
+ { resource: "subscription", path },
66
+ {
67
+ resource: "price",
68
+ path: "/v1/prices/" + prepared.expected.targetPriceId,
69
+ },
70
+ {
71
+ resource: "customer",
72
+ path: "/v1/customers/" + prepared.providerSnapshot.billingCustomer!.id,
73
+ },
74
+ ].map((row, i) => ({
75
+ ...row,
76
+ ordinal: i + 1,
77
+ method: "GET",
78
+ body: undefined,
79
+ options: { apiVersion: "2026-09-30.endive", maxNetworkRetries: 0 },
80
+ }));
81
+ const transportSource = Object.freeze({
82
+ owner: OWNER,
83
+ request,
84
+ readPlan,
85
+ delegate,
86
+ });
87
+ vi.doMock("../operations/sourceOperations.js", () => ({
88
+ loadOwnedTransportSource: () => transportSource,
89
+ }));
90
+ const { createOwnedTransportWithAttemptCapability } =
91
+ await import("../operations/fixedTransport.js");
92
+ const pair = createOwnedTransportWithAttemptCapability();
93
+ return { prepared, request, OWNER, pair, http, source };
94
+ }
@@ -0,0 +1,16 @@
1
+ import { createSourceRawAcquisition } from "../acquisition/rawAcquisition.js";
2
+ import type { OWNER } from "../originalOwner.js";
3
+ import type { createOwnedTransportWithAttemptCapability } from "../operations/fixedTransport.js";
4
+
5
+ type Pair = ReturnType<typeof createOwnedTransportWithAttemptCapability>;
6
+ /**
7
+ * Missing-wiring baseline ONLY: the current isolated factory selects its own delegate.
8
+ * After a saved meaningful RED, retarget the test's import to the actual Source-bound
9
+ * production implementation with this signature. No assertion or fake token changes.
10
+ */
11
+ export function bindRawAcquisitionFromSource(
12
+ _owner: typeof OWNER,
13
+ _transport: Pair["transport"]["readTransport"],
14
+ ) {
15
+ return createSourceRawAcquisition();
16
+ }
@@ -0,0 +1,21 @@
1
+ import { vi } from "vitest";
2
+
3
+ /** One declared stock SDK GET failure. No real network is used. */
4
+ export function installReadRejection(expectedURL: string) {
5
+ const calls: {
6
+ url: string;
7
+ method: string | undefined;
8
+ redirect: RequestRedirect | undefined;
9
+ }[] = [];
10
+ vi.stubGlobal(
11
+ "fetch",
12
+ async (input: RequestInfo | URL, init?: RequestInit) => {
13
+ const url = String(input);
14
+ calls.push({ url, method: init?.method, redirect: init?.redirect });
15
+ throw Object.assign(Error("SYNTHETIC_OWNED_READ_FAILURE"), {
16
+ code: "ECONNRESET",
17
+ });
18
+ },
19
+ );
20
+ return { calls, expectedURL };
21
+ }