@fantastic.dev/better-stripe 0.95.0 → 0.95.1

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 (63) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.d.ts.map +1 -1
  4. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js +2 -5
  5. package/dist/client/billing/renewalAttach/internal/producer/lineageAuthority.js.map +1 -1
  6. package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.d.ts.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.js +15 -4
  8. package/dist/client/billing/renewalAttach/internal/producer/ownerFactory.js.map +1 -1
  9. package/dist/client/billing/renewalObservation/evidence-invoice-lines.d.ts +27 -0
  10. package/dist/client/billing/renewalObservation/evidence-invoice-lines.d.ts.map +1 -0
  11. package/dist/client/billing/renewalObservation/evidence-invoice-lines.js +164 -0
  12. package/dist/client/billing/renewalObservation/evidence-invoice-lines.js.map +1 -0
  13. package/dist/client/billing/renewalObservation/evidence-invoice.d.ts +4 -0
  14. package/dist/client/billing/renewalObservation/evidence-invoice.d.ts.map +1 -0
  15. package/dist/client/billing/renewalObservation/evidence-invoice.js +190 -0
  16. package/dist/client/billing/renewalObservation/evidence-invoice.js.map +1 -0
  17. package/dist/client/billing/renewalObservation/evidence-material.d.ts +26 -0
  18. package/dist/client/billing/renewalObservation/evidence-material.d.ts.map +1 -0
  19. package/dist/client/billing/renewalObservation/evidence-material.js +253 -0
  20. package/dist/client/billing/renewalObservation/evidence-material.js.map +1 -0
  21. package/dist/client/billing/renewalObservation/evidence-v1-types.d.ts +156 -0
  22. package/dist/client/billing/renewalObservation/evidence-v1-types.d.ts.map +1 -0
  23. package/dist/client/billing/renewalObservation/evidence-v1-types.js +2 -0
  24. package/dist/client/billing/renewalObservation/evidence-v1-types.js.map +1 -0
  25. package/dist/client/billing/renewalObservation/evidence-v1.d.ts +4 -0
  26. package/dist/client/billing/renewalObservation/evidence-v1.d.ts.map +1 -0
  27. package/dist/client/billing/renewalObservation/evidence-v1.js +263 -0
  28. package/dist/client/billing/renewalObservation/evidence-v1.js.map +1 -0
  29. package/dist/client/billing/renewalObservation/terminal-evidence.d.ts +17 -0
  30. package/dist/client/billing/renewalObservation/terminal-evidence.d.ts.map +1 -0
  31. package/dist/client/billing/renewalObservation/terminal-evidence.js +289 -0
  32. package/dist/client/billing/renewalObservation/terminal-evidence.js.map +1 -0
  33. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  34. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  35. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  36. package/dist/component/balanceFunding/mutations.d.ts +43 -43
  37. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  38. package/dist/component/earnings/triggers.d.ts +16 -16
  39. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  40. package/dist/component/payoutRelease/queries.d.ts +2 -2
  41. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  42. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  43. package/dist/component/usageCredits/accounting.fixtures.d.ts +16 -16
  44. package/docs/renewal-context-reads.md +9 -5
  45. package/docs/renewal-material-observation.md +50 -0
  46. package/package.json +1 -1
  47. package/src/client/billing/renewalAttach/internal/producer/lineageAuthority.ts +2 -5
  48. package/src/client/billing/renewalAttach/internal/producer/ownerFactory.ts +17 -5
  49. package/src/client/billing/renewalAttach/internal/producer/producerClock.integration.test.ts +175 -0
  50. package/src/client/billing/renewalAttach/internal/producer/producerOwner.integration.test.ts +15 -23
  51. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +62 -0
  52. package/src/client/billing/renewalObservation/evidence-admission.test.ts +219 -0
  53. package/src/client/billing/renewalObservation/evidence-history.test.ts +187 -0
  54. package/src/client/billing/renewalObservation/evidence-invoice-controls.test.ts +293 -0
  55. package/src/client/billing/renewalObservation/evidence-invoice-lines.ts +238 -0
  56. package/src/client/billing/renewalObservation/evidence-invoice.test.ts +177 -0
  57. package/src/client/billing/renewalObservation/evidence-invoice.ts +271 -0
  58. package/src/client/billing/renewalObservation/evidence-material.test.ts +289 -0
  59. package/src/client/billing/renewalObservation/evidence-material.ts +313 -0
  60. package/src/client/billing/renewalObservation/evidence-v1-types.ts +186 -0
  61. package/src/client/billing/renewalObservation/evidence-v1.test.ts +371 -0
  62. package/src/client/billing/renewalObservation/evidence-v1.ts +286 -0
  63. package/src/client/billing/renewalObservation/terminal-evidence.ts +379 -0
