@fantastic.dev/better-stripe 0.105.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 (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts +23 -0
  4. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js +28 -0
  6. package/dist/client/billing/renewalAttach/internal/c10/configureEvents.js.map +1 -1
  7. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts +200 -0
  8. package/dist/client/billing/renewalAttach/internal/configure/transport.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAttach/internal/configure/transport.js +31 -4
  10. package/dist/client/billing/renewalAttach/internal/configure/transport.js.map +1 -1
  11. package/dist/client/billing/renewalAttach/internal/observation/history.d.ts +41 -0
  12. package/dist/client/billing/renewalAttach/internal/observation/history.d.ts.map +1 -0
  13. package/dist/client/billing/renewalAttach/internal/observation/history.js +161 -0
  14. package/dist/client/billing/renewalAttach/internal/observation/history.js.map +1 -0
  15. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.d.ts +55 -0
  16. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.d.ts.map +1 -0
  17. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.js +83 -0
  18. package/dist/client/billing/renewalAttach/internal/observation/historyEvents.js.map +1 -0
  19. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.d.ts +19 -0
  20. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.d.ts.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.js +11 -0
  22. package/dist/client/billing/renewalAttach/internal/producer/configureAcknowledgement.js.map +1 -0
  23. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.d.ts +56 -0
  24. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.d.ts.map +1 -0
  25. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.js +79 -0
  26. package/dist/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.js.map +1 -0
  27. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.d.ts +31 -0
  28. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.d.ts.map +1 -1
  29. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.js +33 -0
  30. package/dist/client/billing/renewalAttach/internal/producer/configureFrontier.js.map +1 -1
  31. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.d.ts +5 -0
  32. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.d.ts.map +1 -0
  33. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.js +259 -0
  34. package/dist/client/billing/renewalAttach/internal/producer/configureRecovery.js.map +1 -0
  35. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.d.ts +2 -25
  36. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.d.ts.map +1 -1
  37. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.js +15 -30
  38. package/dist/client/billing/renewalAttach/internal/producer/configureWrite.js.map +1 -1
  39. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -16
  40. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +32 -32
  41. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  42. package/dist/component/balanceFunding/mutations.d.ts +43 -43
  43. package/dist/component/balanceFunding/queries.d.ts +1 -1
  44. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  45. package/docs/renewal-context-reads.md +90 -3
  46. package/package.json +1 -1
  47. package/src/client/billing/renewalAttach/internal/c10/configureEvents.ts +37 -0
  48. package/src/client/billing/renewalAttach/internal/configure/transport.ts +37 -4
  49. package/src/client/billing/renewalAttach/internal/observation/history.integration.test.ts +79 -0
  50. package/src/client/billing/renewalAttach/internal/observation/history.ts +200 -0
  51. package/src/client/billing/renewalAttach/internal/observation/historyControls.integration.test.ts +238 -0
  52. package/src/client/billing/renewalAttach/internal/observation/historyEvents.ts +114 -0
  53. package/src/client/billing/renewalAttach/internal/producer/configureAcknowledgement.ts +11 -0
  54. package/src/client/billing/renewalAttach/internal/producer/configureAttemptAuthority.ts +121 -0
  55. package/src/client/billing/renewalAttach/internal/producer/configureFrontier.ts +63 -0
  56. package/src/client/billing/renewalAttach/internal/producer/configureRecovery.ts +361 -0
  57. package/src/client/billing/renewalAttach/internal/producer/configureWrite.ts +18 -47
  58. package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecovery.integration.test.ts +99 -0
  59. package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecoveryControls.integration.test.ts +420 -0
  60. package/src/client/billing/renewalAttach/internal/test-fixtures/historySnapshot.ts +47 -0
@@ -9,17 +9,6 @@ export declare const bridge: import("convex/server").RegisteredAction<"internal"
9
9
  stripeSubscriptionId: string;
10
10
  version: number;
11
11
  }, Promise<{
12
- status: "ready";
13
- value: {
14
- customerAccount: string;
15
- enabled?: boolean | undefined;
16
- paymentMethodId: string | null;
17
- paymentMethodTypes?: string[] | null | undefined;
18
- phase: "apply" | "attach" | "create";
19
- providerApiVersion: string;
20
- stripeSubscriptionId: string;
21
- };
22
- } | {
23
12
  reason: "history_incomplete" | "provider_outcome_unknown";
24
13
  retryable: false;
25
14
  status: "unknown";
@@ -35,5 +24,16 @@ export declare const bridge: import("convex/server").RegisteredAction<"internal"
35
24
  reason: "provider_pending";
36
25
  retryable: true;
37
26
  status: "not_ready";
27
+ } | {
28
+ status: "ready";
29
+ value: {
30
+ customerAccount: string;
31
+ enabled?: boolean | undefined;
32
+ paymentMethodId: string | null;
33
+ paymentMethodTypes?: string[] | null | undefined;
34
+ phase: "apply" | "attach" | "create";
35
+ providerApiVersion: string;
36
+ stripeSubscriptionId: string;
37
+ };
38
38
  }>>;
