@fantastic.dev/better-stripe 0.91.0 → 0.93.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 (132) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts +6 -0
  4. package/dist/client/billing/renewalAttach/internal/configure/actor.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/configure/actor.js +46 -56
  6. package/dist/client/billing/renewalAttach/internal/configure/actor.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts +3 -0
  8. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.d.ts.map +1 -0
  9. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js +61 -0
  10. package/dist/client/billing/renewalAttach/internal/configure/ownedContinuation.js.map +1 -0
  11. package/dist/client/billing/renewalAttach/internal/observation/actor.d.ts.map +1 -1
  12. package/dist/client/billing/renewalAttach/internal/observation/actor.js +25 -4
  13. package/dist/client/billing/renewalAttach/internal/observation/actor.js.map +1 -1
  14. package/dist/client/billing/renewalAttach/internal/observation/capture.d.ts.map +1 -1
  15. package/dist/client/billing/renewalAttach/internal/observation/capture.js +3 -2
  16. package/dist/client/billing/renewalAttach/internal/observation/capture.js.map +1 -1
  17. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts +5 -0
  18. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.d.ts.map +1 -0
  19. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js +11 -0
  20. package/dist/client/billing/renewalAttach/internal/observation/configureAcknowledgement.js.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts +5 -0
  22. package/dist/client/billing/renewalAttach/internal/observation/types.d.ts.map +1 -1
  23. package/dist/client/billing/renewalAttach/internal/observation/types.js.map +1 -1
  24. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts +30 -0
  25. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.d.ts.map +1 -0
  26. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js +113 -0
  27. package/dist/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.js.map +1 -0
  28. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +562 -0
  29. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  30. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +281 -0
  31. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  32. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +562 -0
  33. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  34. package/dist/client/connect/payoutSyncTestHelpers.d.ts +281 -0
  35. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  36. package/dist/client/index.d.ts +3 -2
  37. package/dist/client/index.d.ts.map +1 -1
  38. package/dist/client/index.js +16 -3
  39. package/dist/client/index.js.map +1 -1
  40. package/dist/component/_generated/api.d.ts +6 -0
  41. package/dist/component/_generated/api.d.ts.map +1 -1
  42. package/dist/component/_generated/api.js.map +1 -1
  43. package/dist/component/_generated/component.d.ts +406 -0
  44. package/dist/component/_generated/component.d.ts.map +1 -1
  45. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  46. package/dist/component/earnings/triggers.d.ts +294 -0
  47. package/dist/component/earnings/triggers.d.ts.map +1 -1
  48. package/dist/component/payoutRelease/queries.d.ts +2 -2
  49. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  50. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  51. package/dist/component/renewalOperations/helpers.d.ts +236 -0
  52. package/dist/component/renewalOperations/helpers.d.ts.map +1 -0
  53. package/dist/component/renewalOperations/helpers.js +457 -0
  54. package/dist/component/renewalOperations/helpers.js.map +1 -0
  55. package/dist/component/renewalOperations/mutations.d.ts +252 -0
  56. package/dist/component/renewalOperations/mutations.d.ts.map +1 -0
  57. package/dist/component/renewalOperations/mutations.js +340 -0
  58. package/dist/component/renewalOperations/mutations.js.map +1 -0
  59. package/dist/component/renewalOperations/queries.d.ts +163 -0
  60. package/dist/component/renewalOperations/queries.d.ts.map +1 -0
  61. package/dist/component/renewalOperations/queries.js +167 -0
  62. package/dist/component/renewalOperations/queries.js.map +1 -0
  63. package/dist/component/renewalOperations/schema.d.ts +1988 -0
  64. package/dist/component/renewalOperations/schema.d.ts.map +1 -0
  65. package/dist/component/renewalOperations/schema.js +227 -0
  66. package/dist/component/renewalOperations/schema.js.map +1 -0
  67. package/dist/component/schema.d.ts +281 -0
  68. package/dist/component/schema.js +5 -0
  69. package/dist/component/schema.js.map +1 -1
  70. package/dist/component/usage/allowance.fixtures.d.ts +281 -0
  71. package/dist/component/usage/allowance.fixtures.d.ts.map +1 -1
  72. package/dist/component/usageCredits/accounting.fixtures.d.ts +281 -0
  73. package/dist/component/usageCredits/accounting.fixtures.d.ts.map +1 -1
  74. package/dist/shared/renewalOperationJournal.d.ts +43 -0
  75. package/dist/shared/renewalOperationJournal.d.ts.map +1 -0
  76. package/dist/shared/renewalOperationJournal.js +294 -0
  77. package/dist/shared/renewalOperationJournal.js.map +1 -0
  78. package/docs/renewal-context-reads.md +152 -0
  79. package/docs/renewal-material-observation.md +32 -11
  80. package/package.json +1 -1
  81. package/src/client/billing/renewalAttach/internal/configure/actor.ts +63 -52
  82. package/src/client/billing/renewalAttach/internal/configure/ownedContinuation.ts +56 -0
  83. package/src/client/billing/renewalAttach/internal/observation/actor.ts +46 -3
  84. package/src/client/billing/renewalAttach/internal/observation/capture.ts +3 -2
  85. package/src/client/billing/renewalAttach/internal/observation/configureAcknowledgement.ts +20 -0
  86. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +36 -0
  87. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +48 -0
  88. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +44 -0
  89. package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +34 -0
  90. package/src/client/billing/renewalAttach/internal/observation/types.ts +5 -0
  91. package/src/client/billing/renewalAttach/internal/operationJournal.integration.test.ts +380 -0
  92. package/src/client/billing/renewalAttach/internal/producer/classOwnedActionRoot.ts +155 -0
  93. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +5 -1
  94. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +12 -1
  95. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +38 -0
  96. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +8 -0
  97. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +10 -23
  98. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +115 -0
  99. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +141 -0
  100. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +74 -0
  101. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +79 -0
  102. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +207 -0
  103. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +494 -0
  104. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +452 -0
  105. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +88 -0
  106. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +170 -0
  107. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +99 -0
  108. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +411 -0
  109. package/src/client/index.ts +24 -3
  110. package/src/component/_generated/api.ts +6 -0
  111. package/src/component/_generated/component.ts +450 -0
  112. package/src/component/renewalOperations/acknowledgement.fixtures.ts +552 -0
  113. package/src/component/renewalOperations/acknowledgement.test.ts +573 -0
  114. package/src/component/renewalOperations/acknowledgementReads.test.ts +442 -0
  115. package/src/component/renewalOperations/acknowledgementV2.test.ts +493 -0
  116. package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +373 -0
  117. package/src/component/renewalOperations/basisBinding.test.ts +567 -0
  118. package/src/component/renewalOperations/basisLifecycle.test.ts +569 -0
  119. package/src/component/renewalOperations/boundHistory.test.ts +474 -0
  120. package/src/component/renewalOperations/helpers.ts +592 -0
  121. package/src/component/renewalOperations/historyReads.test.ts +595 -0
  122. package/src/component/renewalOperations/initialBasis.test.ts +578 -0
  123. package/src/component/renewalOperations/journal.test.ts +567 -0
  124. package/src/component/renewalOperations/mutations.ts +456 -0
  125. package/src/component/renewalOperations/payload.test.ts +589 -0
  126. package/src/component/renewalOperations/payloadEncoding.test.ts +592 -0
  127. package/src/component/renewalOperations/queries.ts +204 -0
  128. package/src/component/renewalOperations/schema.ts +268 -0
  129. package/src/component/renewalOperations/timingPolicy.fixtures.ts +193 -0
  130. package/src/component/renewalOperations/timingPolicy.test.ts +523 -0
  131. package/src/component/schema.ts +11 -0
  132. package/src/shared/renewalOperationJournal.ts +333 -0
