@fabricorg/platform-host 7.2.3 → 7.4.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.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { ActorType, ActionId, ActionStatus, EvidencePacketReference, AgentActionRoute, AgentActionRiskTier, MutationFootprint, ExecutionPrincipal, GovernanceRuntimeEvidence, PolicyOutcome, AssetEventEnvelope, ExecutionAttestation, ExternalReconciliation, PolicyObligation, PolicyObligationStatus, ModuleRegistry, ActionDefinition, AdapterImplementation, FabricRuntimeServices, AgentActionPolicyEvaluator, MutationGovernanceResolver, RuntimePolicyDefinition } from '@fabricorg/platform';
1
+ import { ActorType, ActionId, ActionStatus, EvidencePacketReference, AgentActionRoute, AgentActionRiskTier, MutationFootprint, ExecutionPrincipal, GovernanceRuntimeEvidence, PolicyOutcome, AssetEventEnvelope, ExecutionAttestation, ExternalReconciliation, PolicyObligation, PolicyObligationStatus, ModuleRegistry, ActionDefinition, AdapterImplementation, AdapterCircuitBreakerProvider, FabricRuntimeServices, AgentActionPolicyEvaluator, MutationGovernanceResolver, RuntimePolicyDefinition } from '@fabricorg/platform';
2
+ export { canonicalJson } from '@fabricorg/platform';
2
3
  import { AssemblyLockfile } from '@fabricorg/assembly';
3
4
 
4
5
  /** Version of the vendor-neutral health/readiness contract. */
