@fabricorg/platform-host 1.0.0 → 2.0.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
@@ -131,10 +131,78 @@ interface PlatformHostStore<TDb> {
131
131
  interface PlatformHostMutationTransaction<TDb> {
132
132
  readonly db: TDb;
133
133
  appendEvent(event: AssetEventEnvelope): Promise<void>;
134
+ appendEventWithOutbox?(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
134
135
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
135
136
  listEvents(tenantId: string, spaceId: string): Promise<AssetEventEnvelope[]>;
136
137
  updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: Partial<Pick<ActionInvocationRecord, "status" | "result" | "error">>): Promise<void>;
137
138
  }
139
+ type OutboxStatus = "pending" | "published" | "dead_letter";
140
+ type EventPayloadClassification = "public" | "internal" | "confidential" | "restricted";
141
+ interface OutboxEventMetadata {
142
+ producerModuleVersion: string;
143
+ payloadClassification: EventPayloadClassification;
144
+ traceContext?: Record<string, string>;
145
+ }
146
+ interface EnterpriseEventEnvelope {
147
+ eventId: string;
148
+ eventType: string;
149
+ eventSchemaVersion: number;
150
+ tenantId: string;
151
+ spaceId: string;
152
+ subjectType: string;
153
+ subjectId: string;
154
+ sequence: number;
155
+ actionInvocationId?: string;
156
+ correlationId: string;
157
+ causationId?: string;
158
+ occurredAt: Date;
159
+ recordedAt: Date;
160
+ producerModuleVersion: string;
161
+ payloadClassification: EventPayloadClassification;
162
+ traceContext?: Record<string, string>;
163
+ payload: unknown;
164
+ }
165
+ interface OutboxRecord {
166
+ id: string;
167
+ tenantId: string;
168
+ spaceId: string;
169
+ event: EnterpriseEventEnvelope;
170
+ status: OutboxStatus;
171
+ attemptCount: number;
172
+ availableAt: Date;
173
+ leaseOwner?: string;
174
+ leaseExpiresAt?: Date;
175
+ lastError?: string;
176
+ createdAt: Date;
177
+ publishedAt?: Date;
178
+ }
179
+ interface ClaimOutboxInput {
180
+ workerId: string;
181
+ leaseDurationMs: number;
182
+ limit?: number;
183
+ tenantId?: string;
184
+ spaceId?: string;
185
+ now?: Date;
186
+ }
187
+ interface OutboxPlatformHostStore<TDb> extends PlatformHostStore<TDb> {
188
+ /** True only when transactionWithEvents supplies appendEventWithOutbox in the same unit of work. */
189
+ readonly transactionalOutbox?: boolean;
190
+ appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
191
+ claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
192
+ markOutboxPublished(id: string, workerId: string, publishedAt: Date): Promise<void>;
193
+ markOutboxFailed(input: {
194
+ id: string;
195
+ workerId: string;
196
+ error: string;
197
+ availableAt: Date;
198
+ deadLetter: boolean;
199
+ }): Promise<void>;
200
+ listOutbox(input?: {
201
+ tenantId?: string;
202
+ spaceId?: string;
203
+ statuses?: OutboxStatus[];
204
+ }): Promise<OutboxRecord[]>;
205
+ }
138
206
  /**
139
207
  * Optional production capability for atomic domain/event persistence.
140
208
  *
@@ -309,6 +377,12 @@ interface PlatformHostOptions<TDb> {
309
377
  adapters?: readonly AdapterImplementation[];
310
378
  dispatcher?: PlatformActionDispatcher;
311
379
  services?: FabricRuntimeServices;
380
+ /** Requires an outbox-capable store; every canonical event is then appended with delivery state. */
381
+ outbox?: {
382
+ producerModuleVersion(actionId: ActionId, actionVersion: number): string;
383
+ classifyPayload(event: AssetEventEnvelope): EventPayloadClassification;
384
+ traceContext?(event: AssetEventEnvelope): Record<string, string> | undefined;
385
+ };
312
386
  /** Optional vertical-owned evaluator. When absent, agent behavior is unchanged. */
313
387
  hitlEvaluator?: AgentActionPolicyEvaluator;
314
388
  /** Durable evaluator/ruleset version recorded with every HITL decision. */
@@ -359,7 +433,7 @@ interface GovernedActionHost {
359
433
 
360
434
  declare function createGovernedActionHost<TDb>(options: PlatformHostOptions<TDb>): GovernedActionHost;
361
435
 
362
- declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb> {
436
+ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb> {
363
437
  readonly db: TDb;
364
438
  readonly invocations: ActionInvocationRecord[];
365
439
  readonly policyEvaluations: PolicyEvaluationRecord[];
@@ -368,6 +442,7 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
368
442
  readonly policyObligations: PolicyObligationRecord[];
369
443
  readonly executionAttestations: ExecutionAttestationRecord[];
370
444
  readonly externalReconciliations: ExternalReconciliationRecord[];
445
+ readonly outbox: OutboxRecord[];
371
446
  constructor(db: TDb);
372
447
  transaction<TResult>(run: (db: TDb) => Promise<TResult>): Promise<TResult>;
373
448
  createActionInvocation(input: CreateActionInvocationInput): Promise<ActionInvocationRecord>;
@@ -390,6 +465,22 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
390
465
  getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
391
466
  updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>): Promise<void>;
392
467
  appendEvent(event: AssetEventEnvelope): Promise<void>;
468
+ appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
469
+ claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
470
+ markOutboxPublished(id: string, workerId: string, publishedAt: Date): Promise<void>;
471
+ markOutboxFailed(input: {
472
+ id: string;
473
+ workerId: string;
474
+ error: string;
475
+ availableAt: Date;
476
+ deadLetter: boolean;
477
+ }): Promise<void>;
478
+ listOutbox(input?: {
479
+ tenantId?: string;
480
+ spaceId?: string;
481
+ statuses?: OutboxStatus[];
482
+ }): Promise<OutboxRecord[]>;
483
+ private requireLeasedOutbox;
393
484
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
394
485
  getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
395
486
  listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
@@ -397,6 +488,29 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
397
488
  listEvents(tenantId: string, spaceId: string): Promise<AssetEventEnvelope[]>;
398
489
  }
399
490
 
491
+ declare function toEnterpriseEventEnvelope(event: AssetEventEnvelope, metadata: OutboxEventMetadata): EnterpriseEventEnvelope;
492
+ interface EnterpriseEventPublisher {
493
+ publish(event: EnterpriseEventEnvelope): Promise<void>;
494
+ }
495
+ interface OutboxRelayOptions<TDb> {
496
+ store: OutboxPlatformHostStore<TDb>;
497
+ publisher: EnterpriseEventPublisher;
498
+ workerId: string;
499
+ leaseDurationMs?: number;
500
+ batchSize?: number;
501
+ maxAttempts?: number;
502
+ retryDelayMs?: (attempt: number) => number;
503
+ now?: () => Date;
504
+ }
505
+ interface OutboxRelayResult {
506
+ claimed: number;
507
+ published: number;
508
+ failed: number;
509
+ deadLettered: number;
510
+ }
511
+ declare function runOutboxRelayCycle<TDb>(options: OutboxRelayOptions<TDb>): Promise<OutboxRelayResult>;
512
+ declare function cloneOutboxRecord(record: OutboxRecord): OutboxRecord;
513
+
400
514
  interface PlatformHostSqlResult<Row = Record<string, unknown>> {
401
515
  rows: Row[];
402
516
  }
@@ -419,10 +533,11 @@ interface PostgresPlatformHostTransactionProvider<TDb> {
419
533
  run<TResult>(run: (context: PostgresPlatformHostTransactionContext<TDb>) => Promise<TResult>): Promise<TResult>;
420
534
  }
421
535
  /** Durable mutation-pipeline ledger for Databricks Lakebase or standard Postgres. */
422
- declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb> {
536
+ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb> {
423
537
  readonly db: TDb;
424
538
  private readonly sql;
425
539
  readonly transactionWithEvents?: AtomicMutationPlatformHostStore<TDb>["transactionWithEvents"];
540
+ readonly transactionalOutbox: boolean;
426
541
  constructor(db: TDb, sql: PlatformHostSqlClient, transactionProvider?: PostgresPlatformHostTransactionProvider<TDb>);
427
542
  ensureSchema(): Promise<void>;
428
543
  transaction<TResult>(run: (db: TDb) => Promise<TResult>): Promise<TResult>;
@@ -446,6 +561,21 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
446
561
  getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
447
562
  updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>): Promise<void>;
448
563
  appendEvent(event: AssetEventEnvelope): Promise<void>;
564
+ appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
565
+ claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
566
+ markOutboxPublished(id: string, workerId: string, publishedAt: Date): Promise<void>;
567
+ markOutboxFailed(input: {
568
+ id: string;
569
+ workerId: string;
570
+ error: string;
571
+ availableAt: Date;
572
+ deadLetter: boolean;
573
+ }): Promise<void>;
574
+ listOutbox(input?: {
575
+ tenantId?: string;
576
+ spaceId?: string;
577
+ statuses?: OutboxStatus[];
578
+ }): Promise<OutboxRecord[]>;
449
579
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
450
580
  getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
451
581
  listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
@@ -463,4 +593,4 @@ declare function runPlatformActionWorkerCycle<TDb>(options: PlatformActionWorker
463
593
  /** Poll until aborted. Each iteration is bounded and waits without busy-spinning. */
464
594
  declare function runPlatformActionWorker<TDb>(options: PlatformActionWorkerOptions<TDb>): Promise<void>;
465
595
 
466
- export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type AtomicMutationPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, PLATFORM_HOST_CONTRACT_VERSION, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostMutationTransaction, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type PostgresPlatformHostTransactionContext, type PostgresPlatformHostTransactionProvider, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
596
+ export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type AtomicMutationPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type ClaimOutboxInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type EnterpriseEventEnvelope, type EnterpriseEventPublisher, type EventPayloadClassification, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, type OutboxEventMetadata, type OutboxPlatformHostStore, type OutboxRecord, type OutboxRelayOptions, type OutboxRelayResult, type OutboxStatus, PLATFORM_HOST_CONTRACT_VERSION, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostMutationTransaction, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type PostgresPlatformHostTransactionContext, type PostgresPlatformHostTransactionProvider, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, cloneOutboxRecord, createGovernedActionHost, createStoreBackedActionDispatcher, runOutboxRelayCycle, runPlatformActionWorker, runPlatformActionWorkerCycle, toEnterpriseEventEnvelope };
package/dist/index.d.ts CHANGED
@@ -131,10 +131,78 @@ interface PlatformHostStore<TDb> {
131
131
  interface PlatformHostMutationTransaction<TDb> {
132
132
  readonly db: TDb;
133
133
  appendEvent(event: AssetEventEnvelope): Promise<void>;
134
+ appendEventWithOutbox?(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
134
135
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
135
136
  listEvents(tenantId: string, spaceId: string): Promise<AssetEventEnvelope[]>;
136
137
  updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: Partial<Pick<ActionInvocationRecord, "status" | "result" | "error">>): Promise<void>;
137
138
  }
139
+ type OutboxStatus = "pending" | "published" | "dead_letter";
140
+ type EventPayloadClassification = "public" | "internal" | "confidential" | "restricted";
141
+ interface OutboxEventMetadata {
142
+ producerModuleVersion: string;
143
+ payloadClassification: EventPayloadClassification;
144
+ traceContext?: Record<string, string>;
145
+ }
146
+ interface EnterpriseEventEnvelope {
147
+ eventId: string;
148
+ eventType: string;
149
+ eventSchemaVersion: number;
150
+ tenantId: string;
151
+ spaceId: string;
152
+ subjectType: string;
153
+ subjectId: string;
154
+ sequence: number;
155
+ actionInvocationId?: string;
156
+ correlationId: string;
157
+ causationId?: string;
158
+ occurredAt: Date;
159
+ recordedAt: Date;
160
+ producerModuleVersion: string;
161
+ payloadClassification: EventPayloadClassification;
162
+ traceContext?: Record<string, string>;
163
+ payload: unknown;
164
+ }
165
+ interface OutboxRecord {
166
+ id: string;
167
+ tenantId: string;
168
+ spaceId: string;
169
+ event: EnterpriseEventEnvelope;
170
+ status: OutboxStatus;
171
+ attemptCount: number;
172
+ availableAt: Date;
173
+ leaseOwner?: string;
174
+ leaseExpiresAt?: Date;
175
+ lastError?: string;
176
+ createdAt: Date;
177
+ publishedAt?: Date;
178
+ }
179
+ interface ClaimOutboxInput {
180
+ workerId: string;
181
+ leaseDurationMs: number;
182
+ limit?: number;
183
+ tenantId?: string;
184
+ spaceId?: string;
185
+ now?: Date;
186
+ }
187
+ interface OutboxPlatformHostStore<TDb> extends PlatformHostStore<TDb> {
188
+ /** True only when transactionWithEvents supplies appendEventWithOutbox in the same unit of work. */
189
+ readonly transactionalOutbox?: boolean;
190
+ appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
191
+ claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
192
+ markOutboxPublished(id: string, workerId: string, publishedAt: Date): Promise<void>;
193
+ markOutboxFailed(input: {
194
+ id: string;
195
+ workerId: string;
196
+ error: string;
197
+ availableAt: Date;
198
+ deadLetter: boolean;
199
+ }): Promise<void>;
200
+ listOutbox(input?: {
201
+ tenantId?: string;
202
+ spaceId?: string;
203
+ statuses?: OutboxStatus[];
204
+ }): Promise<OutboxRecord[]>;
205
+ }
138
206
  /**
139
207
  * Optional production capability for atomic domain/event persistence.
140
208
  *
@@ -309,6 +377,12 @@ interface PlatformHostOptions<TDb> {
309
377
  adapters?: readonly AdapterImplementation[];
310
378
  dispatcher?: PlatformActionDispatcher;
311
379
  services?: FabricRuntimeServices;
380
+ /** Requires an outbox-capable store; every canonical event is then appended with delivery state. */
381
+ outbox?: {
382
+ producerModuleVersion(actionId: ActionId, actionVersion: number): string;
383
+ classifyPayload(event: AssetEventEnvelope): EventPayloadClassification;
384
+ traceContext?(event: AssetEventEnvelope): Record<string, string> | undefined;
385
+ };
312
386
  /** Optional vertical-owned evaluator. When absent, agent behavior is unchanged. */
313
387
  hitlEvaluator?: AgentActionPolicyEvaluator;
314
388
  /** Durable evaluator/ruleset version recorded with every HITL decision. */
@@ -359,7 +433,7 @@ interface GovernedActionHost {
359
433
 
360
434
  declare function createGovernedActionHost<TDb>(options: PlatformHostOptions<TDb>): GovernedActionHost;
361
435
 
362
- declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb> {
436
+ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb> {
363
437
  readonly db: TDb;
364
438
  readonly invocations: ActionInvocationRecord[];
365
439
  readonly policyEvaluations: PolicyEvaluationRecord[];
@@ -368,6 +442,7 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
368
442
  readonly policyObligations: PolicyObligationRecord[];
369
443
  readonly executionAttestations: ExecutionAttestationRecord[];
370
444
  readonly externalReconciliations: ExternalReconciliationRecord[];
445
+ readonly outbox: OutboxRecord[];
371
446
  constructor(db: TDb);
372
447
  transaction<TResult>(run: (db: TDb) => Promise<TResult>): Promise<TResult>;
373
448
  createActionInvocation(input: CreateActionInvocationInput): Promise<ActionInvocationRecord>;
@@ -390,6 +465,22 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
390
465
  getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
391
466
  updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>): Promise<void>;
392
467
  appendEvent(event: AssetEventEnvelope): Promise<void>;
468
+ appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
469
+ claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
470
+ markOutboxPublished(id: string, workerId: string, publishedAt: Date): Promise<void>;
471
+ markOutboxFailed(input: {
472
+ id: string;
473
+ workerId: string;
474
+ error: string;
475
+ availableAt: Date;
476
+ deadLetter: boolean;
477
+ }): Promise<void>;
478
+ listOutbox(input?: {
479
+ tenantId?: string;
480
+ spaceId?: string;
481
+ statuses?: OutboxStatus[];
482
+ }): Promise<OutboxRecord[]>;
483
+ private requireLeasedOutbox;
393
484
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
394
485
  getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
395
486
  listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
@@ -397,6 +488,29 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
397
488
  listEvents(tenantId: string, spaceId: string): Promise<AssetEventEnvelope[]>;
398
489
  }
399
490
 
491
+ declare function toEnterpriseEventEnvelope(event: AssetEventEnvelope, metadata: OutboxEventMetadata): EnterpriseEventEnvelope;
492
+ interface EnterpriseEventPublisher {
493
+ publish(event: EnterpriseEventEnvelope): Promise<void>;
494
+ }
495
+ interface OutboxRelayOptions<TDb> {
496
+ store: OutboxPlatformHostStore<TDb>;
497
+ publisher: EnterpriseEventPublisher;
498
+ workerId: string;
499
+ leaseDurationMs?: number;
500
+ batchSize?: number;
501
+ maxAttempts?: number;
502
+ retryDelayMs?: (attempt: number) => number;
503
+ now?: () => Date;
504
+ }
505
+ interface OutboxRelayResult {
506
+ claimed: number;
507
+ published: number;
508
+ failed: number;
509
+ deadLettered: number;
510
+ }
511
+ declare function runOutboxRelayCycle<TDb>(options: OutboxRelayOptions<TDb>): Promise<OutboxRelayResult>;
512
+ declare function cloneOutboxRecord(record: OutboxRecord): OutboxRecord;
513
+
400
514
  interface PlatformHostSqlResult<Row = Record<string, unknown>> {
401
515
  rows: Row[];
402
516
  }
@@ -419,10 +533,11 @@ interface PostgresPlatformHostTransactionProvider<TDb> {
419
533
  run<TResult>(run: (context: PostgresPlatformHostTransactionContext<TDb>) => Promise<TResult>): Promise<TResult>;
420
534
  }
421
535
  /** Durable mutation-pipeline ledger for Databricks Lakebase or standard Postgres. */
422
- declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb> {
536
+ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostStore<TDb>, ApprovalPlatformHostStore<TDb>, GovernancePlatformHostStore<TDb>, OutboxPlatformHostStore<TDb> {
423
537
  readonly db: TDb;
424
538
  private readonly sql;
425
539
  readonly transactionWithEvents?: AtomicMutationPlatformHostStore<TDb>["transactionWithEvents"];
540
+ readonly transactionalOutbox: boolean;
426
541
  constructor(db: TDb, sql: PlatformHostSqlClient, transactionProvider?: PostgresPlatformHostTransactionProvider<TDb>);
427
542
  ensureSchema(): Promise<void>;
428
543
  transaction<TResult>(run: (db: TDb) => Promise<TResult>): Promise<TResult>;
@@ -446,6 +561,21 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
446
561
  getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
447
562
  updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>): Promise<void>;
448
563
  appendEvent(event: AssetEventEnvelope): Promise<void>;
564
+ appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
565
+ claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
566
+ markOutboxPublished(id: string, workerId: string, publishedAt: Date): Promise<void>;
567
+ markOutboxFailed(input: {
568
+ id: string;
569
+ workerId: string;
570
+ error: string;
571
+ availableAt: Date;
572
+ deadLetter: boolean;
573
+ }): Promise<void>;
574
+ listOutbox(input?: {
575
+ tenantId?: string;
576
+ spaceId?: string;
577
+ statuses?: OutboxStatus[];
578
+ }): Promise<OutboxRecord[]>;
449
579
  nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
450
580
  getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
451
581
  listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
@@ -463,4 +593,4 @@ declare function runPlatformActionWorkerCycle<TDb>(options: PlatformActionWorker
463
593
  /** Poll until aborted. Each iteration is bounded and waits without busy-spinning. */
464
594
  declare function runPlatformActionWorker<TDb>(options: PlatformActionWorkerOptions<TDb>): Promise<void>;
465
595
 
466
- export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type AtomicMutationPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, PLATFORM_HOST_CONTRACT_VERSION, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostMutationTransaction, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type PostgresPlatformHostTransactionContext, type PostgresPlatformHostTransactionProvider, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
596
+ export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type AtomicMutationPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type ClaimOutboxInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type EnterpriseEventEnvelope, type EnterpriseEventPublisher, type EventPayloadClassification, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, type OutboxEventMetadata, type OutboxPlatformHostStore, type OutboxRecord, type OutboxRelayOptions, type OutboxRelayResult, type OutboxStatus, PLATFORM_HOST_CONTRACT_VERSION, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostMutationTransaction, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type PostgresPlatformHostTransactionContext, type PostgresPlatformHostTransactionProvider, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, cloneOutboxRecord, createGovernedActionHost, createStoreBackedActionDispatcher, runOutboxRelayCycle, runPlatformActionWorker, runPlatformActionWorkerCycle, toEnterpriseEventEnvelope };