@fantastic.dev/better-stripe 0.106.0 → 0.107.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 (28) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/observation/history.d.ts +41 -0
  4. package/dist/client/billing/renewalAttach/internal/observation/history.d.ts.map +1 -0
  5. package/dist/client/billing/renewalAttach/internal/observation/history.js +161 -0
  6. package/dist/client/billing/renewalAttach/internal/observation/history.js.map +1 -0
  7. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.d.ts +55 -0
  8. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.d.ts.map +1 -0
  9. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.js +83 -0
  10. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.js.map +1 -0
  11. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  12. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  13. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  14. package/dist/component/balanceFunding/mutations.d.ts +27 -27
  15. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  16. package/dist/component/earnings/triggers.d.ts +16 -16
  17. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  18. package/dist/component/payoutRelease/queries.d.ts +2 -2
  19. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  20. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  21. package/dist/component/usage/allowance.fixtures.d.ts +16 -16
  22. package/docs/renewal-context-reads.md +35 -0
  23. package/package.json +1 -1
  24. package/src/client/billing/renewalAttach/internal/observation/history.integration.test.ts +79 -0
  25. package/src/client/billing/renewalAttach/internal/observation/history.ts +200 -0
  26. package/src/client/billing/renewalAttach/internal/observation/historyControls.integration.test.ts +238 -0
  27. package/src/client/billing/renewalAttach/internal/observation/historyEvents.ts +114 -0
  28. package/src/client/billing/renewalAttach/internal/test-fixtures/historySnapshot.ts +47 -0
@@ -5,14 +5,6 @@ export declare function savePreparationHandler(ctx: MutationCtx, args: Infer<typ
5
5
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
6
6
  }>;