@@ -12,6 +13,7 @@ declare const PLATFORM_HOST_METRIC_NAMES: {
12
13
  readonly workerCyclesCompleted: "fabric.platform.worker.cycles.completed";
13
14
  readonly workerCyclesFailed: "fabric.platform.worker.cycles.failed";
14
15
  readonly invocationSubmitted: "fabric.platform.invocation.submitted";
16
+ readonly invocationAdmissionRefused: "fabric.platform.invocation.admission_refused";
15
17
  readonly invocationExecutionStarted: "fabric.platform.invocation.execution_started";
16
18
  readonly invocationLeaseClaimed: "fabric.platform.invocation.lease_claimed";
17
19
  readonly invocationCompleted: "fabric.platform.invocation.completed";
@@ -27,6 +29,8 @@ declare const PLATFORM_HOST_METRIC_NAMES: {
27
29
  readonly outboxPublished: "fabric.platform.outbox.published";
28
30
  readonly outboxFailed: "fabric.platform.outbox.failed";
29
31
  readonly outboxDeadLettered: "fabric.platform.outbox.dead_lettered";
32
+ readonly outboxRequeued: "fabric.platform.outbox.requeued";
33
+ readonly outboxRequeueRefused: "fabric.platform.outbox.requeue_refused";
30
34
  readonly invocationBacklog: "fabric.platform.invocation.backlog";
31
35
  readonly invocationRunning: "fabric.platform.invocation.running";
32
36
  readonly invocationExpiredLeases: "fabric.platform.invocation.expired_leases";
@@ -37,7 +41,7 @@ declare const PLATFORM_HOST_METRIC_NAMES: {
37
41
  readonly outboxDeadLetters: "fabric.platform.outbox.dead_letters";
38
42
  };
39
43
  type PlatformHostMetricName = (typeof PLATFORM_HOST_METRIC_NAMES)[keyof typeof PLATFORM_HOST_METRIC_NAMES];
40
- type PlatformHostTelemetryEventName = "worker.cycle.started" | "worker.cycle.completed" | "worker.cycle.failed" | "invocation.submitted" | "invocation.execution_started" | "invocation.lease_claimed" | "invocation.completed" | "invocation.failed" | "invocation.policy_blocked" | "invocation.validation_failed" | "invocation.approval_waited" | "invocation.reconciliation_required" | "outbox.relay.started" | "outbox.relay.completed" | "outbox.relay.failed" | "outbox.lease_claimed" | "outbox.published" | "outbox.failed" | "outbox.dead_lettered";
44
+ type PlatformHostTelemetryEventName = "worker.cycle.started" | "worker.cycle.completed" | "worker.cycle.failed" | "invocation.submitted" | "invocation.admission_refused" | "invocation.execution_started" | "invocation.lease_claimed" | "invocation.completed" | "invocation.failed" | "invocation.policy_blocked" | "invocation.validation_failed" | "invocation.approval_waited" | "invocation.reconciliation_required" | "outbox.relay.started" | "outbox.relay.completed" | "outbox.relay.failed" | "outbox.lease_claimed" | "outbox.published" | "outbox.failed" | "outbox.dead_lettered" | "outbox.requeued" | "outbox.requeue_refused";
41
45
  type PlatformHostMetricType = "counter" | "gauge";
42
46
  type PlatformHostTelemetryAttribute = string | number | boolean;
43
47
  interface PlatformHostLifecycleTelemetry {
@@ -185,6 +189,34 @@ declare class IdempotencyConflictError extends Error {
185
189
  readonly code: "IDEMPOTENCY_CONFLICT";
186
190
  constructor(conflict: IdempotencyConflict);
187
191
  }
192
+ /**
193
+ * Why `submitAction` did not admit a submission of an action that declares
194
+ * `admitSubmission`: `refused`, the check answered `{ admitted: false, code }`
195
+ * with a well-formed code; `failed`, it threw or is not a function;
196
+ * `timed_out`, its answer did not settle within `admissionTimeoutMs`;
197
+ * `invalid_decision`, it answered anything other than `{ admitted: true }`
198
+ * or a well-formed refusal; `invalid_parameters`, the parameters are not a
199
+ * JSON-data object Host could copy at submission (a Proxy, a function, a
200
+ * Date, a typed array or SharedArrayBuffer, a cycle, a getter that throws).
201
+ */
202
+ type ActionAdmissionRefusal = "refused" | "failed" | "timed_out" | "invalid_decision" | "invalid_parameters";
203
+ /**
204
+ * Thrown by `submitAction` when a declared admission check did not admit the
205
+ * submission. Host wrote nothing for it: no invocation, idempotency key,
206
+ * event, policy record or error. The message holds the action id, the
207
+ * refusal and, for `refused`, the check's code; never a submitted value or
208
+ * anything the check threw.
209
+ */
210
+ declare class ActionAdmissionError extends Error {
211
+ readonly actionId: string;
212
+ readonly refusal: ActionAdmissionRefusal;
213
+ /** The check's own code, present only for `refused`. */
214
+ readonly refusalCode?: string | undefined;
215
+ readonly code: "ACTION_ADMISSION_REFUSED";
216
+ constructor(actionId: string, refusal: ActionAdmissionRefusal,
217
+ /** The check's own code, present only for `refused`. */
218
+ refusalCode?: string | undefined);
219
+ }
188
220
  type ExternalCompletionRefusal = "still_executing" | "not_found" | "not_awaiting" | "immediate_contract" | "reference_mismatch" | "provider_mismatch" | "invalid_completion" | "result_invalid";
189
221
  /**
190
222
  * Why a completion was not applied, typed so a webhook handler can answer
@@ -253,6 +285,13 @@ interface ActionInvocationRecord {
253
285
  mutationFootprint?: MutationFootprint;
254
286
  executionPrincipal?: ExecutionPrincipal;
255
287
  runtimeEvidence?: GovernanceRuntimeEvidence;
288
+ /**
289
+ * When `submitAction` admitted the submission through the action's
290
+ * `admitSubmission` check, set on creation and never patched. Host refuses
291
+ * to execute an invocation of an action that declares the check when this
292
+ * is absent, and passes it to the handler as `ActionContext.admittedAt`.
293
+ */
294
+ admittedAt?: Date;
256
295
  error?: string;
257
296
  createdAt: Date;
258
297
  updatedAt: Date;
@@ -447,7 +486,24 @@ interface OutboxEventMetadata {
447
486
  payloadClassification: EventPayloadClassification;
448
487
  traceContext?: Record<string, string>;
449
488
  includeProvenance?: boolean;
489
+ /**
490
+ * Only `true` puts the event's `actorId` and `actorType` on the outbox envelope. Absent or any
491
+ * other value leaves them off, and the outbox record says the actor was `suppressed`.
492
+ */
493
+ includeActor?: boolean;
450
494
  }
495
+ /**
496
+ * Whether Host put actor identity on an outbox record's envelope, decided by `includeActor` when
497
+ * the record was written. A record has no value when it predates the decision (`legacy`).
498
+ */
499
+ type OutboxActorDisclosure = "included" | "suppressed";
500
+ /**
501
+ * What the relay tells a publisher about an envelope's actor identity: the record's
502
+ * `OutboxActorDisclosure`, or `legacy` for a record with none. The memory and PostgreSQL stores
503
+ * hydrate actor identity only for `included` records, so their legacy and suppressed envelopes carry
504
+ * none; a consumer that needs it reads the canonical event.
505
+ */
506
+ type EnterpriseEventActorDisclosure = OutboxActorDisclosure | "legacy";
451
507
  interface EnterpriseEventEnvelope {
452
508
  eventId: string;
453
509
  eventType: string;
@@ -460,6 +516,10 @@ interface EnterpriseEventEnvelope {
460
516
  actionInvocationId?: string;
461
517
  correlationId: string;
462
518
  causationId?: string;
519
+ /** Present only when `includeActor` opted this event in; the key is absent otherwise. */
520
+ actorId?: string;
521
+ /** Present only when `includeActor` opted this event in; the key is absent otherwise. */
522
+ actorType?: string;
463
523
  occurredAt: Date;
464
524
  recordedAt: Date;
465
525
  producerModuleVersion: string;
@@ -478,6 +538,8 @@ interface OutboxRecord {
478
538
  tenantId: string;
479
539
  spaceId: string;
480
540
  event: EnterpriseEventEnvelope;
541
+ /** Absent for a record written before Host recorded the `includeActor` decision. */
542
+ actorDisclosure?: OutboxActorDisclosure;
481
543
  status: OutboxStatus;
482
544
  attemptCount: number;
483
545
  availableAt: Date;
@@ -523,6 +585,125 @@ interface OutboxPlatformHostStore<TDb> extends PlatformHostStore<TDb> {
523
585
  statuses?: OutboxStatus[];
524
586
  }): Promise<OutboxRecord[]>;
525
587
  }
588
+ /**
589
+ * Append-only evidence of one operator requeue of a dead-lettered outbox
590
+ * record. The `prior*` fields are the dead-letter state the requeue replaced,
591
+ * so the failure that exhausted the record stays readable after its attempt
592
+ * budget is reset.
593
+ */
594
+ interface OutboxRequeueRecord {
595
+ id: string;
596
+ outboxId: string;
597
+ tenantId: string;
598
+ spaceId: string;
599
+ eventId: string;
600
+ actorId: string;
601
+ actorType: ActorType;
602
+ /** Operator-supplied justification, persisted as audit evidence. Must not carry secrets. */
603
+ reason: string;
604
+ requeuedAt: Date;
605
+ /** When the requeued record became claimable again. */
606
+ availableAt: Date;
607
+ priorAttemptCount: number;
608
+ priorLastError?: string;
609
+ priorAvailableAt: Date;
610
+ priorLeaseToken: number;
611
+ }
612
+ interface RequeueOutboxDeadLetterStoreInput {
613
+ id: string;
614
+ tenantId: string;
615
+ spaceId: string;
616
+ /** Identity of the evidence row written with the transition. */
617
+ requeueId: string;
618
+ actorId: string;
619
+ actorType: ActorType;
620
+ reason: string;
621
+ requeuedAt: Date;
622
+ availableAt: Date;
623
+ /**
624
+ * The lease token of the dead letter the caller read and authorized. Every
625
+ * claim increments the token and a requeue never lowers it, so a record
626
+ * that was requeued, claimed and dead-lettered again carries a higher token
627
+ * than the one observed, and the requeue is refused as `stale`.
628
+ */
629
+ expectedLeaseToken: number;
630
+ }
631
+ /**
632
+ * `not_found`: no record with this id in the tenant and space, including a
633
+ * record that exists under another tenant or space. `not_dead_letter`: the
634
+ * record exists but is pending or published, for example because another
635
+ * requeue won the compare-and-set. `stale`: the record is a dead letter
636
+ * again, but not the one the caller observed; read and authorize it afresh.
637
+ */
638
+ type OutboxRequeueRefusal = "not_found" | "not_dead_letter" | "stale";
639
+ type RequeueOutboxDeadLetterStoreResult = {
640
+ applied: true;
641
+ record: OutboxRecord;
642
+ requeue: OutboxRequeueRecord;
643
+ } | {
644
+ applied: false;
645
+ refusal: OutboxRequeueRefusal;
646
+ currentStatus?: OutboxStatus;
647
+ };
648
+ /**
649
+ * Optional outbox capability that moves a dead-lettered record back to
650
+ * pending. Kept apart from `OutboxPlatformHostStore` so a custom outbox store
651
+ * that predates it still satisfies that interface.
652
+ */
653
+ interface OutboxRequeuePlatformHostStore<TDb> extends OutboxPlatformHostStore<TDb> {
654
+ getOutboxRecord(id: string, tenantId: string, spaceId: string): Promise<OutboxRecord | undefined>;
655
+ /**
656
+ * Compare-and-set from `dead_letter` at `expectedLeaseToken` to `pending`
657
+ * within the tenant and space: resets `attemptCount` to 0, sets
658
+ * `availableAt`, clears any lease owner while keeping the lease token,
659
+ * keeps `lastError`, and appends one `OutboxRequeueRecord` in the same
660
+ * atomic step. A record in any other state, at another lease token, or in
661
+ * another scope is refused and nothing is written. The returned requeue
662
+ * evidence shares nothing with stored history. The returned outbox record
663
+ * has its own Date fields; its event payload and provenance are shallow.
664
+ */
665
+ requeueOutboxDeadLetter(input: RequeueOutboxDeadLetterStoreInput): Promise<RequeueOutboxDeadLetterStoreResult>;
666
+ /** Requeue evidence for a scope, oldest first; `outboxId` narrows it to one record. */
667
+ listOutboxRequeues(input: {
668
+ tenantId: string;
669
+ spaceId: string;
670
+ outboxId?: string;
671
+ }): Promise<OutboxRequeueRecord[]>;
672
+ }
673
+ interface RequeueOutboxDeadLetterInput {
674
+ outboxId: string;
675
+ tenantId: string;
676
+ spaceId: string;
677
+ /** Trusted operator identity from the caller's authenticated session, never from request input. */
678
+ actorId: string;
679
+ actorType: ActorType;
680
+ /** Required justification, at most 1,000 characters, persisted as audit evidence. */
681
+ reason: string;
682
+ /** When the record becomes claimable again; defaults to the host clock. */
683
+ availableAt?: Date;
684
+ }
685
+ type RequeueOutboxDeadLetterRefusal = OutboxRequeueRefusal | "not_authorized";
686
+ type RequeueOutboxDeadLetterResult = {
687
+ status: "requeued";
688
+ record: OutboxRecord;
689
+ requeue: OutboxRequeueRecord;
690
+ } | {
691
+ status: "refused";
692
+ refusal: RequeueOutboxDeadLetterRefusal;
693
+ /** Present for `not_dead_letter` and `stale`: the state the record was found in. */
694
+ currentStatus?: OutboxStatus;
695
+ message: string;
696
+ };
697
+ /** Facts given to `authorizeOutboxRequeue`. `record` is absent when no record with this id exists in the scope. */
698
+ interface OutboxRequeueAuthorizationInput {
699
+ tenantId: string;
700
+ spaceId: string;
701
+ actorId: string;
702
+ actorType: ActorType;
703
+ outboxId: string;
704
+ reason: string;
705
+ record?: Pick<OutboxRecord["event"], "eventId" | "eventType" | "payloadClassification"> & Pick<OutboxRecord, "status" | "attemptCount">;
706
+ }
526
707
  /**
527
708
  * Optional production capability for atomic domain/event persistence.
528
709
  *
@@ -648,6 +829,16 @@ interface ActionExecutionAuthorizationInput extends ActionAuthorizationInput {
648
829
  invocation: Readonly<ActionInvocationRecord>;
649
830
  executionReason: ActionExecutionReason;
650
831
  }
832
+ /**
833
+ * Input to `resolvePolicies`. Carries the invocation identity and the
834
+ * schema-parsed durable (post-redaction) parameters so a resolver can choose
835
+ * the policy snapshot pinned to this specific invocation. Host keeps the first
836
+ * persisted evaluation per invocation and policy, so return the same snapshot
837
+ * for an `actionInvocationId` on every attempt.
838
+ */
839
+ interface ResolvePoliciesInput extends ActionExecutionAuthorizationInput {
840
+ declaredPolicyIds: readonly string[];
841
+ }
651
842
  interface PlatformHostAuthorization {
652
843
  checkEntitlement(input: ActionAuthorizationInput): Promise<boolean>;
653
844
  authorize(input: ActionAuthorizationInput): Promise<boolean>;
@@ -660,6 +851,12 @@ interface PlatformHostAuthorization {
660
851
  authorizeApproval?(input: ActionAuthorizationInput & {
661
852
  decision: ActionApprovalDecision;
662
853
  }): Promise<boolean>;
854
+ /**
855
+ * Authorization for `requeueOutboxDeadLetter`. There is no action to fall
856
+ * back to, so when this is absent every requeue is refused as
857
+ * `not_authorized`. A throw propagates and nothing is requeued.
858
+ */
859
+ authorizeOutboxRequeue?(input: OutboxRequeueAuthorizationInput): Promise<boolean>;
663
860
  }
664
861
  interface DispatchActionInput {
665
862
  actionInvocationId: string;
@@ -675,6 +872,18 @@ interface DispatchActionResult {
675
872
  interface PlatformActionDispatcher {
676
873
  dispatch(input: DispatchActionInput): Promise<DispatchActionResult>;
677
874
  }
875
+ /**
876
+ * One submission. `submitAction` reads the scalar fields (`actionId`, scope,
877
+ * actor, correlation and causation ids, `executionReason`, `idempotencyKey`,
878
+ * `authorizationBindingId`) exactly once, before its first await, and uses
879
+ * only those values afterwards, so changing them while the call is pending
880
+ * changes no action, scope, actor or key Host authorizes, persists or
881
+ * executes. For an action that declares `admitSubmission`, `parameters`,
882
+ * `provenance` and `authorizationBinding` are also read once there and
883
+ * replaced by Host's own copies. For any other action Host uses those three
884
+ * as the caller's objects, read where and as often as before (README,
885
+ * "Submission snapshot").
886
+ */
678
887
  interface SubmitActionInput {
679
888
  actionId: ActionId;
680
889
  parameters: Record<string, unknown>;
@@ -763,6 +972,15 @@ interface PlatformHostOptions<TDb> {
763
972
  /** Resolve vertical- or runtime-local actions without mutating the process-wide registry. */
764
973
  resolveAction?: (actionId: ActionId) => ActionDefinition<TDb> | undefined;
765
974
  adapters?: readonly AdapterImplementation[];
975
+ /**
976
+ * Supplies the circuit breaker for each adapter call. Defaults to a new
977
+ * `AdapterCircuitBreakerRegistry` per Host instance, which creates one
978
+ * in-process breaker per `adapterType:operation` from that adapter's own
979
+ * `circuitBreaker` config, on first use, and none for adapters without one.
980
+ * Pass a shared registry or a custom provider to share breakers between
981
+ * Host instances, receive breaker telemetry, or set manual overrides.
982
+ */
983
+ adapterCircuitBreakers?: AdapterCircuitBreakerProvider;
766
984
  dispatcher?: PlatformActionDispatcher;
767
985
  services?: FabricRuntimeServices;
768
986
  idempotency?: {
@@ -782,6 +1000,12 @@ interface PlatformHostOptions<TDb> {
782
1000
  producerModuleVersion(actionId: ActionId, actionVersion: number): string;
783
1001
  classifyPayload(event: AssetEventEnvelope): EventPayloadClassification;
784
1002
  includeProvenance?(event: AssetEventEnvelope, classification: EventPayloadClassification): boolean;
1003
+ /**
1004
+ * Opt an event's `actorId` and `actorType` into its outbox envelope. Absent, the actor is
1005
+ * excluded for every classification. Only `true` includes it. An included actor reaches every
1006
+ * sink of every relay reading this outbox.
1007
+ */
1008
+ includeActor?(event: AssetEventEnvelope, classification: EventPayloadClassification): boolean;
785
1009
  traceContext?(event: AssetEventEnvelope): Record<string, string> | undefined;
786
1010
  /** Host lifecycle events are excluded by default; opt in only after making their payload audit-safe. */
787
1011
  shouldPublish?(event: AssetEventEnvelope): boolean;
@@ -816,15 +1040,38 @@ interface PlatformHostOptions<TDb> {
816
1040
  */
817
1041
  composition?: {
818
1042
  assembly: AssemblyLockfile;
1043
+ /**
1044
+ * Receives a fresh object whose action, scope, actor, correlation,
1045
+ * causation, idempotency key, binding id and execution reason are the
1046
+ * ones Host read at submission and persists, whatever the caller
1047
+ * changed on its own object since. For an action without
1048
+ * `admitSubmission`, its `parameters`, `provenance` and
1049
+ * `authorizationBinding` read and assign the caller's input, as when
1050
+ * the callback was handed that input itself; for an action that
1051
+ * declares it, they are fresh copies of Host's snapshot.
1052
+ */
819
1053
  resolveInitiatingReleaseDigest?(input: SubmitActionInput): Promise<string | undefined> | string | undefined;
820
1054
  };
821
1055
  /** Lease held while an approved invocation resumes; defaults to five minutes. */
822
1056
  approvalResumeLeaseDurationMs?: number;
823
- /** Remove forbidden/sensitive fields before durable invocation persistence. */
1057
+ /**
1058
+ * Remove forbidden/sensitive fields before durable invocation persistence.
1059
+ * For an action without `admitSubmission`, receives the caller's
1060
+ * parameters object, before provenance normalization and the composition
1061
+ * callback, as before. For an action that declares it, receives Host's
1062
+ * copy, after the check admitted the submission.
1063
+ */
824
1064
  redactActionParameters?: (actionId: ActionId, parameters: Record<string, unknown>) => Record<string, unknown>;
825
- resolvePolicies?: (input: ActionAuthorizationInput & {
826
- declaredPolicyIds: readonly string[];
827
- }) => Promise<RuntimePolicyDefinition[]>;
1065
+ /**
1066
+ * The bound on an action's `admitSubmission` check. An answer that
1067
+ * settles this many milliseconds or more after the check was called,
1068
+ * measured on the monotonic clock when its promise settles, is refused as
1069
+ * `timed_out` and the check's signal is aborted. A whole number from 1 to
1070
+ * 2 147 483 647 (the timer maximum), or `createGovernedActionHost` throws;
1071
+ * default 10 000.
1072
+ */
1073
+ admissionTimeoutMs?: number;
1074
+ resolvePolicies?: (input: ResolvePoliciesInput) => Promise<RuntimePolicyDefinition[]>;
828
1075
  extractEvents?: (data: Record<string, unknown>) => PendingAssetEvent[];
829
1076
  /** Handler-result fields consumed by extractEvents and omitted from the durable result. */
830
1077
  eventResultFields?: readonly string[];
@@ -863,14 +1110,30 @@ interface GovernedActionHost {
863
1110
  overdue: string[];
864
1111
  }>;
865
1112
  }
1113
+ /**
1114
+ * Host operator operations kept outside `GovernedActionHost`, so an existing
1115
+ * hand-written `GovernedActionHost` still satisfies that interface.
1116
+ * `createGovernedActionHost()` returns both.
1117
+ */
1118
+ interface OutboxRequeueHost {
1119
+ /**
1120
+ * Operator replay of a dead-lettered outbox record: authorize the trusted
1121
+ * actor for the tenant and space against the record as read, then move
1122
+ * that same dead letter back to pending with a fresh attempt budget and
1123
+ * append who, when, and why beside the earlier failure. The relay
1124
+ * republishes it under the same `eventId`. Requires an
1125
+ * `OutboxRequeuePlatformHostStore`; refusals are returned, not thrown.
1126
+ */
1127
+ requeueOutboxDeadLetter(input: RequeueOutboxDeadLetterInput): Promise<RequeueOutboxDeadLetterResult>;
1128
+ }
866
1129
 
867
- declare function createGovernedActionHost<TDb>(options: PlatformHostOptions<TDb>): GovernedActionHost;
1130
+ declare function createGovernedActionHost<TDb>(options: PlatformHostOptions<TDb>): GovernedActionHost & OutboxRequeueHost;
868
1131
 
869
1132
  interface MemoryPlatformHostTransactionProvider<TDb> {
870
1133
  snapshot(db: TDb): TDb;
871
1134
  restore(db: TDb, snapshot: TDb): void;
872
1135
  }
873
- declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb> {
1136
+ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb>, OutboxRequeuePlatformHostStore<TDb> {
874
1137
  readonly db: TDb;
875
1138
  readonly transactionalOutbox: boolean;
876
1139
  transactionWithEvents?: <TResult>(run: (transaction: PlatformHostMutationTransaction<TDb>) => Promise<TResult>) => Promise<TResult>;
@@ -883,6 +1146,13 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
883
1146
  readonly executionAttestations: ExecutionAttestationRecord[];
884
1147
  readonly externalReconciliations: ExternalReconciliationRecord[];
885
1148
  readonly outbox: OutboxRecord[];
1149
+ /**
1150
+ * Requeue evidence is append-only audit history, so unlike the ledger
1151
+ * arrays above, which tests have always inspected and seeded directly, it
1152
+ * is not public: `listOutboxRequeues` returns copies with their own Dates. TypeScript
1153
+ * `private`, as for the store's other internals, is a compile-time guard.
1154
+ */
1155
+ private readonly outboxRequeues;
886
1156
  constructor(db: TDb, transactionProvider?: MemoryPlatformHostTransactionProvider<TDb>);
887
1157
  transaction<TResult>(run: (db: TDb) => Promise<TResult>): Promise<TResult>;
888
1158
  private runTransactionWithEvents;
@@ -929,6 +1199,13 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
929
1199
  spaceId?: string;
930
1200
  statuses?: OutboxStatus[];
931
1201
  }): Promise<OutboxRecord[]>;
1202
+ getOutboxRecord(id: string, tenantId: string, spaceId: string): Promise<OutboxRecord | undefined>;
1203
+ requeueOutboxDeadLetter(input: RequeueOutboxDeadLetterStoreInput): Promise<RequeueOutboxDeadLetterStoreResult>;
1204
+ listOutboxRequeues(input: {
1205
+ tenantId: string;
1206
+ spaceId: string;
1207
+ outboxId?: string;
1208
+ }): Promise<OutboxRequeueRecord[]>;
932
1209
  private requireLeasedOutbox;
933
1210
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
934
1211
  getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
@@ -941,10 +1218,18 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
941
1218
  }
942
1219
 
943
1220
  declare function toEnterpriseEventEnvelope(event: AssetEventEnvelope, metadata: OutboxEventMetadata): EnterpriseEventEnvelope;
1221
+ /** The `includeActor` decision a store records with the outbox record it writes from `metadata`. */
1222
+ declare function outboxActorDisclosure(metadata: OutboxEventMetadata): OutboxActorDisclosure;
1223
+ interface EnterpriseEventPublishContext {
1224
+ signal: AbortSignal;
1225
+ /**
1226
+ * Why the envelope does or does not carry `actorId`/`actorType`. `runOutboxRelayCycle()` always
1227
+ * sets it; a caller other than the relay may omit it, which a consumer should treat like `legacy`.
1228
+ */
1229
+ actorDisclosure?: EnterpriseEventActorDisclosure;
1230
+ }
944
1231
  interface EnterpriseEventPublisher {
945
- publish(event: EnterpriseEventEnvelope, context?: {
946
- signal: AbortSignal;
947
- }): Promise<void>;
1232
+ publish(event: EnterpriseEventEnvelope, context?: EnterpriseEventPublishContext): Promise<void>;
948
1233
  }
949
1234
  interface OutboxRelayOptions<TDb> {
950
1235
  store: OutboxPlatformHostStore<TDb>;
@@ -966,6 +1251,10 @@ interface OutboxRelayResult {
966
1251
  deadLettered: number;
967
1252
  }
968
1253
  declare function runOutboxRelayCycle<TDb>(options: OutboxRelayOptions<TDb>): Promise<OutboxRelayResult>;
1254
+ /**
1255
+ * A copy with its own Date fields and trace context. The event payload and
1256
+ * provenance are shallow: the copy shares them with the record, as before.
1257
+ */
969
1258
  declare function cloneOutboxRecord(record: OutboxRecord): OutboxRecord;
970
1259
 
971
1260
  interface PlatformHostSqlResult<Row = Record<string, unknown>> {
@@ -990,7 +1279,7 @@ interface PostgresPlatformHostTransactionProvider<TDb> {
990
1279
  run<TResult>(run: (context: PostgresPlatformHostTransactionContext<TDb>) => Promise<TResult>): Promise<TResult>;
991
1280
  }
992
1281
  /** Durable mutation-pipeline ledger for Databricks Lakebase or standard Postgres. */
993
- declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb> {
1282
+ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb>, OutboxRequeuePlatformHostStore<TDb> {
994
1283
  readonly db: TDb;
995
1284
  private readonly sql;
996
1285
  readonly transactionWithEvents?: AtomicMutationPlatformHostStore<TDb>["transactionWithEvents"];
@@ -1041,6 +1330,13 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
1041
1330
  spaceId?: string;
1042
1331
  statuses?: OutboxStatus[];
1043
1332
  }): Promise<OutboxRecord[]>;
1333
+ getOutboxRecord(id: string, tenantId: string, spaceId: string): Promise<OutboxRecord | undefined>;
1334
+ requeueOutboxDeadLetter(input: RequeueOutboxDeadLetterStoreInput): Promise<RequeueOutboxDeadLetterStoreResult>;
1335
+ listOutboxRequeues(input: {
1336
+ tenantId: string;
1337
+ spaceId: string;
1338
+ outboxId?: string;
1339
+ }): Promise<OutboxRequeueRecord[]>;
1044
1340
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
1045
1341
  getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
1046
1342
  listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
@@ -1066,7 +1362,7 @@ interface PostgresMigration {
1066
1362
  declare function applyPostgresMigrations(client: PlatformHostSqlClient, migrations: readonly PostgresMigration[]): Promise<void>;
1067
1363
 
1068
1364
  declare const PARAMETER_DIGEST_ALGORITHM: "fabric-canonical-json-sha256-v1";
1069
- declare function canonicalJson(value: unknown): string;
1365
+
1070
1366
  declare function digestParameters(parameters: unknown): string;
1071
1367
 
1072
1368
  /**
@@ -1229,4 +1525,4 @@ declare function tenantIsolationChecks(): readonly TenantIsolationCheck[];
1229
1525
  /** Run every check, returning each result rather than throwing on the first. */
1230
1526
  declare function runTenantIsolationChecks(subject: TenantIsolationSubject): Promise<TenantIsolationResult>;
1231
1527
 
1232
- export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationPatch, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type AdapterReconciliationOutcome, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type AtomicMutationPlatformHostStore, type AuthorizationBinding, type AuthorizationGoverningMoment, type AuthorizationReconciliationOutcome, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type ClaimOutboxInput, type CreateActionInvocationInput, type CreateDurableSagaParentLifecycleOptions, type DispatchActionInput, type DispatchActionResult, type EnterpriseEventEnvelope, type EnterpriseEventPublisher, type EventPayloadClassification, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalCompletion, ExternalCompletionError, type ExternalCompletionRefusal, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type HostCompensationRecord, type HostSagaParentApprovalInput, type HostSagaParentCancellationInput, type HostSagaParentCompletionInput, type HostSagaParentFailureInput, type HostSagaParentLifecycle, type HostSagaParentProgressInput, type HostSagaParentProgressRecord, type IdempotencyConflict, IdempotencyConflictError, type InvocationProvenance, type InvocationSource, type KnownActionExecutionReason, type ListActionInvocationsInput, MemoryPlatformHostStore, type MemoryPlatformHostTransactionProvider, type NamespacedAttributes, type OutboxEventMetadata, type OutboxPlatformHostStore, type OutboxRecord, type OutboxRelayOptions, type OutboxRelayResult, type OutboxStatus, PARAMETER_DIGEST_ALGORITHM, PLATFORM_HOST_CONTRACT_VERSION, PLATFORM_HOST_HEALTH_CONTRACT_VERSION, PLATFORM_HOST_METRIC_NAMES, type PendingAssetEvent, type PendingExternalCompletion, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostHealthCounts, type PlatformHostHealthOptions, type PlatformHostHealthQuery, type PlatformHostHealthSnapshot, type PlatformHostHealthStatus, type PlatformHostHealthStore, type PlatformHostLifecycleTelemetry, type PlatformHostMetricName, type PlatformHostMetricTelemetry, type PlatformHostMetricType, type PlatformHostMutationTransaction, type PlatformHostOptions, type PlatformHostReadinessReason, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PlatformHostTelemetry, type PlatformHostTelemetryAttribute, type PlatformHostTelemetryEventName, type PlatformHostTelemetryHook, type PlatformHostTelemetryInput, type PlatformHostTelemetryRecord, type PlatformHostWorkerHealthInput, type PolicyEvaluationRecord, type PolicyObligationRecord, type PostgresMigration, PostgresPlatformHostStore, type PostgresPlatformHostTransactionContext, type PostgresPlatformHostTransactionProvider, type ReconcileOverdueCompletionsInput, type RecordedExternalCompletion, type RecoverablePlatformHostStore, type RenewActionInvocationLeaseInput, type SubmitActionInput, type SubmitActionResult, type TenantIsolationCheck, type TenantIsolationResult, type TenantIsolationScope, type TenantIsolationSubject, type UpdateLeasedActionInvocationInput, applyPostgresMigrations, canonicalJson, cloneOutboxRecord, createDurableSagaParentLifecycle, createGovernedActionHost, createStoreBackedActionDispatcher, digestParameters, emitPlatformHostTelemetry, getPlatformHostHealthSnapshot, runOutboxRelayCycle, runPlatformActionWorker, runPlatformActionWorkerCycle, runTenantIsolationChecks, tenantIsolationChecks, toEnterpriseEventEnvelope };
1528
+ export { ActionAdmissionError, type ActionAdmissionRefusal, type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationPatch, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type AdapterReconciliationOutcome, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type AtomicMutationPlatformHostStore, type AuthorizationBinding, type AuthorizationGoverningMoment, type AuthorizationReconciliationOutcome, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type ClaimOutboxInput, type CreateActionInvocationInput, type CreateDurableSagaParentLifecycleOptions, type DispatchActionInput, type DispatchActionResult, type EnterpriseEventActorDisclosure, type EnterpriseEventEnvelope, type EnterpriseEventPublishContext, type EnterpriseEventPublisher, type EventPayloadClassification, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalCompletion, ExternalCompletionError, type ExternalCompletionRefusal, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type HostCompensationRecord, type HostSagaParentApprovalInput, type HostSagaParentCancellationInput, type HostSagaParentCompletionInput, type HostSagaParentFailureInput, type HostSagaParentLifecycle, type HostSagaParentProgressInput, type HostSagaParentProgressRecord, type IdempotencyConflict, IdempotencyConflictError, type InvocationProvenance, type InvocationSource, type KnownActionExecutionReason, type ListActionInvocationsInput, MemoryPlatformHostStore, type MemoryPlatformHostTransactionProvider, type NamespacedAttributes, type OutboxActorDisclosure, type OutboxEventMetadata, type OutboxPlatformHostStore, type OutboxRecord, type OutboxRelayOptions, type OutboxRelayResult, type OutboxRequeueAuthorizationInput, type OutboxRequeueHost, type OutboxRequeuePlatformHostStore, type OutboxRequeueRecord, type OutboxRequeueRefusal, type OutboxStatus, PARAMETER_DIGEST_ALGORITHM, PLATFORM_HOST_CONTRACT_VERSION, PLATFORM_HOST_HEALTH_CONTRACT_VERSION, PLATFORM_HOST_METRIC_NAMES, type PendingAssetEvent, type PendingExternalCompletion, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostHealthCounts, type PlatformHostHealthOptions, type PlatformHostHealthQuery, type PlatformHostHealthSnapshot, type PlatformHostHealthStatus, type PlatformHostHealthStore, type PlatformHostLifecycleTelemetry, type PlatformHostMetricName, type PlatformHostMetricTelemetry, type PlatformHostMetricType, type PlatformHostMutationTransaction, type PlatformHostOptions, type PlatformHostReadinessReason, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PlatformHostTelemetry, type PlatformHostTelemetryAttribute, type PlatformHostTelemetryEventName, type PlatformHostTelemetryHook, type PlatformHostTelemetryInput, type PlatformHostTelemetryRecord, type PlatformHostWorkerHealthInput, type PolicyEvaluationRecord, type PolicyObligationRecord, type PostgresMigration, PostgresPlatformHostStore, type PostgresPlatformHostTransactionContext, type PostgresPlatformHostTransactionProvider, type ReconcileOverdueCompletionsInput, type RecordedExternalCompletion, type RecoverablePlatformHostStore, type RenewActionInvocationLeaseInput, type RequeueOutboxDeadLetterInput, type RequeueOutboxDeadLetterRefusal, type RequeueOutboxDeadLetterResult, type RequeueOutboxDeadLetterStoreInput, type RequeueOutboxDeadLetterStoreResult, type ResolvePoliciesInput, type SubmitActionInput, type SubmitActionResult, type TenantIsolationCheck, type TenantIsolationResult, type TenantIsolationScope, type TenantIsolationSubject, type UpdateLeasedActionInvocationInput, applyPostgresMigrations, cloneOutboxRecord, createDurableSagaParentLifecycle, createGovernedActionHost, createStoreBackedActionDispatcher, digestParameters, emitPlatformHostTelemetry, getPlatformHostHealthSnapshot, outboxActorDisclosure, runOutboxRelayCycle, runPlatformActionWorker, runPlatformActionWorkerCycle, runTenantIsolationChecks, tenantIsolationChecks, toEnterpriseEventEnvelope };