@@ -1,4 +1,7 @@
1
1
  import { types } from "node:util";
2
+ import { owned } from "./ownedContinuation.js";
3
+ import { renewalSnapshot } from "../../../renewalReplacementSnapshot.js";
4
+ import { freeze } from "../material/nodeKernel.js";
2
5
  import { OWNER } from "../originalOwner.js";
3
6
  import {
4
7
  COMPILED_CONFIGURE_WRITE_ENTRIES as ENTRIES,
@@ -59,7 +62,9 @@ type History = {
59
62
  | "receipt_prepared"
60
63
  | "receipt_recorded";
61
64
  pair: Pair | null;
62
- receipt?: unknown;
65
+ receipt?: Parameters<typeof admitConfigureACK>[2];
66
+ rawReceipt?: Parameters<typeof admitConfigureACK>[1];
67
+ returned: boolean;
63
68
  output?: unknown;
64
69
  };
65
70
  // Local actual Source identities only. JSON and public preflight output never enter this map.
@@ -79,59 +84,62 @@ function isCurrentBundle(
79
84
  wireSubscription: record.configuration.freshSubscription,
80
85
  });
81
86
  }
82
- /** Same original Owner subscription, with FIRST continuation guards on both outcomes. */
83
- function owned<T>(work: () => T | PromiseLike<T>): Promise<T> {
87
+ /** Checked process-local custody only; neither a caller context nor write authority. */
88
+ export function readOwnedConfigureAcknowledgement(
89
+ operation: unknown,
90
+ acknowledgement: unknown,
91
+ record: PreflightRecord,
92
+ actualAttachAcknowledgement: unknown,
93
+ origin: unknown,
94
+ originalEntry: unknown,
95
+ ) {
84
96
  OWNER.check();
85
- return new Promise((resolve, reject) => {
86
- let done = false,
87
- remove: (() => void) | null = null;
88
- const finish = (ok: boolean, value: unknown) => {
89
- if (done) return;
90
- done = true;
91
- remove?.();
92
- if (ok) resolve(value as T);
93
- else reject(value);
94
- };
95
- const retire = () => finish(false, Error("CONFIGURE_WRITE_STOP"));
96
- remove = OWNER.subscribe(retire);
97
- if (done) {
98
- remove();
99
- return;
100
- }
101
- let pending: T | PromiseLike<T>;
102
- try {
103
- OWNER.check();
104
- pending = work();
105
- } catch (error) {
106
- try {
107
- OWNER.check();
108
- finish(false, error);
109
- } catch {
110
- retire();
111
- }
112
- return;
113
- }
114
- void Promise.resolve(pending).then(
115
- (value) => {
116
- if (done) return;
117
- try {
118
- OWNER.check();
119
- finish(true, value);
120
- } catch {
121
- retire();
122
- }
123
- },
124
- (error) => {
125
- if (done) return;
126
- try {
127
- OWNER.check();
128
- finish(false, error);
129
- } catch {
130
- retire();
131
- }
132
- },
133
- );
97
+ need(arguments.length === 6);
98
+ const row = historyFor(operation);
99
+ need(row && row.owner === OWNER && row.basis === OWNER.basis);
100
+ need(
101
+ row.origin === ORIGINAL_ORIGIN_ASSOCIATION &&
102
+ row.origin === origin &&
103
+ row.entry === originalEntry &&
104
+ !types.isProxy(COMPILED_INITIAL_ENTRIES) &&
105
+ Array.isArray(COMPILED_INITIAL_ENTRIES) &&
106
+ COMPILED_INITIAL_ENTRIES.includes(row.entry) &&
107
+ !types.isProxy(ENTRIES) &&
108
+ Array.isArray(ENTRIES) &&
109
+ ENTRIES.includes(row.configureEntry),
110
+ );
111
+ const entry = closed(row.configureEntry, [
112
+ "originalEntry",
113
+ "coversConfigure",
114
+ ]);
115
+ need(entry.originalEntry === row.entry);
116
+ need(
117
+ row.actualAttachAcknowledgement === actualAttachAcknowledgement &&
118
+ equal(row.record, record) &&
119
+ row.lineage.receiptKnown &&
120
+ row.state === "receipt_recorded" &&
121
+ row.returned === true &&
122
+ row.output === acknowledgement &&
123
+ row.rawReceipt &&
124
+ row.receipt,
125
+ );
126
+ // Re-admit the whole18/19 wrapper, then return detached immutable DATA only.
127
+ const admitted = closed(
128
+ admitConfigureACK(row.record, row.rawReceipt, row.receipt),
129
+ [
130
+ "status",
131
+ "originalRecord",
132
+ "rawReceipt",
133
+ "receipt",
134
+ "operationalAuthority",
135
+ ],
136
+ );
137
+ const result = Object.freeze({
138
+ rawReceipt: freeze(renewalSnapshot(row.rawReceipt)),
139
+ receipt: admitted.receipt,
134
140
  });
141
+ OWNER.check();
142
+ return result;
135
143
  }
136
144
  function capture(replay: boolean) {
137
145
  let consumed = false;
@@ -327,6 +335,7 @@ function capture(replay: boolean) {
327
335
  actualAttachAcknowledgement,
328
336
  lineage,
329
337
  state: "not_started",
338
+ returned: false,
330
339
  pair,
331
340
  };
332
341
  attempts.set(live, row);
@@ -504,6 +513,7 @@ function capture(replay: boolean) {
504
513
  OWNER.check();
505
514
  // Actual C9 success is retained before output admission or receipt-event publication.
506
515
  // This closes the whole lineage even if either later admission/publication fails.
516
+ row.rawReceipt = rawReceipt;
507
517
  row.receipt = receipt;
508
518
  row.state = "receipt_prepared";
509
519
  lineage.receiptKnown = true;
@@ -523,6 +533,7 @@ function capture(replay: boolean) {
523
533
  lineage.busy = false;
524
534
  OWNER.check();
525
535
  activePair.capability.discardFulfilledQuarantine();
536
+ row.returned = true;
526
537
  return output;
527
538
  } catch (error) {
528
539
  let live = false;
@@ -0,0 +1,56 @@
1
+ import { OWNER } from "../originalOwner.js";
2
+
3
+ /** Same original Owner subscription, with FIRST continuation guards on both outcomes. */
4
+ export function owned<T>(work: () => T | PromiseLike<T>): Promise<T> {
5
+ OWNER.check();
6
+ return new Promise((resolve, reject) => {
7
+ let done = false,
8
+ remove: (() => void) | null = null;
9
+ const finish = (ok: boolean, value: unknown) => {
10
+ if (done) return;
11
+ done = true;
12
+ remove?.();
13
+ if (ok) resolve(value as T);
14
+ else reject(value);
15
+ };
16
+ const retire = () => finish(false, Error("CONFIGURE_WRITE_STOP"));
17
+ remove = OWNER.subscribe(retire);
18
+ if (done) {
19
+ remove();
20
+ return;
21
+ }
22
+ let pending: T | PromiseLike<T>;
23
+ try {
24
+ OWNER.check();
25
+ pending = work();
26
+ } catch (error) {
27
+ try {
28
+ OWNER.check();
29
+ finish(false, error);
30
+ } catch {
31
+ retire();
32
+ }
33
+ return;
34
+ }
35
+ void Promise.resolve(pending).then(
36
+ (value) => {
37
+ if (done) return;
38
+ try {
39
+ OWNER.check();
40
+ finish(true, value);
41
+ } catch {
42
+ retire();
43
+ }
44
+ },
45
+ (error) => {
46
+ if (done) return;
47
+ try {
48
+ OWNER.check();
49
+ finish(false, error);
50
+ } catch {
51
+ retire();
52
+ }
53
+ },
54
+ );
55
+ });
56
+ }
@@ -9,6 +9,7 @@ import {
9
9
  import {
10
10
  projectRenewalConfigurationV2,
11
11
  constructRenewalScheduleAttachmentReceiptV2,
12
+ constructRenewalConfigurationReceiptV2,
12
13
  } from "../../../renewalV2/index.js";
13
14
  import { inspectRenewalScheduleMaterialV2 } from "../../../renewalV2/observation.js";
14
15
  import { captureObservationRecord, verifyObservationRecord } from "./record.js";
@@ -26,6 +27,7 @@ import {
26
27
  validateCoupon,
27
28
  } from "./profile.js";
28
29
  import { checkOwnerResult } from "./types.js";
30
+ import { admitRetainedConfigureAcknowledgement } from "./configureAcknowledgement.js";
29
31
  import type {
30
32
  Data,
31
33
  SourceMethod,
@@ -148,7 +150,7 @@ export function captureOwnedRenewalObservationV2() {
148
150
  "actualAttachAcknowledgement",
149
151
  "readTransport",
150
152
  ],
151
- ["configureAcknowledgement"],
153
+ ["configureAcknowledgement", "configureOperation"],
152
154
  );
153
155
  need(op.owner === OWNER && OWNER === ORIGINAL_OWNER);
154
156
  need(op.originAssociation === ORIGINAL_ORIGIN_ASSOCIATION);
@@ -158,8 +160,13 @@ export function captureOwnedRenewalObservationV2() {
158
160
  COMPILED_OBSERVATION_ENTRIES.includes(op.observationEntry),
159
161
  );
160
162
  need(field(op.observationEntry, "originalEntry") === op.originalEntry);
163
+ const hasConfigureAcknowledgement = Object.prototype.hasOwnProperty.call(
164
+ op,
165
+ "configureAcknowledgement",
166
+ );
161
167
  need(
162
- !Object.prototype.hasOwnProperty.call(op, "configureAcknowledgement"),
168
+ hasConfigureAcknowledgement ===
169
+ Object.prototype.hasOwnProperty.call(op, "configureOperation"),
163
170
  );
164
171
  const coversRetained = method(op.originalEntry, "coversRetained");
165
172
  const coversObservation = method(
@@ -365,6 +372,39 @@ export function captureOwnedRenewalObservationV2() {
365
372
  ]);
366
373
  ownerCheck();
367
374
  need(covered === true);
375
+ let configureReceipt:
376
+ | import("../../../renewalV2/index.js").ConstructRenewalConfigurationReceiptV2Options
377
+ | undefined;
378
+ if (hasConfigureAcknowledgement) {
379
+ const writer = await owned(() => import("../configure/actor.js"));
380
+ ownerCheck();
381
+ const readOwnedConfigureAcknowledgement =
382
+ writer.readOwnedConfigureAcknowledgement;
383
+ ownerCheck();
384
+ need(
385
+ typeof readOwnedConfigureAcknowledgement === "function" &&
386
+ !types.isProxy(readOwnedConfigureAcknowledgement),
387
+ );
388
+ const retainedACK = readOwnedConfigureAcknowledgement(
389
+ op.configureOperation,
390
+ op.configureAcknowledgement,
391
+ record,
392
+ op.actualAttachAcknowledgement,
393
+ op.originAssociation,
394
+ op.originalEntry,
395
+ );
396
+ ownerCheck();
397
+ const configured = await owned(() =>
398
+ constructRenewalConfigurationReceiptV2(retainedACK.rawReceipt),
399
+ );
400
+ ownerCheck();
401
+ configureReceipt = admitRetainedConfigureAcknowledgement(
402
+ record,
403
+ retainedACK,
404
+ configured,
405
+ );
406
+ ownerCheck();
407
+ }
368
408
  // New child/channel identity is allocated only after all original proof work.
369
409
  invocation = Object.freeze({});
370
410
  generation = Object.freeze({});
@@ -405,6 +445,7 @@ export function captureOwnedRenewalObservationV2() {
405
445
  const input = captureObservationInput({
406
446
  configuration: record.configuration,
407
447
  reads,
448
+ ...(configureReceipt === undefined ? {} : { configureReceipt }),
408
449
  });
409
450
  phase = "observer";
410
451
  const observation = await owned(() =>
@@ -423,7 +464,9 @@ export function captureOwnedRenewalObservationV2() {
423
464
  observation,
424
465
  reads: input.reads,
425
466
  observedAt,
426
- retainedConfigureAcknowledgement: "absent",
467
+ retainedConfigureAcknowledgement: hasConfigureAcknowledgement
468
+ ? "present"
469
+ : "absent",
427
470
  operationalAuthority: false,
428
471
  });
429
472
  ownerCheck();
@@ -126,7 +126,7 @@ export function captureObservationReply(reply: unknown) {
126
126
  return ordinary(Object.fromEntries(entries));
127
127
  }
128
128
  export function captureObservationInput<T>(value: T): T {
129
- const root = closed(value, ["configuration", "reads"]);
129
+ const root = closed(value, ["configuration", "reads"], ["configureReceipt"]);
130
130
  const reads = closed(root.reads, [
131
131
  "schedule",
132
132
  "subscription",
@@ -149,7 +149,8 @@ export function admitObservationOutput<T>(value: T): T {
149
149
  need(
150
150
  root.status === "owned_observation_data" &&
151
151
  root.operationalAuthority === false &&
152
- root.retainedConfigureAcknowledgement === "absent",
152
+ (root.retainedConfigureAcknowledgement === "absent" ||
153
+ root.retainedConfigureAcknowledgement === "present"),
153
154
  );
154
155
  need(
155
156
  typeof root.observedAt === "number" &&
@@ -0,0 +1,20 @@
1
+ import { admitConfigureACK } from "../configure/output.js";
2
+ import { equal } from "../../../renewalAggregate/shared.js";
3
+ import type { RenewalConfigurationReceiptV2 } from "../../../renewalV2/index.js";
4
+ import type {
5
+ ObservationRecord,
6
+ RetainedConfigureAcknowledgement,
7
+ } from "./types.js";
8
+
9
+ /** Stateless whole relation only; the actor must establish actual returned-ACK custody first. */
10
+ export function admitRetainedConfigureAcknowledgement(
11
+ record: ObservationRecord,
12
+ retained: RetainedConfigureAcknowledgement,
13
+ actualReceipt: RenewalConfigurationReceiptV2,
14
+ ) {
15
+ // Existing exact18/19 slot ledger binds the complete request/raw response/default presence.
16
+ admitConfigureACK(record, retained.rawReceipt, actualReceipt);
17
+ if (!equal(actualReceipt, retained.receipt))
18
+ throw Error("OWNED_OBSERVATION_STOP");
19
+ return retained.rawReceipt;
20
+ }
@@ -0,0 +1,36 @@
1
+ import { it } from "vitest";
2
+ import { optionalConfigureACK18Fixture } from "../test-fixtures/observationConfigureACKOperation.js";
3
+ import { assertOptionalConfigureACK18 } from "../test-fixtures/observationConfigureACKAssertions.js";
4
+
5
+ it("owned observation retains actual published configure ACK18 with historical unknown", async () => {
6
+ const h = await optionalConfigureACK18Fixture();
7
+ try {
8
+ const output = await h.capture().invoke();
9
+ assertOptionalConfigureACK18(h, output);
10
+ } catch (originalError) {
11
+ try {
12
+ console.log(
13
+ JSON.stringify({
14
+ kind: "OPTIONAL_ACK18_TARGET_FAILURE_FRONTIER",
15
+ counters: { ...h.counters },
16
+ observationHTTP: h.calls.length,
17
+ originalReadPromises: h.promises.length,
18
+ writerRecords: h.writer.writeState.records.length,
19
+ writerPOSTs: h.writer.writeState.calls.filter(
20
+ (row) => row.method === "POST",
21
+ ).length,
22
+ writerExplicitC9: h.writer.writeState.explicitC9,
23
+ setupRecords: h.writer.state.records.length,
24
+ setupPOSTs: h.writer.state.calls.filter(
25
+ (row) => row.method === "POST",
26
+ ).length,
27
+ operationalAuthority: false,
28
+ }),
29
+ );
30
+ } finally {
31
+ throw originalError;
32
+ }
33
+ } finally {
34
+ await h.cleanup();
35
+ }
36
+ });
@@ -0,0 +1,48 @@
1
+ import assert from "node:assert/strict";
2
+ import { it } from "vitest";
3
+ import { optionalConfigureACKControlCases } from "../test-fixtures/observationConfigureACKDeclarations.js";
4
+ import { optionalConfigureACKControlFixture } from "../test-fixtures/observationConfigureACKOperation.js";
5
+ import {
6
+ assertOptionalConfigureACK18,
7
+ assertOptionalConfigureACKRefusal,
8
+ } from "../test-fixtures/observationConfigureACKAssertions.js";
9
+
10
+ for (const controlCase of optionalConfigureACKControlCases)
11
+ it("owned observation configure ACK control: " + controlCase, async () => {
12
+ const h = await optionalConfigureACKControlFixture(controlCase);
13
+ try {
14
+ const original = h.capture().invoke();
15
+ if (h.selected.stage === "positive")
16
+ assertOptionalConfigureACK18(h, await original);
17
+ else {
18
+ const error = await original.then(
19
+ () => assert.fail("EXPECTED_OPTIONAL_CONFIGURE_ACK_REFUSAL"),
20
+ (error: unknown) => error,
21
+ );
22
+ assertOptionalConfigureACKRefusal(h, error);
23
+ }
24
+ } catch (originalError) {
25
+ try {
26
+ console.log(
27
+ JSON.stringify({
28
+ kind: "OPTIONAL_CONFIGURE_ACK_CONTROL_FAILURE_FRONTIER",
29
+ controlCase,
30
+ declaredStage: h.selected.stage,
31
+ counters: { ...h.counters },
32
+ observationHTTP: h.calls.length,
33
+ originalReadPromises: h.promises.length,
34
+ writerRecords: h.writer.writeState.records.length,
35
+ writerPOSTs: h.writer.writeState.calls.filter(
36
+ (row) => row.method === "POST",
37
+ ).length,
38
+ writerExplicitC9: h.writer.writeState.explicitC9,
39
+ operationalAuthority: false,
40
+ }),
41
+ );
42
+ } finally {
43
+ throw originalError;
44
+ }
45
+ } finally {
46
+ await h.cleanup();
47
+ }
48
+ });
@@ -0,0 +1,44 @@
1
+ import assert from "node:assert/strict";
2
+ import { it } from "vitest";
3
+ import { configureACKLifecycleCases } from "../test-fixtures/observationConfigureACKLifecycleDeclarations.js";
4
+ import { configureACKLifecycleFixture } from "../test-fixtures/observationConfigureACKLifecycleOperation.js";
5
+ import { assertConfigureACKLifecycleResult } from "../test-fixtures/observationConfigureACKLifecycleAssertions.js";
6
+
7
+ for (const controlCase of configureACKLifecycleCases)
8
+ it("owned observation configure ACK lifecycle: " + controlCase, async () => {
9
+ const h = await configureACKLifecycleFixture(controlCase);
10
+ try {
11
+ const original = h.capture().invoke();
12
+ const expectedFailure = controlCase === "L07-C6Failure-priority";
13
+ const value = expectedFailure
14
+ ? await original
15
+ : await original.then(
16
+ () => assert.fail("EXPECTED_LIFECYCLE_REFUSAL"),
17
+ (error: unknown) => error,
18
+ );
19
+ assertConfigureACKLifecycleResult(h, value);
20
+ if (controlCase === "L04-POST-pending") await h.finishPendingWriter();
21
+ } catch (originalError) {
22
+ try {
23
+ console.log(
24
+ JSON.stringify({
25
+ kind: "OPTIONAL_ACK_LIFECYCLE_FAILURE_FRONTIER",
26
+ controlCase,
27
+ counters: { ...h.counters },
28
+ observationHTTP: h.calls.length,
29
+ writerRecords: h.writer.writeState.records.length,
30
+ writerPOSTs: h.writer.writeState.calls.filter(
31
+ (row) => row.method === "POST",
32
+ ).length,
33
+ writerC9: h.writer.writeState.explicitC9,
34
+ candidateKind: h.declaration.candidateKind,
35
+ operationalAuthority: false,
36
+ }),
37
+ );
38
+ } finally {
39
+ throw originalError;
40
+ }
41
+ } finally {
42
+ await h.cleanup();
43
+ }
44
+ });
@@ -0,0 +1,34 @@
1
+ import { it } from "vitest";
2
+ import { configuredHistoryCases } from "../test-fixtures/observationConfiguredHistoryDeclarations.js";
3
+ import { configuredHistoryFixture } from "../test-fixtures/observationConfiguredHistoryOperation.js";
4
+ import { assertConfiguredHistoryResult } from "../test-fixtures/observationConfiguredHistoryAssertions.js";
5
+
6
+ for (const controlCase of configuredHistoryCases)
7
+ it("configured history owned observation: " + controlCase, async () => {
8
+ const h = await configuredHistoryFixture(controlCase);
9
+ try {
10
+ assertConfiguredHistoryResult(h, await h.capture().invoke());
11
+ } catch (originalError) {
12
+ try {
13
+ console.log(
14
+ JSON.stringify({
15
+ kind: "CONFIGURED_HISTORY_FAILURE_FRONTIER",
16
+ controlCase,
17
+ counters: { ...h.counters },
18
+ observationHTTP: h.calls.length,
19
+ originalReadPromises: h.promises.length,
20
+ writerRecords: h.writer.writeState.records.length,
21
+ writerPOSTs: h.writer.writeState.calls.filter(
22
+ (row) => row.method === "POST",
23
+ ).length,
24
+ writerC9: h.writer.writeState.explicitC9,
25
+ operationalAuthority: false,
26
+ }),
27
+ );
28
+ } finally {
29
+ throw originalError;
30
+ }
31
+ } finally {
32
+ await h.cleanup();
33
+ }
34
+ });
@@ -5,6 +5,11 @@ import type { Node } from "../material/nodeKernel.js";
5
5
  import type { inspectRenewalScheduleMaterialV2 } from "../../../renewalV2/observation.js";
6
6
 
7
7
  export type Data = Record<string, unknown>;
8
+ /** Detached immutable DATA after checked actor-local writer custody; never a capability. */
9
+ export interface RetainedConfigureAcknowledgement {
10
+ readonly rawReceipt: import("../../../renewalV2/index.js").ConstructRenewalConfigurationReceiptV2Options;
11
+ readonly receipt: unknown;
12
+ }
8
13
  /** Captured DATA shape only; actual C6/C3/raw proof and Source pointers remain mandatory. */
9
14
  export type ObservationRecord = PreflightRecord;
10
15
  export interface CapturedObservationRecord {