39
39
  //# sourceMappingURL=actions.d.ts.map
@@ -22,14 +22,6 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
22
22
  requestKey: string;
23
23
  scopeKey: string;
24
24
  }, Promise<{
25
- reason: "identity_changed" | "revision_changed" | "scope_busy";
26
- retryable: false;
27
- status: "conflict";
28
- } | {
29
- reason: "policy_invalid";
30
- retryable: false;
31
- status: "rejected";
32
- } | {
33
25
  operation: {
34
26
  accountId: string;
35
27
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -40,6 +32,14 @@ export declare const begin: import("convex/server").RegisteredMutation<"public",
40
32
  } | {
41
33
  enabled: boolean;
42
34
  status: "unchanged";
35
+ } | {
36
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
37
+ retryable: false;
38
+ status: "conflict";
39
+ } | {
40
+ reason: "policy_invalid";
41
+ retryable: false;
42
+ status: "rejected";
43
43
  } | {
44
44
  reason: "provider_pending";
45
45
  retryable: true;
@@ -395,14 +395,6 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
395
395
  requestKey: string;
396
396
  scopeKey: string;
397
397
  }, Promise<{
398
- reason: "identity_changed" | "revision_changed" | "scope_busy";
399
- retryable: false;
400
- status: "conflict";
401
- } | {
402
- reason: "policy_invalid";
403
- retryable: false;
404
- status: "rejected";
405
- } | {
406
398
  operation: {
407
399
  accountId: string;
408
400
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -413,6 +405,14 @@ export declare const prepare: import("convex/server").RegisteredMutation<"public
413
405
  } | {
414
406
  enabled: boolean;
415
407
  status: "unchanged";
408
+ } | {
409
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
410
+ retryable: false;
411
+ status: "conflict";
412
+ } | {
413
+ reason: "policy_invalid";
414
+ retryable: false;
415
+ status: "rejected";
416
416
  } | {
417
417
  reason: "provider_pending";
418
418
  retryable: true;
@@ -595,22 +595,6 @@ export declare const startWorkflow: import("convex/server").RegisteredMutation<"
595
595
  } & {
596
596
  providerAction: string;
597
597
  }, Promise<{
598
- reason: "history_incomplete" | "provider_outcome_unknown";
599
- retryable: false;
600
- status: "unknown";
601
- } | {
602
- reason: "identity_changed" | "revision_changed" | "scope_busy";
603
- retryable: false;
604
- status: "conflict";
605
- } | {
606
- reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
607
- retryable: false;
608
- status: "rejected";
609
- } | {
610
- reason: "provider_pending";
611
- retryable: true;
612
- status: "not_ready";
613
- } | {
614
598
  operation: {
615
599
  accountId: string;
616
600
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -627,16 +611,7 @@ export declare const startWorkflow: import("convex/server").RegisteredMutation<"
627
611
  version: number;
628
612
  };
629
613
  status: "canceled";
630
- }>>;
631
- export declare const resumeWorkflow: import("convex/server").RegisteredMutation<"public", {
632
- accountId: string;
633
- definitionVersion: string;
634
- operationId: import("convex/values").GenericId<"balanceFundingOperations">;
635
- providerApiVersion: string;
636
- scopeKey: string;
637
- stripeSubscriptionId: string;
638
- version: number;
639
- }, Promise<{
614
+ } | {
640
615
  reason: "history_incomplete" | "provider_outcome_unknown";
641
616
  retryable: false;
642
617
  status: "unknown";
@@ -652,7 +627,16 @@ export declare const resumeWorkflow: import("convex/server").RegisteredMutation<
652
627
  reason: "provider_pending";
653
628
  retryable: true;
654
629
  status: "not_ready";
655
- } | {
630
+ }>>;
631
+ export declare const resumeWorkflow: import("convex/server").RegisteredMutation<"public", {
632
+ accountId: string;
633
+ definitionVersion: string;
634
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
635
+ providerApiVersion: string;
636
+ scopeKey: string;
637
+ stripeSubscriptionId: string;
638
+ version: number;
639
+ }, Promise<{
656
640
  operation: {
657
641
  accountId: string;
658
642
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -669,6 +653,22 @@ export declare const resumeWorkflow: import("convex/server").RegisteredMutation<
669
653
  version: number;
670
654
  };
671
655
  status: "canceled";
656
+ } | {
657
+ reason: "history_incomplete" | "provider_outcome_unknown";
658
+ retryable: false;
659
+ status: "unknown";
660
+ } | {
661
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
662
+ retryable: false;
663
+ status: "conflict";
664
+ } | {
665
+ reason: "invalid_scope" | "policy_invalid" | "unsupported_source";
666
+ retryable: false;
667
+ status: "rejected";
668
+ } | {
669
+ reason: "provider_pending";
670
+ retryable: true;
671
+ status: "not_ready";
672
672
  }>>;
673
673
  export declare const cancelWorkflow: import("convex/server").RegisteredMutation<"public", {
674
674
  accountId: string;
@@ -180,11 +180,11 @@ export declare const findPreparationOperation: import("convex/server").Registere
180
180
  retryable: false;
181
181
  } | {
182
182
  reason?: undefined;
183
+ retryable?: undefined;
183
184
  accountId: string;
184
185
  scopeKey: string;
185
186
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
186
187
  version: number;
187
- retryable?: undefined;
188
188
  status?: undefined;
189
189
  state: "canceled" | "failed" | "pending" | "running" | "succeeded" | "unknown";
190
190
  cancelRequested: boolean;
@@ -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">;
@@ -263,7 +263,7 @@ call.
263
263
 
264
264
  The result is an opaque private view containing `owner`, `basisJSON` and
265
265
  `operationalAuthority: false`. The separate private C10 factory below can use
266
- that identity. Configure recovery actors and public scheduling
266
+ that identity. Cross-process configure recovery and public scheduling
267
267
  remain required, as do genuine generation and operational qualification.
268
268
  Production Source profile arrays remain empty.
269
269
 
@@ -375,8 +375,60 @@ event 3 commits, its actual C10 ACK returns and the final complete history and
375
375
  retention fence passes. The view retains the exact returned output and its
376
376
  receipt/raw-receipt identities. A final guard precedes quarantine discard with
377
377
  no intervening callback or Owner sample. Late fulfillment after retirement stays
378
- unknown and cannot publish ACK custody. This initial-write path supplies no
379
- replay, resumption, public scheduling entrypoint or pending/effective claim.
378
+ unknown and cannot publish ACK custody. This initial-write actor never replays itself. Separate recovery remains explicit;
379
+ public scheduling and pending/effective acceptance remain outstanding.
380
+
381
+ ## Private same-live-Owner configure recovery
382
+
383
+ `captureAdmittedConfigureRecovery(token)` synchronously reserves one recovery
384
+ from the actual original child attempt before its first await. The original
385
+ invocation must have started and settled, with idle journal work and no returned
386
+ ACK. The attempt retains its actual qualified pair, original fresh evidence,
387
+ preflight/profile pointers, immutable C7 and any owned safe response/C9/retention
388
+ reply. A disposition marker, copied token or journal DATA cannot supply that
389
+ custody. The original Owner, SDK client, method, basis and deadlines remain fixed.
390
+ Production Source profile arrays remain empty.
391
+
392
+ `NOT_STARTED`, `PENDING`, unsettled invocations and pending journal RPCs refuse.
393
+ A committed row does not establish that its actual RPC reply returned. Recovery
394
+ also refuses `FULFILLED_SAFE` without the actual saved response or C9. The write
395
+ producer saves that safe response before awaiting response-event publication;
396
+ a failed response append therefore cannot turn an owned response into permission
397
+ for another POST.
398
+
399
+ Unknown replay requires no owned response/C9, exact dispatch-only history and no
400
+ known acknowledgement. A distinct replay transport performs its own fixed fresh
401
+ GET generation. Complete raw baseline equality, fresh C6 reconstruction and the
402
+ captured write predicate must preserve the original C7, key and first-dispatch
403
+ time. Retention requires `0 <= now - originalFirstDispatch < 86400` before
404
+ acquisition and again immediately before POST. The original Owner must still be
405
+ live; this scalar rule never revives it. The actor re-ACKs the identical dispatch
406
+ DATA and repeats the full head-one/ACK-null/idle fence before its single replay
407
+ POST, with zero retries. Baseline drift or an already-applied state never becomes
408
+ a newly projected request.
409
+
410
+ Owned safe-response or C9 completion performs no provider GET or POST. It checks
411
+ the complete existing journal prefix against that actual custody, uses a distinct
412
+ original-journal sender, and re-ACKs or completes matching dispatch/response DATA.
413
+ A stopped original sender cannot be reopened. The actor constructs missing C9
414
+ from the owned response, retains complete canonical C9 and validates retention
415
+ reply/readback before whole-output admission or receipt event three. Matching
416
+ head-three DATA can be re-ACKed after a lost append reply. Every observed retained
417
+ descriptor must stay identical; conflicts refuse without repair. An output-budget
418
+ failure stays unknown with its complete known receipt, never truncated DATA.
419
+
420
+ The unified `readAdmittedConfigureAcknowledgement(token)` returns only actual
421
+ initial or recovered completion. Its output and receipt/raw-receipt identities
422
+ come from the actual returned wrapper. There is no caller receipt/output
423
+ registration API. Final guards precede quarantine discard without intervening
424
+ callbacks. Pending work, retirement or observed pointer changes cannot publish
425
+ late ACK custody or create another recovery reservation.
426
+
427
+ These are bounded read fences, not an atomic provider-writer lock. The recovery
428
+ is process-local and uses the same live Owner; persisted DATA cannot create a new
429
+ Owner or a cross-process execution grant. Public scheduling, cross-process
430
+ recovery, genuine generated/deployed compatibility, provider/native qualification
431
+ and complete Dojo adoption remain separate acceptance work.
380
432
 
381
433
  ## Component operation journal
382
434
 
@@ -855,3 +907,38 @@ custody qualification before it can be enabled; see
855
907
  These helpers retain ordinary provider and caller metadata within their JSON
856
908
  limits. They do not redact, encrypt or certify that input or output is safe to
857
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.105.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",
@@ -1,3 +1,4 @@
1
+ import { readConfigureRecoveryAuthority } from "../producer/configureAttemptAuthority.js";
1
2
  import type { CapturedNode } from "./eventCodec.js";
2
3
  import type {
3
4
  ProjectedRenewalConfigurationV2,
@@ -58,6 +59,42 @@ export function createAdmittedConfigureEventCompiler(token: object) {
58
59
  );
59
60
  return configureEventCompiler(lineage.configuration, channel);
60
61
  }
62
+ const recoveryChannels = new WeakSet<object>();
63
+ /** Distinct original-journal sender after synchronous actual recovery reservation. */
64
+ export function createRecoveryConfigureEventCompiler(recovery: object) {
65
+ need(
66
+ typeof recovery === "object" &&
67
+ recovery !== null &&
68
+ !recoveryChannels.has(recovery),
69
+ );
70
+ recoveryChannels.add(recovery);
71
+ need(arguments.length === 1);
72
+ const state = readConfigureRecoveryAuthority(recovery);
73
+ const lineage = readConfigureLineage(state.token);
74
+ const guard = () => {
75
+ readConfigureRecoveryAuthority(recovery);
76
+ };
77
+ const send = journalWorkForConfigureLineage(state.token).captureSend();
78
+ const channel = createGuardedInitialStageChannel(
79
+ lineage.parentToken,
80
+ {
81
+ timeoutMs: 5000,
82
+ send(
83
+ record: Parameters<typeof send>[0],
84
+ ack: Parameters<typeof send>[1],
85
+ ) {
86
+ guard();
87
+ return send(record, (value) => {
88
+ guard();
89
+ ack(value);
90
+ guard();
91
+ });
92
+ },
93
+ },
94
+ guard,
95
+ );
96
+ return configureEventCompiler(lineage.configuration, channel);
97
+ }
61
98
  function configureEventCompiler(
62
99
  raw: unknown,
63
100
  channel: ReturnType<typeof createStageChannel>,
@@ -357,9 +357,13 @@ export function createConfigureReplayTransport() {
357
357
  return build(loadConfigureReplayTransportSource);
358
358
  }
359
359
 
360
- /** Actual completed preflight custody only; no caller-supplied frame or Owner. */
361
- export function createAdmittedConfigureWriteTransport(token: object) {
362
- const source = captureAdmittedConfigureWriteFrame(token, arguments.length);
360
+ type QualifiedPair = ReturnType<typeof qualifiedWrite>;
361
+ const qualifiedWrites = new WeakMap<object, QualifiedPair>();
362
+ const replayCaptures = new WeakSet<object>();
363
+ function bindQualified(
364
+ source: ReturnType<typeof captureAdmittedConfigureWriteFrame>,
365
+ token: object,
366
+ ) {
363
367
  const pair = configureWriteKernel(source.frame, source.owner, source.guard);
364
368
  need(
365
369
  pair.capability.assertSourceOperationBinding(
@@ -373,5 +377,34 @@ export function createAdmittedConfigureWriteTransport(token: object) {
373
377
  );
374
378
  need(pair.capability.reserveAcquisition());
375
379
  source.guard();
376
- return Object.freeze({ ...pair, ...source });
380
+ return Object.freeze({ ...source, ...pair });
381
+ }
382
+ function qualifiedWrite(token: object, arity: number) {
383
+ return bindQualified(captureAdmittedConfigureWriteFrame(token, arity), token);
384
+ }
385
+ /** Actual completed preflight custody only; no caller-supplied frame or Owner. */
386
+ export function createAdmittedConfigureWriteTransport(token: object) {
387
+ const pair = qualifiedWrite(token, arguments.length);
388
+ qualifiedWrites.set(token, pair);
389
+ return pair;
390
+ }
391
+ /** Original actual pair identity for trusted producers, never reconstructed DATA. */
392
+ export function readOriginalConfigureWriteTransport(token: object) {
393
+ need(arguments.length === 1);
394
+ const pair = qualifiedWrites.get(token);
395
+ need(pair);
396
+ pair.guard();
397
+ return pair;
398
+ }
399
+ /** Separate read generation; explicit recovery admission remains required by its actor. */
400
+ export function createAdmittedConfigureReplayTransport(token: object) {
401
+ need(
402
+ typeof token === "object" && token !== null && !replayCaptures.has(token),
403
+ );
404
+ replayCaptures.add(token);
405
+ need(arguments.length === 1);
406
+ const source = readOriginalConfigureWriteTransport(token);
407
+ const disposition = source.transport.postDisposition();
408
+ need(disposition === "REJECTED" || disposition === "FULFILLED_UNVERIFIED");
409
+ return bindQualified(source, token);
377
410
  }
@@ -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
+ );