@@ -0,0 +1,186 @@
1
+ /** Private version1 evidence DATA shapes. No public SDK entry or authority. */
2
+ import type {
3
+ ProjectRenewalConfigurationV2Options,
4
+ ConstructRenewalConfigurationReceiptV2Options,
5
+ } from "../renewalV2/index.js";
6
+ import type { RenewalScheduleMaterialReads } from "../renewalV2/observation.js";
7
+
8
+ export type API = "2026-09-30.endive";
9
+ export type Period = Readonly<{ start: number; end: number }>;
10
+ export type Presence<T> =
11
+ | Readonly<{ presence: "absent" }>
12
+ | Readonly<{ presence: "present"; value: T }>;
13
+ export type Reason =
14
+ | "not_supplied"
15
+ | "unsupported_api_version"
16
+ | "unsupported_profile"
17
+ | "incomplete_material"
18
+ | "owned_identity_mismatch"
19
+ | "material_mismatch"
20
+ | "terminal_completion_unproven"
21
+ | "invalid_terminal_field"
22
+ | "ambiguous_items"
23
+ | "incomplete_invoice_lines"
24
+ | "unsupported_invoice_reason"
25
+ | "invoice_relation_mismatch"
26
+ | "invoice_material_mismatch"
27
+ | "snapshot_relation_mismatch";
28
+
29
+ export type InvoiceInventoryV1 = Readonly<{
30
+ invoice: unknown;
31
+ linePages: readonly unknown[];
32
+ }>;
33
+ export type InvoiceContextV1 = Readonly<{
34
+ original: InvoiceInventoryV1;
35
+ current: InvoiceInventoryV1;
36
+ }>;
37
+ export type HistoricalSnapshotV1 = Readonly<{
38
+ reads: RenewalScheduleMaterialReads;
39
+ invoiceContext: InvoiceContextV1 | null;
40
+ }>;
41
+
42
+ // Exactly seven own enumerable DATA keys, all REQUIRED; no undefined aliases.
43
+ // Raw provider resource/page bodies preserve every admitted unknown own field.
44
+ export type RenewalEvidenceInputV1 = Readonly<{
45
+ version: 1;
46
+ apiVersion: API;
47
+ configuration: ProjectRenewalConfigurationV2Options;
48
+ configureReceipt: ConstructRenewalConfigurationReceiptV2Options | null;
49
+ reads: RenewalScheduleMaterialReads;
50
+ invoiceContext: InvoiceContextV1 | null;
51
+ historicalSnapshot: HistoricalSnapshotV1 | null;
52
+ }>;
53
+
54
+ export type IdentityV1 = Readonly<{
55
+ scope: "platform";
56
+ customerAccountId: string;
57
+ customerId: string;
58
+ livemode: boolean;
59
+ scheduleId: string;
60
+ subscriptionId: string;
61
+ originalItemId: string;
62
+ targetPriceId: string;
63
+ targetProductId: string;
64
+ originalNativePeriod: Period;
65
+ targetBoundary: number;
66
+ }>;
67
+ export type TerminalFactsV1 = Readonly<{
68
+ canceledAt: Presence<number | null>;
69
+ completedAt: Presence<number | null>;
70
+ releasedAt: Presence<number | null>;
71
+ subscriptionId: Presence<string | null>;
72
+ releasedSubscriptionId: Presence<string | null>;
73
+ }>;
74
+ export type CompletionV1 = Readonly<{
75
+ scheduleId: string;
76
+ subscriptionId: string;
77
+ completedAt: number;
78
+ targetPeriod: Period;
79
+ finalPhaseEnd: number;
80
+ endBehavior: "release";
81
+ comparison: "full_normalized_phase_history_match";
82
+ }>;
83
+ export type LifecycleV1 =
84
+ | Readonly<{
85
+ predicate: "status_only";
86
+ providerStatus: "not_started" | "active";
87
+ facts: null;
88
+ completion: null;
89
+ reason: null;
90
+ }>
91
+ | Readonly<{
92
+ predicate: "status_only";
93
+ providerStatus: "canceled" | "released";
94
+ facts: TerminalFactsV1;
95
+ completion: null;
96
+ reason: null;
97
+ }>
98
+ | Readonly<{
99
+ predicate: "completed_correlated";
100
+ providerStatus: "completed";
101
+ facts: TerminalFactsV1;
102
+ completion: CompletionV1;
103
+ reason: null;
104
+ }>
105
+ | Readonly<{
106
+ predicate: "unknown" | "conflict";
107
+ providerStatus: string | null;
108
+ facts: TerminalFactsV1 | null;
109
+ completion: null;
110
+ reason: Reason;
111
+ }>;
112
+ export type MaterialMatchV1 = Readonly<{
113
+ predicate: "current_target_material_match";
114
+ observedItemId: string;
115
+ nativePeriod: Period;
116
+ reason: null;
117
+ }>;
118
+ export type CurrentMaterialV1 =
119
+ | MaterialMatchV1
120
+ | Readonly<{
121
+ predicate: "attached_unconfigured_match" | "pending_material_match";
122
+ observedItemId: null;
123
+ nativePeriod: null;
124
+ reason: null;
125
+ }>
126
+ | Readonly<{
127
+ predicate: "unknown" | "conflict";
128
+ observedItemId: null;
129
+ nativePeriod: null;
130
+ reason: Reason;
131
+ }>;
132
+ export type HistoricalMaterialV1 =
133
+ | Readonly<{
134
+ predicate: "snapshot_target_material_match";
135
+ observedItemId: string;
136
+ nativePeriod: Period;
137
+ reason: null;
138
+ }>
139
+ | Readonly<{
140
+ predicate: "unknown" | "conflict";
141
+ observedItemId: null;
142
+ nativePeriod: null;
143
+ reason: Reason;
144
+ }>;
145
+ export type InvoiceLineMatchV1 = Readonly<{
146
+ invoiceId: string;
147
+ lineId: string;
148
+ subscriptionItemId: string;
149
+ nativePeriod: Period;
150
+ priceId: string;
151
+ productId: string;
152
+ currency: string;
153
+ quantityDecimal: string;
154
+ unitAmountDecimal: string;
155
+ invoiceStatus: "draft" | "open" | "paid" | "uncollectible" | "void" | null;
156
+ }>;
157
+ export type InvoiceEvidenceV1 =
158
+ | Readonly<{
159
+ predicate: "invoice_lines_correlated";
160
+ original: InvoiceLineMatchV1;
161
+ current: InvoiceLineMatchV1;
162
+ reason: null;
163
+ }>
164
+ | Readonly<{
165
+ predicate: "unknown" | "conflict";
166
+ original: null;
167
+ current: null;
168
+ reason: Reason;
169
+ }>;
170
+
171
+ // Exactly twelve own enumerable keys. Every nested union is closed as written.
172
+ // This result never enters the existing owned-observation output admission.
173
+ export type RenewalEvidenceResultV1 = Readonly<{
174
+ version: 1;
175
+ kind: "renewal_evidence_data";
176
+ apiVersion: API;
177
+ identity: IdentityV1 | null;
178
+ lifecycle: LifecycleV1;
179
+ currentMaterial: CurrentMaterialV1;
180
+ historicalMaterial: HistoricalMaterialV1;
181
+ invoiceEvidence: InvoiceEvidenceV1;
182
+ acknowledgementEstablished: false;
183
+ authenticationEstablished: false;
184
+ operationalAuthority: false;
185
+ providerQualificationRequired: true;
186
+ }>;
@@ -0,0 +1,371 @@
1
+ import assert from "node:assert/strict";
2
+ import { afterEach, expect, it, vi } from "vitest";
3
+ import { observationInput } from "../../../../tests/renewalObservation/fixtures.js";
4
+ import {
5
+ prepareRenewalPriceReplacementV2,
6
+ prepareRenewalScheduleAttachmentV2,
7
+ constructRenewalScheduleAttachmentReceiptV2,
8
+ projectRenewalConfigurationV2,
9
+ } from "../renewalV2/index.js";
10
+ import { inspectRenewalScheduleMaterialV2 } from "../renewalV2/observation.js";
11
+ import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
12
+ import { inspectRenewalEvidenceV1 } from "./evidence-v1.js";
13
+ import type {
14
+ IdentityV1,
15
+ LifecycleV1,
16
+ RenewalEvidenceInputV1,
17
+ RenewalEvidenceResultV1,
18
+ TerminalFactsV1,
19
+ } from "./evidence-v1-types.js";
20
+
21
+ const cases = [
22
+ "E01-canceled-facts",
23
+ "E02-released-not-completed",
24
+ "E03-completed-correlated",
25
+ "E04-completed-missing-timestamp",
26
+ "E05-foreign-released-subscription",
27
+ "E06-completed-default-drift",
28
+ ] as const;
29
+ type Case = (typeof cases)[number];
30
+ const present = <T>(value: T) => ({ presence: "present" as const, value });
31
+ function set(object: object, key: string, value: unknown) {
32
+ Object.defineProperty(object, key, {
33
+ value,
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ });
38
+ }
39
+ const base = {
40
+ acknowledgementEstablished: false,
41
+ authenticationEstablished: false,
42
+ providerQualificationRequired: true,
43
+ } as const;
44
+
45
+ /** Every terminal choice is fixed before the actual V2 constructor calls. */
46
+ function recipe(control: Case) {
47
+ const active = control !== "E01-canceled-facts";
48
+ // Maintained pure synthetic provider-shaped declaration, never an old
49
+ // native-window script, live provider fixture or acknowledged Source port.
50
+ const raw = observationInput(active, true);
51
+ const baseline = structuredClone(raw);
52
+ const original = raw.configuration.preparation.subscription.items.data[0];
53
+ const boundary = raw.configuration.preparation.expected.periodEnd;
54
+ const targetEnd = raw.reads.schedule.phases[1].end_date;
55
+ const canceledAt = boundary - 100;
56
+ const completedAt = targetEnd + 60;
57
+ const released =
58
+ control === "E02-released-not-completed" ||
59
+ control === "E05-foreign-released-subscription";
60
+ const status =
61
+ control === "E01-canceled-facts"
62
+ ? "canceled"
63
+ : released
64
+ ? "released"
65
+ : "completed";
66
+ const releasedId =
67
+ control === "E05-foreign-released-subscription"
68
+ ? "sub_foreign"
69
+ : raw.configuration.preparation.expected.subscriptionId;
70
+ set(raw.reads.schedule, "status", status);
71
+ set(raw.reads.schedule, "current_phase", null);
72
+ set(
73
+ raw.reads.schedule,
74
+ "subscription",
75
+ status === "canceled" ? raw.reads.subscription.id : null,
76
+ );
77
+ set(
78
+ raw.reads.schedule,
79
+ "canceled_at",
80
+ status === "canceled" ? canceledAt : null,
81
+ );
82
+ set(
83
+ raw.reads.schedule,
84
+ "completed_at",
85
+ status === "completed" ? completedAt : null,
86
+ );
87
+ set(raw.reads.schedule, "released_at", released ? boundary : null);
88
+ set(
89
+ raw.reads.schedule,
90
+ "released_subscription",
91
+ released ? releasedId : null,
92
+ );
93
+ set(raw.reads.subscription, "schedule", null);
94
+ if (status === "canceled") set(raw.reads.subscription, "status", "canceled");
95
+ if (control === "E04-completed-missing-timestamp") {
96
+ expect(Reflect.deleteProperty(raw.reads.schedule, "completed_at")).toBe(
97
+ true,
98
+ );
99
+ }
100
+ if (control === "E06-completed-default-drift") {
101
+ set(
102
+ raw.reads.schedule.default_settings,
103
+ "description",
104
+ "TEST_DECLARED_DRIFT",
105
+ );
106
+ }
107
+ const identity: IdentityV1 = {
108
+ scope: "platform",
109
+ customerAccountId: raw.configuration.preparation.expected.customerAccountId,
110
+ customerId: raw.reads.billingCustomer.id,
111
+ livemode: raw.configuration.preparation.expected.livemode,
112
+ scheduleId: raw.configuration.schedule.id,
113
+ subscriptionId: raw.configuration.preparation.expected.subscriptionId,
114
+ originalItemId: original.id,
115
+ targetPriceId: raw.configuration.preparation.expected.targetPriceId,
116
+ targetProductId: raw.configuration.targetPrice.product,
117
+ originalNativePeriod: {
118
+ start: original.current_period_start,
119
+ end: original.current_period_end,
120
+ },
121
+ targetBoundary: boundary,
122
+ };
123
+ const facts: TerminalFactsV1 = {
124
+ canceledAt: present(status === "canceled" ? canceledAt : null),
125
+ completedAt:
126
+ control === "E04-completed-missing-timestamp"
127
+ ? { presence: "absent" }
128
+ : present(status === "completed" ? completedAt : null),
129
+ releasedAt: present(released ? boundary : null),
130
+ subscriptionId: present(
131
+ status === "canceled" ? identity.subscriptionId : null,
132
+ ),
133
+ releasedSubscriptionId: present(released ? releasedId : null),
134
+ };
135
+ let lifecycle: LifecycleV1;
136
+ if (control === "E03-completed-correlated") {
137
+ lifecycle = {
138
+ predicate: "completed_correlated",
139
+ providerStatus: "completed",
140
+ facts,
141
+ completion: {
142
+ scheduleId: identity.scheduleId,
143
+ subscriptionId: identity.subscriptionId,
144
+ completedAt,
145
+ targetPeriod: { start: boundary, end: targetEnd },
146
+ finalPhaseEnd: targetEnd,
147
+ endBehavior: "release",
148
+ comparison: "full_normalized_phase_history_match",
149
+ },
150
+ reason: null,
151
+ };
152
+ } else if (control === "E04-completed-missing-timestamp") {
153
+ lifecycle = {
154
+ predicate: "unknown",
155
+ providerStatus: "completed",
156
+ facts,
157
+ completion: null,
158
+ reason: "terminal_completion_unproven",
159
+ };
160
+ } else if (
161
+ control === "E05-foreign-released-subscription" ||
162
+ control === "E06-completed-default-drift"
163
+ ) {
164
+ lifecycle = {
165
+ predicate: "conflict",
166
+ providerStatus: status,
167
+ facts,
168
+ completion: null,
169
+ reason:
170
+ control === "E05-foreign-released-subscription"
171
+ ? "owned_identity_mismatch"
172
+ : "material_mismatch",
173
+ };
174
+ } else {
175
+ assert(status === "canceled" || status === "released");
176
+ lifecycle = {
177
+ predicate: "status_only",
178
+ providerStatus: status,
179
+ facts,
180
+ completion: null,
181
+ reason: null,
182
+ };
183
+ }
184
+ const expected: RenewalEvidenceResultV1 = {
185
+ version: 1,
186
+ kind: "renewal_evidence_data",
187
+ apiVersion: "2026-09-30.endive",
188
+ identity,
189
+ lifecycle,
190
+ currentMaterial: {
191
+ predicate:
192
+ control === "E05-foreign-released-subscription"
193
+ ? "conflict"
194
+ : "unknown",
195
+ observedItemId: null,
196
+ nativePeriod: null,
197
+ reason:
198
+ control === "E05-foreign-released-subscription"
199
+ ? "owned_identity_mismatch"
200
+ : "terminal_completion_unproven",
201
+ },
202
+ historicalMaterial: {
203
+ predicate: "unknown",
204
+ observedItemId: null,
205
+ nativePeriod: null,
206
+ reason: "not_supplied",
207
+ },
208
+ invoiceEvidence: {
209
+ predicate: "unknown",
210
+ original: null,
211
+ current: null,
212
+ reason: "not_supplied",
213
+ },
214
+ acknowledgementEstablished: false,
215
+ authenticationEstablished: false,
216
+ operationalAuthority: false,
217
+ providerQualificationRequired: true,
218
+ };
219
+ const input: RenewalEvidenceInputV1 = {
220
+ version: 1,
221
+ apiVersion: "2026-09-30.endive",
222
+ configuration: raw.configuration,
223
+ configureReceipt: null,
224
+ reads: raw.reads,
225
+ invoiceContext: null,
226
+ historicalSnapshot: null,
227
+ };
228
+ return { input, expected, baseline, status, active, boundary, targetEnd };
229
+ }
230
+
231
+ afterEach(() => vi.unstubAllGlobals());
232
+ it.each(cases)("private evidence V1 %s", async (control) => {
233
+ const h = recipe(control);
234
+ let fetchCalls = 0;
235
+ vi.stubGlobal("fetch", () => {
236
+ fetchCalls++;
237
+ throw Error("UNEXPECTED_PROVIDER_FETCH");
238
+ });
239
+ const before = renewalSnapshot(h.input);
240
+ const serialized = JSON.stringify(before);
241
+ expect(serialized.length).toBeLessThanOrEqual(500000);
242
+ expect(new TextEncoder().encode(serialized).length).toBeLessThanOrEqual(
243
+ 500000,
244
+ );
245
+ expect(Object.keys(h.input).sort()).toEqual([
246
+ "apiVersion",
247
+ "configuration",
248
+ "configureReceipt",
249
+ "historicalSnapshot",
250
+ "invoiceContext",
251
+ "reads",
252
+ "version",
253
+ ]);
254
+ const progress = {
255
+ preparation: 0,
256
+ attachment: 0,
257
+ receipt: 0,
258
+ projection: 0,
259
+ baseline: 0,
260
+ terminalOracle: 0,
261
+ target: 0,
262
+ };
263
+ let failed = false;
264
+ try {
265
+ const source = h.input.configuration.attachReceipt.attachRequest;
266
+ const prepared = await prepareRenewalPriceReplacementV2(source.preparation);
267
+ progress.preparation++;
268
+ const attachment = await prepareRenewalScheduleAttachmentV2({
269
+ prepared,
270
+ apiVersion: source.apiVersion,
271
+ attachKey: source.attachKey,
272
+ firstDispatchedAt: source.firstDispatchedAt,
273
+ });
274
+ expect({
275
+ scope: attachment.scope,
276
+ apiVersion: attachment.apiVersion,
277
+ method: attachment.method,
278
+ path: attachment.path,
279
+ payload: attachment.payload,
280
+ key: attachment.key,
281
+ firstDispatchedAt: attachment.firstDispatchedAt,
282
+ }).toEqual(h.input.configuration.attachReceipt.actualDispatch);
283
+ progress.attachment++;
284
+ const receipt = await constructRenewalScheduleAttachmentReceiptV2(
285
+ h.input.configuration.attachReceipt,
286
+ );
287
+ expect(receipt.scheduleId).toBe(h.expected.identity?.scheduleId);
288
+ expect(receipt.subscriptionId).toBe(h.expected.identity?.subscriptionId);
289
+ expect(receipt.customerAccountId).toBe(
290
+ h.expected.identity?.customerAccountId,
291
+ );
292
+ expect(receipt.livemode).toBe(h.expected.identity?.livemode);
293
+ progress.receipt++;
294
+ const projected = await projectRenewalConfigurationV2(
295
+ h.input.configuration,
296
+ );
297
+ assert(projected.status === "projected_configure_request");
298
+ expect(projected.scheduleId).toBe(receipt.scheduleId);
299
+ expect(projected.apiVersion).toBe("2026-09-30.endive");
300
+ expect(projected.payload.end_behavior).toBe("release");
301
+ progress.projection++;
302
+ expect(await inspectRenewalScheduleMaterialV2(h.baseline)).toEqual(
303
+ h.active
304
+ ? {
305
+ ...base,
306
+ predicate: "current_target_material_match",
307
+ observedItemId: "si_successor",
308
+ nativePeriod: { start: h.boundary, end: h.targetEnd },
309
+ }
310
+ : { ...base, predicate: "pending_material_match" },
311
+ );
312
+ progress.baseline++;
313
+ const old = await inspectRenewalScheduleMaterialV2({
314
+ configuration: h.input.configuration,
315
+ reads: h.input.reads,
316
+ });
317
+ expect(old).toEqual(
318
+ control === "E05-foreign-released-subscription"
319
+ ? {
320
+ ...base,
321
+ predicate: "conflict",
322
+ reason: "terminal_released_relation_mismatch",
323
+ }
324
+ : {
325
+ ...base,
326
+ predicate: "terminal_facts_only",
327
+ providerStatus: h.status,
328
+ effectiveness: "unknown",
329
+ },
330
+ );
331
+ progress.terminalOracle++;
332
+ expect(h.input).toEqual(before);
333
+ progress.target++;
334
+ const actual = await inspectRenewalEvidenceV1(h.input);
335
+ // Honest UNKNOWN scaffold first fails this concrete terminal predicate;
336
+ // no absent module/type/route or constructor error is accepted as RED.
337
+ expect(actual.lifecycle).toEqual(h.expected.lifecycle);
338
+ expect(actual).toEqual(h.expected);
339
+ expect(Reflect.ownKeys(actual)).toHaveLength(12);
340
+ for (const key of Reflect.ownKeys(actual)) {
341
+ expect(typeof key).toBe("string");
342
+ const descriptor = Object.getOwnPropertyDescriptor(actual, key);
343
+ expect(descriptor?.enumerable).toBe(true);
344
+ expect(
345
+ descriptor && Object.prototype.hasOwnProperty.call(descriptor, "value"),
346
+ ).toBe(true);
347
+ }
348
+ } catch (error) {
349
+ failed = true;
350
+ throw error;
351
+ } finally {
352
+ try {
353
+ expect(h.input).toEqual(before);
354
+ expect(JSON.stringify(renewalSnapshot(h.input))).toBe(serialized);
355
+ expect(fetchCalls).toBe(0);
356
+ console.info(
357
+ "RENEWAL_EVIDENCE_TERMINAL_SETTLEMENT",
358
+ JSON.stringify({
359
+ control,
360
+ ...progress,
361
+ inputBytes: new TextEncoder().encode(serialized).length,
362
+ inputUnchanged: true,
363
+ fetchCalls: 0,
364
+ }),
365
+ );
366
+ } catch (error) {
367
+ if (!failed) throw error;
368
+ console.info("RENEWAL_EVIDENCE_TERMINAL_INSPECTION_FAILED");
369
+ }
370
+ }
371
+ });