7
7
  export declare function beginHandler(ctx: MutationCtx, args: Infer<typeof beginArgs>): Promise<{
8
- reason: "identity_changed" | "revision_changed" | "scope_busy";
9
- retryable: false;
10
- status: "conflict";
11
- } | {
12
- reason: "policy_invalid";
13
- retryable: false;
14
- status: "rejected";
15
- } | {
16
8
  operation: {
17
9
  accountId: string;
18
10
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -23,6 +15,14 @@ export declare function beginHandler(ctx: MutationCtx, args: Infer<typeof beginA
23
15
  } | {
24
16
  enabled: boolean;
25
17
  status: "unchanged";
18
+ } | {
19
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
20
+ retryable: false;
21
+ status: "conflict";
22
+ } | {
23
+ reason: "policy_invalid";
24
+ retryable: false;
25
+ status: "rejected";
26
26
  } | {
27
27
  reason: "provider_pending";
28
28
  retryable: true;
@@ -372,14 +372,6 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
372
372
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
373
373
  requestKey: string;
374
374
  result?: {
375
- reason: "identity_changed" | "revision_changed" | "scope_busy";
376
- retryable: false;
377
- status: "conflict";
378
- } | {
379
- reason: "policy_invalid";
380
- retryable: false;
381
- status: "rejected";
382
- } | {
383
375
  operation: {
384
376
  accountId: string;
385
377
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -390,6 +382,14 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
390
382
  } | {
391
383
  enabled: boolean;
392
384
  status: "unchanged";
385
+ } | {
386
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
387
+ retryable: false;
388
+ status: "conflict";
389
+ } | {
390
+ reason: "policy_invalid";
391
+ retryable: false;
392
+ status: "rejected";
393
393
  } | {
394
394
  reason: "provider_pending";
395
395
  retryable: true;
@@ -3417,14 +3417,6 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
3417
3417
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
3418
3418
  requestKey: string;
3419
3419
  result?: {
3420
- reason: "identity_changed" | "revision_changed" | "scope_busy";
3421
- retryable: false;
3422
- status: "conflict";
3423
- } | {
3424
- reason: "policy_invalid";
3425
- retryable: false;
3426
- status: "rejected";
3427
- } | {
3428
3420
  operation: {
3429
3421
  accountId: string;
3430
3422
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -3435,6 +3427,14 @@ export declare const mutation: import("convex-helpers/server/customFunctions").C
3435
3427
  } | {
3436
3428
  enabled: boolean;
3437
3429
  status: "unchanged";
3430
+ } | {
3431
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
3432
+ retryable: false;
3433
+ status: "conflict";
3434
+ } | {
3435
+ reason: "policy_invalid";
3436
+ retryable: false;
3437
+ status: "rejected";
3438
3438
  } | {
3439
3439
  reason: "provider_pending";
3440
3440
  retryable: true;
@@ -9,9 +9,9 @@ export declare function legOwnership(ctx: MutationCtx, bucketKey: string, prior:
9
9
  orgId: string | undefined;
10
10
  ownershipStatus: "ambiguous";
11
11
  } | {
12
- registrationId?: undefined;
13
12
  userId?: undefined;
14
13
  orgId?: undefined;
14
+ registrationId?: undefined;
15
15
  ownershipStatus: "ambiguous";
16
16
  } | {
17
17
  registrationId: import("convex/values").GenericId<"financialOwnership">;
@@ -19,9 +19,9 @@ export declare function legOwnership(ctx: MutationCtx, bucketKey: string, prior:
19
19
  orgId: string | undefined;
20
20
  ownershipStatus: "unknown";
21
21
  } | {
22
- registrationId?: undefined;
23
22
  userId?: undefined;
24
23
  orgId?: undefined;
24
+ registrationId?: undefined;
25
25
  ownershipStatus: "unknown";
26
26
  } | {
27
27
  registrationId: import("convex/values").GenericId<"financialOwnership">;
@@ -29,9 +29,9 @@ export declare function legOwnership(ctx: MutationCtx, bucketKey: string, prior:
29
29
  orgId: string | undefined;
30
30
  ownershipStatus: "contradictory";
31
31
  } | {
32
- registrationId?: undefined;
33
32
  userId?: undefined;
34
33
  orgId?: undefined;
34
+ registrationId?: undefined;
35
35
  ownershipStatus: "contradictory";
36
36
  } | {
37
37
  registrationId: import("convex/values").GenericId<"financialOwnership">;
@@ -163,10 +163,10 @@ export declare const snapshot: import("convex/server").RegisteredQuery<"public",
163
163
  accountId: string;
164
164
  ownerKey: string;
165
165
  }, Promise<{
166
- status: "held";
167
- reason: "snapshot_limit";
168
166
  transfers?: undefined;
169
167
  claims?: undefined;
168
+ status: "held";
169
+ reason: "snapshot_limit";
170
170
  } | {
171
171
  reason?: undefined;
172
172
  status: "ready";
@@ -1 +1 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIlB,CAAC;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBd,CAAC;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;GAQf,CAAC;AAEH,4FAA4F;AAC5F,eAAO,MAAM,QAAQ;;;;YAsBE,MAAM;YAAmB,gBAAgB;;;;;YAS3C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE1B,CAAC"}
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIlB,CAAC;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBd,CAAC;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;GAQf,CAAC;AAEH,4FAA4F;AAC5F,eAAO,MAAM,QAAQ;;;;;;YAsBE,MAAM;YAAmB,gBAAgB;;;YAS3C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE1B,CAAC"}
@@ -14,7 +14,7 @@ export declare function checkRollback(ctx: MutationCtx, op: Doc<"processingCostR
14
14
  readonly bindFunding?: undefined;
15
15
  } | {
16
16
  reason?: undefined;
17
- readonly retryable?: undefined;
17
+ retryable?: undefined;
18
18
  readonly status: "ready";
19
19
  readonly bindFunding: boolean;
20
20
  }>;
@@ -2632,14 +2632,6 @@ export declare function setupAllowance(): Promise<{
2632
2632
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
2633
2633
  requestKey: string;
2634
2634
  result?: {
2635
- reason: "identity_changed" | "revision_changed" | "scope_busy";
2636
- retryable: false;
2637
- status: "conflict";
2638
- } | {
2639
- reason: "policy_invalid";
2640
- retryable: false;
2641
- status: "rejected";
2642
- } | {
2643
2635
  operation: {
2644
2636
  accountId: string;
2645
2637
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -2650,6 +2642,14 @@ export declare function setupAllowance(): Promise<{
2650
2642
  } | {
2651
2643
  enabled: boolean;
2652
2644
  status: "unchanged";
2645
+ } | {
2646
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
2647
+ retryable: false;
2648
+ status: "conflict";
2649
+ } | {
2650
+ reason: "policy_invalid";
2651
+ retryable: false;
2652
+ status: "rejected";
2653
2653
  } | {
2654
2654
  reason: "provider_pending";
2655
2655
  retryable: true;
@@ -2660,14 +2660,6 @@ export declare function setupAllowance(): Promise<{
2660
2660
  payload: import("convex/values").VString<string, "required">;
2661
2661
  preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
2662
2662
  result: import("convex/values").VUnion<{
2663
- reason: "identity_changed" | "revision_changed" | "scope_busy";
2664
- retryable: false;
2665
- status: "conflict";
2666
- } | {
2667
- reason: "policy_invalid";
2668
- retryable: false;
2669
- status: "rejected";
2670
- } | {
2671
2663
  operation: {
2672
2664
  accountId: string;
2673
2665
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -2678,6 +2670,14 @@ export declare function setupAllowance(): Promise<{
2678
2670
  } | {
2679
2671
  enabled: boolean;
2680
2672
  status: "unchanged";
2673
+ } | {
2674
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
2675
+ retryable: false;
2676
+ status: "conflict";
2677
+ } | {
2678
+ reason: "policy_invalid";
2679
+ retryable: false;
2680
+ status: "rejected";
2681
2681
  } | {
2682
2682
  reason: "provider_pending";
2683
2683
  retryable: true;
@@ -907,3 +907,38 @@ custody qualification before it can be enabled; see
907
907
  These helpers retain ordinary provider and caller metadata within their JSON
908
908
  limits. They do not redact, encrypt or certify that input or output is safe to
909
909
  log. Do not place secrets in metadata, and protect retained full records.
910
+
911
+ ### Private retained observation history DATA
912
+
913
+ The private `captureRetainedObservationHistory` helper reconstructs a complete
914
+ retained history snapshot without selecting a client or creating a read or write
915
+ Owner. Its input has exactly `parent` and `configure`. Each contains the complete
916
+ `operation`, `attempt`, `events` and `acknowledgement` query results. An active
917
+ reserved v2 attachment parent must have three complete events and full retained
918
+ C3. The reserved v3 configure child may have zero through three events. Standalone
919
+ attachment history at head two and unreserved configure operations are outside
920
+ this increment.
921
+
922
+ The helper copies and freezes the entire own-DATA graph before its first await.
923
+ The aggregate input is limited to 10,000 traversal nodes, depth 40 and 500,000
924
+ UTF-8 bytes, with the existing component return-value limits also enforced.
925
+ Proxies, accessors, hidden properties, sparse arrays and unsupported values reject.
926
+ Every full event must match its manifest and canonical event binding. Full C3,
927
+ C7, original raw material, account, API, parent linkage, period/deadline policy and
928
+ bound basis must agree. Parent and child host authorization envelopes may differ.
929
+ Only a head-zero child may have an unbound basis. Operation, attempt, event and
930
+ payload identities must not alias.
931
+
932
+ Missing C9 is valid at child heads zero, one and two. A complete response at head
933
+ two is checked against the original request and configuration, but reconstruction
934
+ alone does not make a receipt retained. A supplied C9 must match the full response,
935
+ canonical receipt JSON and retention references. Head three requires retained C9.
936
+ The output preserves the full detached snapshot and original configuration. Its
937
+ authentication, public delivery and operational-authority flags are false.
938
+
939
+ These are unsigned historical DATA checks. They do not prove an actual returned
940
+ ACK, grant fresh authorization, revive an expired Owner or permit replay. The
941
+ future-period observation entry still needs fresh host authorization, a separate
942
+ bounded GET-only lifetime and complete lifecycle/invoice/history acquisition.
943
+ Production Source profiles remain empty. Provider qualification, genuine
944
+ generation/deployed compatibility and final Dojo acceptance remain outstanding.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fantastic.dev/better-stripe",
3
- "version": "0.106.0",
3
+ "version": "0.107.0",
4
4
  "description": "Convex component for Stripe Accounts v2, subscriptions, metered billing and Connect marketplaces, with React workflows.",
5
5
  "keywords": [
6
6
  "stripe",
@@ -0,0 +1,79 @@
1
+ import { expect } from "vitest";
2
+ import {
3
+ configureAdmissionCase,
4
+ admissionControls,
5
+ } from "../test-fixtures/producerConfigureAdmission.js";
6
+ import {
7
+ historySnapshot,
8
+ historyPrefix,
9
+ } from "../test-fixtures/historySnapshot.js";
10
+ import { captureRetainedObservationHistory } from "./history.js";
11
+ import { object } from "../producer/configureJournalData.js";
12
+
13
+ configureAdmissionCase(
14
+ "reconstructs reserved history heads zero through three without write authority",
15
+ historySnapshot,
16
+ async (h, full) => {
17
+ const calls = h.calls.length;
18
+ const selectors = admissionControls.selectors;
19
+ for (const head of [0, 1, 2, 3]) {
20
+ const snapshot = historyPrefix(full, head, head === 3);
21
+ const result = await captureRetainedObservationHistory(snapshot);
22
+ expect(result).not.toBeNull();
23
+ expect(result?.status).toBe("retained_observation_history_data");
24
+ expect(result?.configureHead).toBe(head);
25
+ expect(result?.configureReceipt === null).toBe(head !== 3);
26
+ expect(result?.operationalAuthority).toBe(false);
27
+ expect(result?.authenticationEstablished).toBe(false);
28
+ expect(result?.publicDeliveryEstablished).toBe(false);
29
+ expect(result?.record).toEqual(
30
+ JSON.parse(full.configure.operation.recordJSON).configureRecord,
31
+ );
32
+ }
33
+ expect(h.calls).toHaveLength(calls);
34
+ expect(admissionControls.selectors).toBe(selectors);
35
+ },
36
+ );
37
+
38
+ configureAdmissionCase(
39
+ "retains full C9 at head two and captures before the first asynchronous reconstruction",
40
+ historySnapshot,
41
+ async (_h, full) => {
42
+ const input = historyPrefix(full, 2, true);
43
+ const pending = captureRetainedObservationHistory(input);
44
+ input.configure.operation.recordJSON = "{}";
45
+ const result = await pending;
46
+ expect(result?.configureHead).toBe(2);
47
+ expect(result?.configureReceipt).toEqual(
48
+ JSON.parse(full.configure.acknowledgement!.receiptJSON),
49
+ );
50
+ expect(object(object(result.snapshot.configure).operation).recordJSON).toBe(
51
+ full.configure.operation.recordJSON,
52
+ );
53
+ expect(Object.isFrozen(result)).toBe(true);
54
+ expect(Object.isFrozen(result?.record.configuration)).toBe(true);
55
+ expect(Object.isFrozen(object(result.snapshot.configure).events)).toBe(
56
+ true,
57
+ );
58
+ },
59
+ );
60
+
61
+ configureAdmissionCase(
62
+ "permits unbound head zero while preserving independently scoped host envelopes",
63
+ historySnapshot,
64
+ async (_h, full) => {
65
+ const snapshot = historyPrefix(full, 0);
66
+ Object.assign(snapshot.configure.operation, { initialBasis: null });
67
+ const result = await captureRetainedObservationHistory(snapshot);
68
+ expect(result?.configureHead).toBe(0);
69
+ expect(result?.configureReceipt).toBeNull();
70
+ expect(object(object(result.snapshot.parent).operation).recordJSON).toBe(
71
+ full.parent.operation.recordJSON,
72
+ );
73
+ expect(
74
+ JSON.parse(full.parent.operation.recordJSON).authorization.scope,
75
+ ).not.toBe(
76
+ JSON.parse(full.configure.operation.recordJSON).authorization.scope,
77
+ );
78
+ },
79
+ );
@@ -0,0 +1,200 @@
1
+ import { rejectProxyJSON } from "../acquisition/rawWireSource.js";
2
+ import { renewalSnapshot } from "../../../renewalReplacementSnapshot.js";
3
+ import { closed, freeze, sevenWire } from "../c10/ownData.js";
4
+ import { canonicalInitialBasis } from "../../../../../shared/renewalOperationJournal.js";
5
+ import {
6
+ reconstructConfigurationV2,
7
+ constructRenewalConfigurationReceiptV2,
8
+ } from "../../../renewalV2/index.js";
9
+ import { captureObservationRecord, verifyObservationRecord } from "./record.js";
10
+ import { admitConfigureACK } from "../configure/output.js";
11
+ import {
12
+ checkOperationLoad,
13
+ matchConfigureDATA,
14
+ object,
15
+ text,
16
+ requireConfigure as need,
17
+ } from "../producer/configureJournalData.js";
18
+ import {
19
+ captureHistoryStage,
20
+ verifyHistoryEvents,
21
+ verifyHistoryRetention,
22
+ } from "./historyEvents.js";
23
+
24
+ /** Pure retained DATA. No Source, actual returned ACK, authorization or execution grant. */
25
+ export async function captureRetainedObservationHistory(raw: unknown) {
26
+ need(arguments.length === 1);
27
+ // Capture the complete graph before the first await, including opaque JSON strings.
28
+ rejectProxyJSON(raw);
29
+ const copy = renewalSnapshot(raw);
30
+ need(new TextEncoder().encode(JSON.stringify(copy)).length <= 500000);
31
+ matchConfigureDATA(raw, copy);
32
+ freeze(copy);
33
+ const snapshot = closed(copy, ["parent", "configure"]);
34
+ const parent = captureHistoryStage(snapshot.parent, "attach");
35
+ const child = captureHistoryStage(snapshot.configure, "configure");
36
+ need(
37
+ parent.reservation.operationId !== child.reservation.operationId &&
38
+ parent.reservation.attemptId !== child.reservation.attemptId,
39
+ );
40
+ const original = object(JSON.parse(child.reservation.recordJSON));
41
+ const parentOriginal = object(JSON.parse(parent.reservation.recordJSON));
42
+ const captured = captureObservationRecord(original.configureRecord);
43
+ const record = captured.record;
44
+ const rebuilt = await reconstructConfigurationV2(record.configuration);
45
+ need(rebuilt.material && "requestIdentity" in rebuilt.result);
46
+ verifyObservationRecord(captured, rebuilt.result, rebuilt.material.receipt);
47
+ const receipt = rebuilt.material.receipt,
48
+ request = rebuilt.result;
49
+ matchConfigureDATA(original.parentAttachment, {
50
+ operationId: parent.reservation.operationId,
51
+ attemptId: parent.reservation.attemptId,
52
+ sourcePayloadId: parent.reservation.payloadId,
53
+ receiptBinding: receipt.binding,
54
+ });
55
+ matchConfigureDATA(
56
+ record.configuration.attachReceipt.attachRequest,
57
+ parentOriginal.attachRequest,
58
+ );
59
+ matchConfigureDATA(record.originalBundle, parentOriginal.originalBundle);
60
+ matchConfigureDATA(original.account, parentOriginal.account);
61
+ matchConfigureDATA(original.account, {
62
+ mode: "platform",
63
+ stripeAccount: null,
64
+ livemode: receipt.livemode,
65
+ });
66
+ need(
67
+ original.apiVersion === parentOriginal.apiVersion &&
68
+ original.apiVersion === request.apiVersion,
69
+ );
70
+ matchConfigureDATA(original.dispatch, sevenWire(request));
71
+ matchConfigureDATA(parentOriginal.dispatch, sevenWire(receipt.request));
72
+ need(
73
+ child.reservation.requestBinding === request.requestIdentity.binding &&
74
+ parent.reservation.requestBinding ===
75
+ receipt.request.requestIdentity.binding,
76
+ );
77
+ const policy = object(original.timingPolicy),
78
+ parentPolicy = object(parentOriginal.timingPolicy);
79
+ for (const key of ["workEndWallMs", "endWallMs", "periodStart", "periodEnd"])
80
+ need(policy[key] === parentPolicy[key]);
81
+ const parentLoad = object(parent.operation),
82
+ basis = object(parentLoad.initialBasis);
83
+ const basisJSON = text(basis.basisJSON);
84
+ need(
85
+ canonicalInitialBasis(parent.reservation.timingPolicyJSON, basisJSON)
86
+ .basisJSON === basisJSON,
87
+ );
88
+ need(
89
+ canonicalInitialBasis(child.reservation.timingPolicyJSON, basisJSON)
90
+ .basisJSON === basisJSON,
91
+ );
92
+ checkOperationLoad(parent.operation, parent.reservation, basisJSON);
93
+ checkOperationLoad(
94
+ child.operation,
95
+ child.reservation,
96
+ basisJSON,
97
+ child.events.length === 0,
98
+ );
99
+ await verifyHistoryEvents(parent, [
100
+ { event: "dispatch", stage: "attach", request: receipt.request },
101
+ {
102
+ event: "response",
103
+ stage: "attach",
104
+ request: receipt.request,
105
+ body: receipt.providerSnapshot,
106
+ status: parent.events[1].data.status,
107
+ },
108
+ { event: "receipt", stage: "attach", request: receipt.request, receipt },
109
+ ]);
110
+ const attachmentRetention = verifyHistoryRetention(parent, receipt);
111
+ const expected: unknown[] = [];
112
+ if (child.events.length >= 1)
113
+ expected.push({ event: "dispatch", stage: "configure", request });
114
+ const response = child.events[1]?.data;
115
+ if (response)
116
+ expected.push({
117
+ event: "response",
118
+ stage: "configure",
119
+ request,
120
+ body: response.body,
121
+ transport: response.transport,
122
+ });
123
+ let configureReceipt = null,
124
+ rawConfigureReceipt = null,
125
+ configureRetention = null;
126
+ if (response) {
127
+ const t = closed(response.transport, ["status"], ["requestId"]);
128
+ need(typeof t.status === "number");
129
+ need(t.requestId === undefined || typeof t.requestId === "string");
130
+ const rawResponse = {
131
+ configuration: record.configuration,
132
+ actualDispatch: sevenWire(request),
133
+ providerSnapshot: object(response.body),
134
+ transport: {
135
+ status: t.status,
136
+ ...(typeof t.requestId === "string" ? { requestId: t.requestId } : {}),
137
+ },
138
+ };
139
+ const reconstructed =
140
+ await constructRenewalConfigurationReceiptV2(rawResponse);
141
+ admitConfigureACK(record, rawResponse, reconstructed);
142
+ // Response2 may be valid without durable C9. Reconstruction does not retain it.
143
+ if (child.acknowledgement !== null) {
144
+ rawConfigureReceipt = rawResponse;
145
+ configureReceipt = reconstructed;
146
+ configureRetention = verifyHistoryRetention(child, configureReceipt);
147
+ }
148
+ } else need(child.acknowledgement === null);
149
+ if (child.events.length === 3) {
150
+ need(configureReceipt);
151
+ expected.push({
152
+ event: "receipt",
153
+ stage: "configure",
154
+ request,
155
+ receipt: configureReceipt,
156
+ });
157
+ }
158
+ await verifyHistoryEvents(child, expected);
159
+ // IDs remain opaque DATA. Even equal complete records never become runtime tokens.
160
+ const payloads = [
161
+ parent.reservation.payloadId,
162
+ child.reservation.payloadId,
163
+ ...parent.events.map((e) => e.descriptor.payloadId),
164
+ ...child.events.map((e) => e.descriptor.payloadId),
165
+ object(attachmentRetention.retention).receiptPayloadId,
166
+ ...(configureRetention
167
+ ? [object(configureRetention.retention).receiptPayloadId]
168
+ : []),
169
+ ];
170
+ const eventIds = [...parent.events, ...child.events].map(
171
+ (e) => e.descriptor.eventId,
172
+ );
173
+ need(
174
+ new Set(payloads).size === payloads.length &&
175
+ new Set(eventIds).size === eventIds.length,
176
+ );
177
+ const ids = [
178
+ parent.reservation.operationId,
179
+ child.reservation.operationId,
180
+ parent.reservation.attemptId,
181
+ child.reservation.attemptId,
182
+ ...payloads,
183
+ ...eventIds,
184
+ ];
185
+ need(new Set(ids).size === ids.length);
186
+ return freeze({
187
+ status: "retained_observation_history_data" as const,
188
+ record,
189
+ configureHead: child.events.length,
190
+ configureReceipt,
191
+ rawConfigureReceipt,
192
+ attachmentReceipt: receipt,
193
+ attachmentRetention,
194
+ configureRetention,
195
+ snapshot: { parent: snapshot.parent, configure: snapshot.configure },
196
+ operationalAuthority: false as const,
197
+ authenticationEstablished: false as const,
198
+ publicDeliveryEstablished: false as const,
199
+ });
200
+ }