@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,32 @@
1
+ import { it } from "vitest";
2
+ import type { ConfigureWriteFixture } from "../test-fixtures/configureWriteOperation.js";
3
+ import { assertConfigureACK } from "../test-fixtures/configureWriteAssertions.js";
4
+ import { writerFrontierDiagnostics } from "../test-fixtures/configureWriteObservations.js";
5
+ import { writeCases } from "../test-fixtures/configureWriteDeclarations.js";
6
+
7
+ for (const name of writeCases.dispatch)
8
+ it(
9
+ "bounded configure writer acknowledges complete raw response: " + name,
10
+ async () => {
11
+ const diagnostic = writerFrontierDiagnostics();
12
+ let h: ConfigureWriteFixture | undefined;
13
+ try {
14
+ const { configureWriteFixture } =
15
+ await import("../test-fixtures/configureWriteOperation.js");
16
+ h = await configureWriteFixture(name);
17
+ assertConfigureACK(h, await h.captureWriter().invoke());
18
+ } catch (error) {
19
+ try {
20
+ diagnostic.log(h?.writeState, h?.state.readerBindings);
21
+ } finally {
22
+ throw error;
23
+ }
24
+ } finally {
25
+ try {
26
+ if (h) await h.cleanup();
27
+ } finally {
28
+ await diagnostic.cleanup();
29
+ }
30
+ }
31
+ },
32
+ );
@@ -0,0 +1,510 @@
1
+ import assert from "node:assert/strict";
2
+ import { it, vi } from "vitest";
3
+ import { configureWriteFixture } from "../test-fixtures/configureWriteOperation.js";
4
+ import { limitCounterexample } from "../test-fixtures/configureWriteDeclarations.js";
5
+ import { ackSlots } from "../test-fixtures/configureWriteAssertions.js";
6
+ import { data } from "../test-fixtures/configurePreflightControls.js";
7
+ import {
8
+ assertFit,
9
+ metrics,
10
+ } from "../test-fixtures/configurePreflightAssertions.js";
11
+
12
+ for (const name of ["ack", "defaults-null", "defaults-object"] as const)
13
+ it(
14
+ "configure ACK DATA admits complete actual18/19 slots: " + name,
15
+ async () => {
16
+ const h = await configureWriteFixture(name);
17
+ try {
18
+ const { admitConfigureACK } = await import("./output.js");
19
+ const out: unknown = Reflect.apply(admitConfigureACK, undefined, [
20
+ h.expectedRecord,
21
+ h.rawReceipt,
22
+ h.expectedReceipt,
23
+ ]);
24
+ assert.deepEqual(out, h.expectedACK);
25
+ assert(Object.isFrozen(out));
26
+ assertFit(out);
27
+ assert.equal(h.writeState.calls.length, 0);
28
+ } finally {
29
+ await h.cleanup();
30
+ }
31
+ },
32
+ );
33
+
34
+ for (const name of [
35
+ "special-keys",
36
+ "repeated-reference",
37
+ "numeric-array",
38
+ ] as const)
39
+ it(
40
+ "configure ACK DATA preserves coherent actualC9 raw JSON: " + name,
41
+ async () => {
42
+ const mutate = (value: unknown) => limitCounterexample(value, name);
43
+ const h = await configureWriteFixture();
44
+ try {
45
+ const candidate = data(mutate(h.expectedACK)),
46
+ raw = data(candidate.rawReceipt);
47
+ const actual = await vi.importActual<
48
+ typeof import("../../../renewalV2/index.js")
49
+ >("../../../renewalV2/index.js");
50
+ const receipt: unknown = await Reflect.apply(
51
+ actual.constructRenewalConfigurationReceiptV2,
52
+ actual,
53
+ [raw],
54
+ );
55
+ const { admitConfigureACK } = await import("./output.js");
56
+ const out = data(
57
+ Reflect.apply(admitConfigureACK, undefined, [
58
+ h.expectedRecord,
59
+ raw,
60
+ receipt,
61
+ ]),
62
+ );
63
+ assert.deepEqual(out, {
64
+ status: "configure_acknowledged",
65
+ originalRecord: h.expectedRecord,
66
+ rawReceipt: raw,
67
+ receipt,
68
+ operationalAuthority: false,
69
+ });
70
+ assert.deepEqual(
71
+ data(out.rawReceipt).providerSnapshot,
72
+ raw.providerSnapshot,
73
+ );
74
+ assert(Object.isFrozen(out));
75
+ assertFit(out);
76
+ assert.equal(h.writeState.calls.length, 0);
77
+ } finally {
78
+ await h.cleanup();
79
+ }
80
+ },
81
+ );
82
+
83
+ it("direct ACK DATA whole cap refuses after complete components and actualC9 fit", async () => {
84
+ const opaque = "x".repeat(250000);
85
+ const h = await configureWriteFixture();
86
+ try {
87
+ const raw = structuredClone(h.rawReceipt);
88
+ Object.assign(raw.providerSnapshot, { opaque });
89
+ const actual = await vi.importActual<
90
+ typeof import("../../../renewalV2/index.js")
91
+ >("../../../renewalV2/index.js");
92
+ const receipt = await actual.constructRenewalConfigurationReceiptV2(raw);
93
+ const parts = [
94
+ assertFit(h.expectedRecord),
95
+ assertFit(raw),
96
+ assertFit(receipt),
97
+ ];
98
+ const expected = {
99
+ status: "configure_acknowledged",
100
+ originalRecord: h.expectedRecord,
101
+ rawReceipt: raw,
102
+ receipt,
103
+ operationalAuthority: false,
104
+ };
105
+ const whole = metrics(expected);
106
+ assert(
107
+ whole.chars > 500000 || whole.bytes > 500000,
108
+ "WHOLE_ACK_ONLY_OVERFLOW_PREREQUISITE",
109
+ );
110
+ assert(whole.nodes <= 10000 && whole.depth <= 40);
111
+ const { admitConfigureACK } = await import("./output.js");
112
+ assert.throws(
113
+ () =>
114
+ Reflect.apply(admitConfigureACK, undefined, [
115
+ h.expectedRecord,
116
+ raw,
117
+ receipt,
118
+ ]),
119
+ {
120
+ message: "CONFIGURE_WRITE_STOP",
121
+ },
122
+ );
123
+ assert.equal(h.writeState.calls.length, 0);
124
+ console.log(
125
+ JSON.stringify({
126
+ kind: "DIRECT_ACK_DATA_WHOLE_CAP",
127
+ parts,
128
+ whole,
129
+ actorOverflowClaim: false,
130
+ }),
131
+ );
132
+ } finally {
133
+ await h.cleanup();
134
+ }
135
+ });
136
+
137
+ for (const name of [
138
+ "escaped-token",
139
+ "raw-digest",
140
+ "proxy",
141
+ "accessor",
142
+ "symbol",
143
+ "nonenumerable",
144
+ "cycle",
145
+ "pan",
146
+ "credential",
147
+ "utf8",
148
+ "nodes",
149
+ "depth",
150
+ ] as const)
151
+ it(
152
+ "direct ACK DATA refuses hostile or inconsistent complete input: " + name,
153
+ async () => {
154
+ const probes = { proxy: 0, getter: 0 };
155
+ const mutate = (value: unknown) => {
156
+ const result =
157
+ name === "accessor"
158
+ ? data(structuredClone(value))
159
+ : data(limitCounterexample(value, name));
160
+ const raw = data(result.rawReceipt);
161
+ if (name === "accessor")
162
+ Object.defineProperty(data(raw.providerSnapshot), "opaque", {
163
+ enumerable: true,
164
+ get() {
165
+ probes.getter++;
166
+ throw Error("TEST_ACCESSOR_REFLECTION");
167
+ },
168
+ });
169
+ if (name === "proxy") {
170
+ const target = raw.providerSnapshot;
171
+ assert(target !== null && typeof target === "object");
172
+ const trap = (): never => {
173
+ probes.proxy++;
174
+ throw Error("TEST_PROXY_REFLECTION");
175
+ };
176
+ raw.providerSnapshot = new Proxy(target, {
177
+ get: trap,
178
+ ownKeys: trap,
179
+ getPrototypeOf: trap,
180
+ getOwnPropertyDescriptor: trap,
181
+ });
182
+ }
183
+ return result;
184
+ };
185
+ const h = await configureWriteFixture();
186
+ try {
187
+ const candidate = data(mutate(h.expectedACK));
188
+ const { admitConfigureACK } = await import("./output.js");
189
+ assert.throws(
190
+ () =>
191
+ Reflect.apply(admitConfigureACK, undefined, [
192
+ candidate.originalRecord,
193
+ candidate.rawReceipt,
194
+ candidate.receipt,
195
+ ]),
196
+ { message: "CONFIGURE_WRITE_STOP" },
197
+ );
198
+ assert.deepEqual(probes, { proxy: 0, getter: 0 });
199
+ assert.equal(h.writeState.calls.length, 0);
200
+ } finally {
201
+ await h.cleanup();
202
+ }
203
+ },
204
+ );
205
+
206
+ it("failure DATA retains complete C6request and exact five generated positions", async () => {
207
+ const diagnostics = Object.freeze({
208
+ type: "StripeConnectionError",
209
+ code: "ECONNRESET",
210
+ requestId: "req_SYNTHETIC",
211
+ statusCode: 409,
212
+ });
213
+ const h = await configureWriteFixture();
214
+ try {
215
+ const { admitConfigureFailure } = await import("./output.js");
216
+ const failure = data(
217
+ admitConfigureFailure(
218
+ "post",
219
+ "configure",
220
+ 5 + h.write.currentBundle.couponReads.length,
221
+ h.projected,
222
+ diagnostics,
223
+ ),
224
+ );
225
+ assert.deepEqual(failure, {
226
+ category: "provider_rejected",
227
+ phase: "post",
228
+ resource: "configure",
229
+ ordinal: 5 + h.write.currentBundle.couponReads.length,
230
+ request: h.projected,
231
+ diagnostics,
232
+ outcome: "unknown",
233
+ operationalAuthority: false,
234
+ });
235
+ assert.deepEqual(Object.keys(failure).sort(), [
236
+ "category",
237
+ "diagnostics",
238
+ "operationalAuthority",
239
+ "ordinal",
240
+ "outcome",
241
+ "phase",
242
+ "request",
243
+ "resource",
244
+ ]);
245
+ assertFit(failure);
246
+ assert(Object.isFrozen(failure));
247
+ assert.equal(h.writeState.calls.length, 0);
248
+ } finally {
249
+ await h.cleanup();
250
+ }
251
+ });
252
+
253
+ for (const diagnostics of [
254
+ { type: "sk_live_SYNTHETIC_UNSAFE" },
255
+ { unknown: "extra" },
256
+ { requestId: "x".repeat(256) },
257
+ ])
258
+ it(
259
+ "failure DATA rejects closed or unsafe diagnostics: " +
260
+ Object.keys(diagnostics)[0],
261
+ async () => {
262
+ const h = await configureWriteFixture();
263
+ try {
264
+ const { admitConfigureFailure } = await import("./output.js");
265
+ assert.throws(
266
+ () =>
267
+ Reflect.apply(admitConfigureFailure, undefined, [
268
+ "post",
269
+ "configure",
270
+ 7,
271
+ h.projected,
272
+ diagnostics,
273
+ ]),
274
+ { message: "CONFIGURE_WRITE_STOP" },
275
+ );
276
+ } finally {
277
+ await h.cleanup();
278
+ }
279
+ },
280
+ );
281
+
282
+ for (const [now, first, expected] of [
283
+ [186399, 100000, true],
284
+ [186400, 100000, false],
285
+ [99999, 100000, false],
286
+ [Number.MAX_SAFE_INTEGER + 1, 100000, false],
287
+ [100000.5, 100000, false],
288
+ [100000, -1, false],
289
+ ] as const)
290
+ it(
291
+ "direct retention DATA boundary without Owner revival: " +
292
+ String(now) +
293
+ "/" +
294
+ String(first),
295
+ async () => {
296
+ const { withinConfigureRetention } = await import("./replay.js");
297
+ assert.equal(withinConfigureRetention(now, first), expected);
298
+ },
299
+ );
300
+
301
+ for (const mode of ["ack", "defaults-null", "defaults-object"] as const)
302
+ it(
303
+ "exact ACK ledger rejects missing or wrong-family generated positions: " +
304
+ mode,
305
+ async () => {
306
+ const h = await configureWriteFixture(mode);
307
+ try {
308
+ const { admitConfigureACK } = await import("./output.js");
309
+ const paths = ackSlots(h);
310
+ assert.equal(paths.length, mode === "ack" ? 18 : 19);
311
+ for (const path of paths)
312
+ for (const mutation of ["missing", "wrong-family"] as const) {
313
+ const candidate = data(structuredClone(h.expectedACK));
314
+ let parent = candidate;
315
+ for (const key of path.slice(0, -1)) parent = data(parent[key]);
316
+ const key = path[path.length - 1]!;
317
+ const original = parent[key];
318
+ assert.equal(typeof original, "string");
319
+ if (mutation === "missing") Reflect.deleteProperty(parent, key);
320
+ else
321
+ parent[key] =
322
+ typeof original === "string" &&
323
+ original.startsWith("renewal:v2:")
324
+ ? "renewal-configure-receipt:v2:sha256:" + "a".repeat(64)
325
+ : "renewal:v2:sha256:" + "a".repeat(64);
326
+ assert.throws(
327
+ () =>
328
+ Reflect.apply(admitConfigureACK, undefined, [
329
+ candidate.originalRecord,
330
+ candidate.rawReceipt,
331
+ candidate.receipt,
332
+ ]),
333
+ { message: "CONFIGURE_WRITE_STOP" },
334
+ );
335
+ }
336
+ const candidate = data(structuredClone(h.expectedACK)),
337
+ receipt = data(candidate.receipt);
338
+ if (mode === "ack")
339
+ receipt.defaultSettingsBinding =
340
+ "renewal-configured-defaults:v2:sha256:" + "a".repeat(64);
341
+ else Reflect.deleteProperty(receipt, "defaultSettingsBinding");
342
+ assert.throws(
343
+ () =>
344
+ Reflect.apply(admitConfigureACK, undefined, [
345
+ candidate.originalRecord,
346
+ candidate.rawReceipt,
347
+ receipt,
348
+ ]),
349
+ { message: "CONFIGURE_WRITE_STOP" },
350
+ );
351
+ assert.equal(h.writeState.calls.length, 0);
352
+ } finally {
353
+ await h.cleanup();
354
+ }
355
+ },
356
+ );
357
+
358
+ it("coherent actualC9 raw descendants and escaped keys have no generated privilege", async () => {
359
+ const unsafeHex = "a".repeat(22) + "4242424242424242" + "b".repeat(26);
360
+ const unsafeRawToken = "renewal:v2:sha256:" + unsafeHex;
361
+ const ordinary64Digits = "renewal:v2:sha256:" + "1".repeat(64);
362
+ const recipes = ["ancestor", "escaped"] as const;
363
+ assert.equal(unsafeHex.length, 64);
364
+ assert(/^renewal:v2:sha256:[0-9a-f]{64}$/.test(unsafeRawToken));
365
+ const h = await configureWriteFixture();
366
+ try {
367
+ const { admitConfigureACK } = await import("./output.js");
368
+ const { requiredJSONSnapshot } =
369
+ await import("../material/requiredJson.js");
370
+ assert.throws(() => requiredJSONSnapshot(unsafeRawToken), {
371
+ message: "REQUIRED_JSON_PRIVACY_STOP",
372
+ });
373
+ assert.doesNotThrow(() => requiredJSONSnapshot(ordinary64Digits));
374
+ const actual = await vi.importActual<
375
+ typeof import("../../../renewalV2/index.js")
376
+ >("../../../renewalV2/index.js");
377
+ for (const recipe of recipes) {
378
+ const candidate = data(structuredClone(h.expectedACK));
379
+ const raw = data(candidate.rawReceipt),
380
+ body = data(raw.providerSnapshot);
381
+ if (recipe === "ancestor")
382
+ body.opaque = {
383
+ receipt: { request: { logicalBinding: unsafeRawToken } },
384
+ };
385
+ else
386
+ Object.defineProperty(body, "/receipt/request/logicalBinding", {
387
+ value: unsafeRawToken,
388
+ enumerable: true,
389
+ });
390
+ // A constructor refusal is a failed prerequisite, never helper privacy coverage.
391
+ const receipt: unknown = await Reflect.apply(
392
+ actual.constructRenewalConfigurationReceiptV2,
393
+ actual,
394
+ [raw],
395
+ );
396
+ const r = data(receipt);
397
+ assert.equal(r.stage, "configure_acknowledged");
398
+ assert.deepEqual(raw.configuration, h.expectedRecord.configuration);
399
+ assert.deepEqual(raw.actualDispatch, h.rawReceipt.actualDispatch);
400
+ assert.deepEqual(r.request, h.projected);
401
+ assert.deepEqual(raw.providerSnapshot, r.providerSnapshot);
402
+ assert.deepEqual(raw.transport, r.transport);
403
+ const components = [
404
+ assertFit(candidate.originalRecord),
405
+ assertFit(raw),
406
+ assertFit(receipt),
407
+ ];
408
+ const full = {
409
+ status: "configure_acknowledged",
410
+ originalRecord: candidate.originalRecord,
411
+ rawReceipt: raw,
412
+ receipt,
413
+ operationalAuthority: false,
414
+ };
415
+ const whole = assertFit(full);
416
+ assert.throws(
417
+ () =>
418
+ Reflect.apply(admitConfigureACK, undefined, [
419
+ candidate.originalRecord,
420
+ raw,
421
+ receipt,
422
+ ]),
423
+ { message: "CONFIGURE_WRITE_STOP" },
424
+ );
425
+ console.log(
426
+ JSON.stringify({
427
+ kind: "COHERENT_RAW_TOKEN_PRIVACY_BOUNDARY",
428
+ recipe,
429
+ components,
430
+ whole,
431
+ actualC9Prerequisite: true,
432
+ bodyTransportEqual: true,
433
+ actorApplicabilityClaim: false,
434
+ sourceApplicabilityClaim: false,
435
+ }),
436
+ );
437
+ }
438
+ assert.equal(h.writeState.calls.length, 0);
439
+ } finally {
440
+ await h.cleanup();
441
+ }
442
+ });
443
+
444
+ it("direct failure DATA whole cap refuses after provisional protocol component fits", async () => {
445
+ // Fixed structural boundary formula, declared before constructors; never retried or fitted to a refusal.
446
+ const targetRequestCharacters = 499500;
447
+ const diagnostics = {
448
+ type: "x".repeat(255),
449
+ code: "x".repeat(255),
450
+ requestId: "x".repeat(255),
451
+ statusCode: 409,
452
+ };
453
+ const h = await configureWriteFixture();
454
+ try {
455
+ const candidate = data(structuredClone(h.projected));
456
+ const phases = data(candidate.payload).phases;
457
+ assert(Array.isArray(phases));
458
+ const phase = data(phases[0]);
459
+ phase.metadata = { opaque: "" };
460
+ const fixedOverhead = JSON.stringify(candidate).length;
461
+ assert(fixedOverhead < targetRequestCharacters);
462
+ data(phase.metadata).opaque = "x".repeat(
463
+ targetRequestCharacters - fixedOverhead,
464
+ );
465
+ const actual = await import("./output.js");
466
+ // This is provisional DATA shape admission, not a new C6 projection or Source authentication.
467
+ const component = actual.captureConfigureRequest(candidate);
468
+ const componentMetrics = assertFit(component);
469
+ assert.equal(componentMetrics.chars, targetRequestCharacters);
470
+ const expected = {
471
+ category: "provider_rejected",
472
+ phase: "post",
473
+ resource: "configure",
474
+ ordinal: 7,
475
+ request: component,
476
+ diagnostics,
477
+ outcome: "unknown",
478
+ operationalAuthority: false,
479
+ };
480
+ const whole = metrics(expected);
481
+ assert(
482
+ whole.chars > 500000 && whole.bytes > 500000,
483
+ "WHOLE_FAILURE_ONLY_OVERFLOW_PREREQUISITE",
484
+ );
485
+ assert(whole.nodes <= 10000 && whole.depth <= 40);
486
+ assert.throws(
487
+ () =>
488
+ actual.admitConfigureFailure(
489
+ "post",
490
+ "configure",
491
+ 7,
492
+ component,
493
+ diagnostics,
494
+ ),
495
+ { message: "CONFIGURE_WRITE_STOP" },
496
+ );
497
+ assert.equal(h.writeState.calls.length, 0);
498
+ console.log(
499
+ JSON.stringify({
500
+ kind: "DIRECT_FAILURE_DATA_WHOLE_CAP",
501
+ componentMetrics,
502
+ whole,
503
+ actualC6ApplicabilityClaim: false,
504
+ actorOverflowClaim: false,
505
+ }),
506
+ );
507
+ } finally {
508
+ await h.cleanup();
509
+ }
510
+ });