@fabricorg/platform-host 7.4.0 → 7.5.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/CHANGELOG.md +45 -0
- package/README.md +214 -15
- package/dist/index.cjs +386 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -15
- package/dist/index.d.ts +123 -15
- package/dist/index.js +387 -68
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -217,13 +217,15 @@ declare class ActionAdmissionError extends Error {
|
|
|
217
217
|
/** The check's own code, present only for `refused`. */
|
|
218
218
|
refusalCode?: string | undefined);
|
|
219
219
|
}
|
|
220
|
-
type ExternalCompletionRefusal = "still_executing" | "not_found" | "not_awaiting" | "immediate_contract" | "reference_mismatch" | "provider_mismatch" | "invalid_completion" | "result_invalid";
|
|
220
|
+
type ExternalCompletionRefusal = "still_executing" | "not_found" | "not_awaiting" | "immediate_contract" | "reference_mismatch" | "provider_mismatch" | "invalid_completion" | "result_invalid" | "redaction_failed";
|
|
221
221
|
/**
|
|
222
222
|
* Why a completion was not applied, typed so a webhook handler can answer
|
|
223
223
|
* the external system correctly: `retryable` means the invocation is still
|
|
224
224
|
* being finalized and the same callback will be accepted once it parks, so
|
|
225
225
|
* answer with something the sender retries; anything else is permanent and
|
|
226
|
-
* a retry will get the same refusal.
|
|
226
|
+
* a retry will get the same refusal without a configuration/input change.
|
|
227
|
+
* `redaction_failed` means completion result or error-text redaction failed before writes;
|
|
228
|
+
* it is not retryable.
|
|
227
229
|
*/
|
|
228
230
|
declare class ExternalCompletionError extends Error {
|
|
229
231
|
readonly refusal: ExternalCompletionRefusal;
|
|
@@ -432,6 +434,12 @@ interface AdapterInvocationRecord {
|
|
|
432
434
|
}
|
|
433
435
|
interface CreateActionInvocationInput extends Omit<ActionInvocationRecord, "createdAt" | "updatedAt" | "attemptCount" | "leaseOwner" | "leaseExpiresAt" | "leaseToken"> {
|
|
434
436
|
}
|
|
437
|
+
/** Scope of an adapter checkpoint within its owning action invocation. */
|
|
438
|
+
interface AdapterInvocationScope {
|
|
439
|
+
tenantId: string;
|
|
440
|
+
spaceId: string;
|
|
441
|
+
actionInvocationId: string;
|
|
442
|
+
}
|
|
435
443
|
interface PlatformHostStore<TDb> {
|
|
436
444
|
readonly db: TDb;
|
|
437
445
|
/**
|
|
@@ -445,10 +453,32 @@ interface PlatformHostStore<TDb> {
|
|
|
445
453
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
446
454
|
appendPolicyEvaluation(record: PolicyEvaluationRecord): Promise<void>;
|
|
447
455
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
448
|
-
|
|
449
|
-
|
|
456
|
+
/**
|
|
457
|
+
* Host supplies scope from its store-loaded invocation at adapter call sites.
|
|
458
|
+
* When supplied, stores must match tenant, space, and action invocation:
|
|
459
|
+
* an out-of-scope record returns undefined. Optional for compatibility with
|
|
460
|
+
* existing custom stores and direct callers; tenantIsolationChecks tests
|
|
461
|
+
* scoped read and write conformance.
|
|
462
|
+
*/
|
|
463
|
+
getAdapterInvocation(id: string, scope?: AdapterInvocationScope): Promise<AdapterInvocationRecord | undefined>;
|
|
464
|
+
/**
|
|
465
|
+
* Match all three scope fields when supplied, changing nothing outside it
|
|
466
|
+
* (a not-found error is permitted). Host supplies scope as described above;
|
|
467
|
+
* optional only for compatibility with existing stores and direct callers.
|
|
468
|
+
*/
|
|
469
|
+
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>, scope?: AdapterInvocationScope): Promise<void>;
|
|
450
470
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
451
471
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
472
|
+
/**
|
|
473
|
+
* Return the state and invocation writer of the same event selected by
|
|
474
|
+
* getEntityState, scoped to this subject and tenant/space. Return undefined
|
|
475
|
+
* when that event or its invocation provenance is unavailable. Transaction
|
|
476
|
+
* implementations include pending events visible to getEntityState.
|
|
477
|
+
*/
|
|
478
|
+
getEntityStateSource?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
479
|
+
state: string;
|
|
480
|
+
actionInvocationId: string;
|
|
481
|
+
} | undefined>;
|
|
452
482
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
453
483
|
}
|
|
454
484
|
/**
|
|
@@ -475,6 +505,16 @@ interface PlatformHostMutationTransaction<TDb> {
|
|
|
475
505
|
appendEventWithOutbox?(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
476
506
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
477
507
|
listEvents(tenantId: string, spaceId: string): Promise<AssetEventEnvelope[]>;
|
|
508
|
+
/**
|
|
509
|
+
* Return the state and invocation writer of the same event selected by
|
|
510
|
+
* getEntityState, scoped to this subject and tenant/space. Return undefined
|
|
511
|
+
* when that event or its invocation provenance is unavailable. Transaction
|
|
512
|
+
* implementations include pending events visible to getEntityState.
|
|
513
|
+
*/
|
|
514
|
+
getEntityStateSource?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
515
|
+
state: string;
|
|
516
|
+
actionInvocationId: string;
|
|
517
|
+
} | undefined>;
|
|
478
518
|
getEntityState?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
479
519
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
480
520
|
updateLeasedActionInvocation?(input: UpdateLeasedActionInvocationInput): Promise<boolean>;
|
|
@@ -963,6 +1003,21 @@ interface PlatformActionWorkerCycleResult {
|
|
|
963
1003
|
failed: number;
|
|
964
1004
|
/** Present when claimed agent work was durably parked instead of failing. */
|
|
965
1005
|
waitingForApproval?: number;
|
|
1006
|
+
/**
|
|
1007
|
+
* Present only when > 0: claimed invocations whose execution threw a
|
|
1008
|
+
* RetryableExecutionError (counted by error type, not by where it was thrown).
|
|
1009
|
+
* The row stays leased and a later claim retries it; excluded from failed.
|
|
1010
|
+
*/
|
|
1011
|
+
deferred?: number;
|
|
1012
|
+
}
|
|
1013
|
+
/** Origin of error text redacted before Host records or returns it. */
|
|
1014
|
+
interface ErrorTextRedactionContext {
|
|
1015
|
+
actionId: ActionId;
|
|
1016
|
+
source: "handler" | "adapter" | "external_completion" | "execution";
|
|
1017
|
+
adapterType?: string;
|
|
1018
|
+
operation?: string;
|
|
1019
|
+
/** Adapter vendor or external completion provider. */
|
|
1020
|
+
provider?: string;
|
|
966
1021
|
}
|
|
967
1022
|
interface PlatformHostOptions<TDb> {
|
|
968
1023
|
store: PlatformHostStore<TDb>;
|
|
@@ -979,8 +1034,24 @@ interface PlatformHostOptions<TDb> {
|
|
|
979
1034
|
* `circuitBreaker` config, on first use, and none for adapters without one.
|
|
980
1035
|
* Pass a shared registry or a custom provider to share breakers between
|
|
981
1036
|
* Host instances, receive breaker telemetry, or set manual overrides.
|
|
1037
|
+
* The default key shares failures across tenants and vendors in a registry.
|
|
1038
|
+
* Use `new AdapterCircuitBreakerRegistry({ key: scopedAdapterCircuitBreakerKey })`
|
|
1039
|
+
* for tenant/space/vendor isolation. Host passes trusted tenant/space scope
|
|
1040
|
+
* to the provider. The registry keeps the first config seen for a key;
|
|
1041
|
+
* later conflicting configs reuse that breaker without throwing. Breakers
|
|
1042
|
+
* are never evicted, so scoped keys keep one breaker per scope seen.
|
|
982
1043
|
*/
|
|
983
1044
|
adapterCircuitBreakers?: AdapterCircuitBreakerProvider;
|
|
1045
|
+
/**
|
|
1046
|
+
* Positive integer attempt cap for RetryableExecutionError during governance,
|
|
1047
|
+
* before policy-evaluation persistence (default 5). A leased, idempotent action
|
|
1048
|
+
* below the cap is left running for worker reclaim after lease expiry.
|
|
1049
|
+
* Inline execution, approval resume, exhausted attempts, and non-idempotent
|
|
1050
|
+
* actions fail. Policy persistence, obligation listing/resolution/persistence, state-machine checks,
|
|
1051
|
+
* the handler transaction, handlers, adapters, and finalization are excluded;
|
|
1052
|
+
* their existing failure/reconciliation/recovery semantics apply.
|
|
1053
|
+
*/
|
|
1054
|
+
retryableExecutionMaxAttempts?: number;
|
|
984
1055
|
dispatcher?: PlatformActionDispatcher;
|
|
985
1056
|
services?: FabricRuntimeServices;
|
|
986
1057
|
idempotency?: {
|
|
@@ -1029,6 +1100,7 @@ interface PlatformHostOptions<TDb> {
|
|
|
1029
1100
|
input: Record<string, unknown>;
|
|
1030
1101
|
startedAt: Date;
|
|
1031
1102
|
completedAt: Date;
|
|
1103
|
+
/** Adapter output after redactAdapterOutput, when configured. */
|
|
1032
1104
|
output: Record<string, unknown>;
|
|
1033
1105
|
}) => Promise<ExecutionAttestation | undefined> | ExecutionAttestation | undefined;
|
|
1034
1106
|
/** Package/provider/ruleset generations persisted with every newly created invocation. */
|
|
@@ -1076,6 +1148,33 @@ interface PlatformHostOptions<TDb> {
|
|
|
1076
1148
|
/** Handler-result fields consumed by extractEvents and omitted from the durable result. */
|
|
1077
1149
|
eventResultFields?: readonly string[];
|
|
1078
1150
|
redactAdapterInput?: (actionId: ActionId, adapterType: string, operation: string, input: Record<string, unknown>) => Record<string, unknown>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Redact successful adapter output before row/event persistence and attestation extraction.
|
|
1153
|
+
* A throwing hook or a null, array or non-object return withholds output and requires reconciliation.
|
|
1154
|
+
* Class instances and Dates are accepted, matching the adapter output record contract.
|
|
1155
|
+
* Keep redactors deterministic and stable across deploys.
|
|
1156
|
+
* Accepted-operation references are read from the original adapter result.
|
|
1157
|
+
*/
|
|
1158
|
+
redactAdapterOutput?: (actionId: ActionId, adapterType: string, operation: string, output: Record<string, unknown>) => Record<string, unknown>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Redact originating handler, adapter, completion and caught execution error text.
|
|
1161
|
+
* Host-authored fixed text bypasses this hook; circuit and consistency errors use adapter context.
|
|
1162
|
+
* Empty originating text bypasses the hook unchanged. For non-empty input, throwing or returning
|
|
1163
|
+
* a non-string or empty string uses a placeholder on execution paths, but refuses a completion
|
|
1164
|
+
* as redaction_failed before writes. State-machine `transition.error` text uses `source: "handler"`.
|
|
1165
|
+
* Keep redactors deterministic and stable across deploys: changed output can make a repeat
|
|
1166
|
+
* completion look like different evidence.
|
|
1167
|
+
*/
|
|
1168
|
+
redactErrorText?: (context: ErrorTextRedactionContext, message: string) => string;
|
|
1169
|
+
/**
|
|
1170
|
+
* Redact completion results before merging, schema validation, persistence and digesting.
|
|
1171
|
+
* Contradiction detection compares retained values; legacy raw digests also match repeats.
|
|
1172
|
+
* A throwing hook or a null, array or non-object return refuses as redaction_failed before writes.
|
|
1173
|
+
* Class instances and Dates are accepted by the same record predicate as adapter output.
|
|
1174
|
+
* Keep redactors deterministic and stable across deploys: changes can make a repeat look like
|
|
1175
|
+
* different evidence. A matching legacy raw digest is acknowledged before invoking hooks.
|
|
1176
|
+
*/
|
|
1177
|
+
redactExternalCompletionResult?: (actionId: ActionId, provider: string, result: Record<string, unknown>) => Record<string, unknown>;
|
|
1079
1178
|
adapterEventSubject?: (actionId: ActionId, parameters: unknown, handlerResult: Record<string, unknown>) => {
|
|
1080
1179
|
subjectType: string;
|
|
1081
1180
|
subjectId: string;
|
|
@@ -1173,8 +1272,8 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1173
1272
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1174
1273
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1175
1274
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1176
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1177
|
-
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt"
|
|
1275
|
+
getAdapterInvocation(id: string, scope?: AdapterInvocationScope): Promise<AdapterInvocationRecord | undefined>;
|
|
1276
|
+
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>, scope?: AdapterInvocationScope): Promise<void>;
|
|
1178
1277
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1179
1278
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1180
1279
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1208,6 +1307,10 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1208
1307
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1209
1308
|
private requireLeasedOutbox;
|
|
1210
1309
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
1310
|
+
getEntityStateSource(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
1311
|
+
state: string;
|
|
1312
|
+
actionInvocationId: string;
|
|
1313
|
+
} | undefined>;
|
|
1211
1314
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1212
1315
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1213
1316
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1304,8 +1407,8 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1304
1407
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1305
1408
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1306
1409
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1307
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1308
|
-
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt"
|
|
1410
|
+
getAdapterInvocation(id: string, scope?: AdapterInvocationScope): Promise<AdapterInvocationRecord | undefined>;
|
|
1411
|
+
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>, scope?: AdapterInvocationScope): Promise<void>;
|
|
1309
1412
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1310
1413
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1311
1414
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1338,6 +1441,10 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1338
1441
|
outboxId?: string;
|
|
1339
1442
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1340
1443
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
1444
|
+
getEntityStateSource(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
1445
|
+
state: string;
|
|
1446
|
+
actionInvocationId: string;
|
|
1447
|
+
} | undefined>;
|
|
1341
1448
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1342
1449
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1343
1450
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1493,13 +1600,13 @@ interface TenantIsolationSubject<TDb = unknown> {
|
|
|
1493
1600
|
}>;
|
|
1494
1601
|
/**
|
|
1495
1602
|
* Optional: put the host and store back to a known state before a check.
|
|
1496
|
-
* The checks tolerate accumulated state, and each
|
|
1603
|
+
* The checks tolerate accumulated state, and each retires any row it
|
|
1497
1604
|
* creates directly, so this exists for subjects whose store is shared.
|
|
1498
1605
|
*/
|
|
1499
1606
|
reset?(): Promise<void> | void;
|
|
1500
1607
|
}
|
|
1501
1608
|
interface TenantIsolationCheck {
|
|
1502
|
-
id: "fabric.tenancy.invocation-scoped-read.v1" | "fabric.tenancy.idempotency-key-scoped.v1" | "fabric.tenancy.events-scoped.v1" | "fabric.tenancy.worker-claim-scoped.v1" | "fabric.tenancy.completion-scoped.v1" | "fabric.tenancy.projection-scoped.v1";
|
|
1609
|
+
id: "fabric.tenancy.invocation-scoped-read.v1" | "fabric.tenancy.idempotency-key-scoped.v1" | "fabric.tenancy.events-scoped.v1" | "fabric.tenancy.worker-claim-scoped.v1" | "fabric.tenancy.completion-scoped.v1" | "fabric.tenancy.projection-scoped.v1" | "fabric.tenancy.adapter-invocation-read-scoped.v1" | "fabric.tenancy.adapter-invocation-write-scoped.v1";
|
|
1503
1610
|
run(subject: TenantIsolationSubject): Promise<string[]>;
|
|
1504
1611
|
}
|
|
1505
1612
|
interface TenantIsolationResult {
|
|
@@ -1514,15 +1621,16 @@ interface TenantIsolationResult {
|
|
|
1514
1621
|
/**
|
|
1515
1622
|
* The suite any deployment of the host must pass before it claims isolation.
|
|
1516
1623
|
*
|
|
1517
|
-
*
|
|
1624
|
+
* Eight checks: an invocation cannot be read, executed, or completed under
|
|
1518
1625
|
* another tenant's scope; an idempotency key is a tenant's own, so the same
|
|
1519
1626
|
* key in two tenants is two invocations; a tenant's event stream carries no
|
|
1520
|
-
* other tenant's events; a worker scoped to one tenant
|
|
1521
|
-
* work;
|
|
1522
|
-
*
|
|
1627
|
+
* other tenant's events; a worker scoped to one tenant does not claim another's
|
|
1628
|
+
* work; an adapter checkpoint cannot be read or written under another tenant,
|
|
1629
|
+
* space, or owning invocation; and, when the subject lends a read, a viewer in
|
|
1630
|
+
* the other tenant sees nothing of ours.
|
|
1523
1631
|
*/
|
|
1524
1632
|
declare function tenantIsolationChecks(): readonly TenantIsolationCheck[];
|
|
1525
1633
|
/** Run every check, returning each result rather than throwing on the first. */
|
|
1526
1634
|
declare function runTenantIsolationChecks(subject: TenantIsolationSubject): Promise<TenantIsolationResult>;
|
|
1527
1635
|
|
|
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 };
|
|
1636
|
+
export { ActionAdmissionError, type ActionAdmissionRefusal, type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationPatch, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationScope, 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 ErrorTextRedactionContext, 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -217,13 +217,15 @@ declare class ActionAdmissionError extends Error {
|
|
|
217
217
|
/** The check's own code, present only for `refused`. */
|
|
218
218
|
refusalCode?: string | undefined);
|
|
219
219
|
}
|
|
220
|
-
type ExternalCompletionRefusal = "still_executing" | "not_found" | "not_awaiting" | "immediate_contract" | "reference_mismatch" | "provider_mismatch" | "invalid_completion" | "result_invalid";
|
|
220
|
+
type ExternalCompletionRefusal = "still_executing" | "not_found" | "not_awaiting" | "immediate_contract" | "reference_mismatch" | "provider_mismatch" | "invalid_completion" | "result_invalid" | "redaction_failed";
|
|
221
221
|
/**
|
|
222
222
|
* Why a completion was not applied, typed so a webhook handler can answer
|
|
223
223
|
* the external system correctly: `retryable` means the invocation is still
|
|
224
224
|
* being finalized and the same callback will be accepted once it parks, so
|
|
225
225
|
* answer with something the sender retries; anything else is permanent and
|
|
226
|
-
* a retry will get the same refusal.
|
|
226
|
+
* a retry will get the same refusal without a configuration/input change.
|
|
227
|
+
* `redaction_failed` means completion result or error-text redaction failed before writes;
|
|
228
|
+
* it is not retryable.
|
|
227
229
|
*/
|
|
228
230
|
declare class ExternalCompletionError extends Error {
|
|
229
231
|
readonly refusal: ExternalCompletionRefusal;
|
|
@@ -432,6 +434,12 @@ interface AdapterInvocationRecord {
|
|
|
432
434
|
}
|
|
433
435
|
interface CreateActionInvocationInput extends Omit<ActionInvocationRecord, "createdAt" | "updatedAt" | "attemptCount" | "leaseOwner" | "leaseExpiresAt" | "leaseToken"> {
|
|
434
436
|
}
|
|
437
|
+
/** Scope of an adapter checkpoint within its owning action invocation. */
|
|
438
|
+
interface AdapterInvocationScope {
|
|
439
|
+
tenantId: string;
|
|
440
|
+
spaceId: string;
|
|
441
|
+
actionInvocationId: string;
|
|
442
|
+
}
|
|
435
443
|
interface PlatformHostStore<TDb> {
|
|
436
444
|
readonly db: TDb;
|
|
437
445
|
/**
|
|
@@ -445,10 +453,32 @@ interface PlatformHostStore<TDb> {
|
|
|
445
453
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
446
454
|
appendPolicyEvaluation(record: PolicyEvaluationRecord): Promise<void>;
|
|
447
455
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
448
|
-
|
|
449
|
-
|
|
456
|
+
/**
|
|
457
|
+
* Host supplies scope from its store-loaded invocation at adapter call sites.
|
|
458
|
+
* When supplied, stores must match tenant, space, and action invocation:
|
|
459
|
+
* an out-of-scope record returns undefined. Optional for compatibility with
|
|
460
|
+
* existing custom stores and direct callers; tenantIsolationChecks tests
|
|
461
|
+
* scoped read and write conformance.
|
|
462
|
+
*/
|
|
463
|
+
getAdapterInvocation(id: string, scope?: AdapterInvocationScope): Promise<AdapterInvocationRecord | undefined>;
|
|
464
|
+
/**
|
|
465
|
+
* Match all three scope fields when supplied, changing nothing outside it
|
|
466
|
+
* (a not-found error is permitted). Host supplies scope as described above;
|
|
467
|
+
* optional only for compatibility with existing stores and direct callers.
|
|
468
|
+
*/
|
|
469
|
+
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>, scope?: AdapterInvocationScope): Promise<void>;
|
|
450
470
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
451
471
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
472
|
+
/**
|
|
473
|
+
* Return the state and invocation writer of the same event selected by
|
|
474
|
+
* getEntityState, scoped to this subject and tenant/space. Return undefined
|
|
475
|
+
* when that event or its invocation provenance is unavailable. Transaction
|
|
476
|
+
* implementations include pending events visible to getEntityState.
|
|
477
|
+
*/
|
|
478
|
+
getEntityStateSource?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
479
|
+
state: string;
|
|
480
|
+
actionInvocationId: string;
|
|
481
|
+
} | undefined>;
|
|
452
482
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
453
483
|
}
|
|
454
484
|
/**
|
|
@@ -475,6 +505,16 @@ interface PlatformHostMutationTransaction<TDb> {
|
|
|
475
505
|
appendEventWithOutbox?(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
476
506
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
477
507
|
listEvents(tenantId: string, spaceId: string): Promise<AssetEventEnvelope[]>;
|
|
508
|
+
/**
|
|
509
|
+
* Return the state and invocation writer of the same event selected by
|
|
510
|
+
* getEntityState, scoped to this subject and tenant/space. Return undefined
|
|
511
|
+
* when that event or its invocation provenance is unavailable. Transaction
|
|
512
|
+
* implementations include pending events visible to getEntityState.
|
|
513
|
+
*/
|
|
514
|
+
getEntityStateSource?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
515
|
+
state: string;
|
|
516
|
+
actionInvocationId: string;
|
|
517
|
+
} | undefined>;
|
|
478
518
|
getEntityState?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
479
519
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
480
520
|
updateLeasedActionInvocation?(input: UpdateLeasedActionInvocationInput): Promise<boolean>;
|
|
@@ -963,6 +1003,21 @@ interface PlatformActionWorkerCycleResult {
|
|
|
963
1003
|
failed: number;
|
|
964
1004
|
/** Present when claimed agent work was durably parked instead of failing. */
|
|
965
1005
|
waitingForApproval?: number;
|
|
1006
|
+
/**
|
|
1007
|
+
* Present only when > 0: claimed invocations whose execution threw a
|
|
1008
|
+
* RetryableExecutionError (counted by error type, not by where it was thrown).
|
|
1009
|
+
* The row stays leased and a later claim retries it; excluded from failed.
|
|
1010
|
+
*/
|
|
1011
|
+
deferred?: number;
|
|
1012
|
+
}
|
|
1013
|
+
/** Origin of error text redacted before Host records or returns it. */
|
|
1014
|
+
interface ErrorTextRedactionContext {
|
|
1015
|
+
actionId: ActionId;
|
|
1016
|
+
source: "handler" | "adapter" | "external_completion" | "execution";
|
|
1017
|
+
adapterType?: string;
|
|
1018
|
+
operation?: string;
|
|
1019
|
+
/** Adapter vendor or external completion provider. */
|
|
1020
|
+
provider?: string;
|
|
966
1021
|
}
|
|
967
1022
|
interface PlatformHostOptions<TDb> {
|
|
968
1023
|
store: PlatformHostStore<TDb>;
|
|
@@ -979,8 +1034,24 @@ interface PlatformHostOptions<TDb> {
|
|
|
979
1034
|
* `circuitBreaker` config, on first use, and none for adapters without one.
|
|
980
1035
|
* Pass a shared registry or a custom provider to share breakers between
|
|
981
1036
|
* Host instances, receive breaker telemetry, or set manual overrides.
|
|
1037
|
+
* The default key shares failures across tenants and vendors in a registry.
|
|
1038
|
+
* Use `new AdapterCircuitBreakerRegistry({ key: scopedAdapterCircuitBreakerKey })`
|
|
1039
|
+
* for tenant/space/vendor isolation. Host passes trusted tenant/space scope
|
|
1040
|
+
* to the provider. The registry keeps the first config seen for a key;
|
|
1041
|
+
* later conflicting configs reuse that breaker without throwing. Breakers
|
|
1042
|
+
* are never evicted, so scoped keys keep one breaker per scope seen.
|
|
982
1043
|
*/
|
|
983
1044
|
adapterCircuitBreakers?: AdapterCircuitBreakerProvider;
|
|
1045
|
+
/**
|
|
1046
|
+
* Positive integer attempt cap for RetryableExecutionError during governance,
|
|
1047
|
+
* before policy-evaluation persistence (default 5). A leased, idempotent action
|
|
1048
|
+
* below the cap is left running for worker reclaim after lease expiry.
|
|
1049
|
+
* Inline execution, approval resume, exhausted attempts, and non-idempotent
|
|
1050
|
+
* actions fail. Policy persistence, obligation listing/resolution/persistence, state-machine checks,
|
|
1051
|
+
* the handler transaction, handlers, adapters, and finalization are excluded;
|
|
1052
|
+
* their existing failure/reconciliation/recovery semantics apply.
|
|
1053
|
+
*/
|
|
1054
|
+
retryableExecutionMaxAttempts?: number;
|
|
984
1055
|
dispatcher?: PlatformActionDispatcher;
|
|
985
1056
|
services?: FabricRuntimeServices;
|
|
986
1057
|
idempotency?: {
|
|
@@ -1029,6 +1100,7 @@ interface PlatformHostOptions<TDb> {
|
|
|
1029
1100
|
input: Record<string, unknown>;
|
|
1030
1101
|
startedAt: Date;
|
|
1031
1102
|
completedAt: Date;
|
|
1103
|
+
/** Adapter output after redactAdapterOutput, when configured. */
|
|
1032
1104
|
output: Record<string, unknown>;
|
|
1033
1105
|
}) => Promise<ExecutionAttestation | undefined> | ExecutionAttestation | undefined;
|
|
1034
1106
|
/** Package/provider/ruleset generations persisted with every newly created invocation. */
|
|
@@ -1076,6 +1148,33 @@ interface PlatformHostOptions<TDb> {
|
|
|
1076
1148
|
/** Handler-result fields consumed by extractEvents and omitted from the durable result. */
|
|
1077
1149
|
eventResultFields?: readonly string[];
|
|
1078
1150
|
redactAdapterInput?: (actionId: ActionId, adapterType: string, operation: string, input: Record<string, unknown>) => Record<string, unknown>;
|
|
1151
|
+
/**
|
|
1152
|
+
* Redact successful adapter output before row/event persistence and attestation extraction.
|
|
1153
|
+
* A throwing hook or a null, array or non-object return withholds output and requires reconciliation.
|
|
1154
|
+
* Class instances and Dates are accepted, matching the adapter output record contract.
|
|
1155
|
+
* Keep redactors deterministic and stable across deploys.
|
|
1156
|
+
* Accepted-operation references are read from the original adapter result.
|
|
1157
|
+
*/
|
|
1158
|
+
redactAdapterOutput?: (actionId: ActionId, adapterType: string, operation: string, output: Record<string, unknown>) => Record<string, unknown>;
|
|
1159
|
+
/**
|
|
1160
|
+
* Redact originating handler, adapter, completion and caught execution error text.
|
|
1161
|
+
* Host-authored fixed text bypasses this hook; circuit and consistency errors use adapter context.
|
|
1162
|
+
* Empty originating text bypasses the hook unchanged. For non-empty input, throwing or returning
|
|
1163
|
+
* a non-string or empty string uses a placeholder on execution paths, but refuses a completion
|
|
1164
|
+
* as redaction_failed before writes. State-machine `transition.error` text uses `source: "handler"`.
|
|
1165
|
+
* Keep redactors deterministic and stable across deploys: changed output can make a repeat
|
|
1166
|
+
* completion look like different evidence.
|
|
1167
|
+
*/
|
|
1168
|
+
redactErrorText?: (context: ErrorTextRedactionContext, message: string) => string;
|
|
1169
|
+
/**
|
|
1170
|
+
* Redact completion results before merging, schema validation, persistence and digesting.
|
|
1171
|
+
* Contradiction detection compares retained values; legacy raw digests also match repeats.
|
|
1172
|
+
* A throwing hook or a null, array or non-object return refuses as redaction_failed before writes.
|
|
1173
|
+
* Class instances and Dates are accepted by the same record predicate as adapter output.
|
|
1174
|
+
* Keep redactors deterministic and stable across deploys: changes can make a repeat look like
|
|
1175
|
+
* different evidence. A matching legacy raw digest is acknowledged before invoking hooks.
|
|
1176
|
+
*/
|
|
1177
|
+
redactExternalCompletionResult?: (actionId: ActionId, provider: string, result: Record<string, unknown>) => Record<string, unknown>;
|
|
1079
1178
|
adapterEventSubject?: (actionId: ActionId, parameters: unknown, handlerResult: Record<string, unknown>) => {
|
|
1080
1179
|
subjectType: string;
|
|
1081
1180
|
subjectId: string;
|
|
@@ -1173,8 +1272,8 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1173
1272
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1174
1273
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1175
1274
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1176
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1177
|
-
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt"
|
|
1275
|
+
getAdapterInvocation(id: string, scope?: AdapterInvocationScope): Promise<AdapterInvocationRecord | undefined>;
|
|
1276
|
+
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>, scope?: AdapterInvocationScope): Promise<void>;
|
|
1178
1277
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1179
1278
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1180
1279
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1208,6 +1307,10 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1208
1307
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1209
1308
|
private requireLeasedOutbox;
|
|
1210
1309
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
1310
|
+
getEntityStateSource(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
1311
|
+
state: string;
|
|
1312
|
+
actionInvocationId: string;
|
|
1313
|
+
} | undefined>;
|
|
1211
1314
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1212
1315
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1213
1316
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1304,8 +1407,8 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1304
1407
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1305
1408
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1306
1409
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1307
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1308
|
-
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt"
|
|
1410
|
+
getAdapterInvocation(id: string, scope?: AdapterInvocationScope): Promise<AdapterInvocationRecord | undefined>;
|
|
1411
|
+
updateAdapterInvocation(id: string, patch: Partial<Pick<AdapterInvocationRecord, "status" | "output" | "error" | "attempt" | "updatedAt">>, scope?: AdapterInvocationScope): Promise<void>;
|
|
1309
1412
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1310
1413
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1311
1414
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1338,6 +1441,10 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1338
1441
|
outboxId?: string;
|
|
1339
1442
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1340
1443
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
1444
|
+
getEntityStateSource(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<{
|
|
1445
|
+
state: string;
|
|
1446
|
+
actionInvocationId: string;
|
|
1447
|
+
} | undefined>;
|
|
1341
1448
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1342
1449
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1343
1450
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1493,13 +1600,13 @@ interface TenantIsolationSubject<TDb = unknown> {
|
|
|
1493
1600
|
}>;
|
|
1494
1601
|
/**
|
|
1495
1602
|
* Optional: put the host and store back to a known state before a check.
|
|
1496
|
-
* The checks tolerate accumulated state, and each
|
|
1603
|
+
* The checks tolerate accumulated state, and each retires any row it
|
|
1497
1604
|
* creates directly, so this exists for subjects whose store is shared.
|
|
1498
1605
|
*/
|
|
1499
1606
|
reset?(): Promise<void> | void;
|
|
1500
1607
|
}
|
|
1501
1608
|
interface TenantIsolationCheck {
|
|
1502
|
-
id: "fabric.tenancy.invocation-scoped-read.v1" | "fabric.tenancy.idempotency-key-scoped.v1" | "fabric.tenancy.events-scoped.v1" | "fabric.tenancy.worker-claim-scoped.v1" | "fabric.tenancy.completion-scoped.v1" | "fabric.tenancy.projection-scoped.v1";
|
|
1609
|
+
id: "fabric.tenancy.invocation-scoped-read.v1" | "fabric.tenancy.idempotency-key-scoped.v1" | "fabric.tenancy.events-scoped.v1" | "fabric.tenancy.worker-claim-scoped.v1" | "fabric.tenancy.completion-scoped.v1" | "fabric.tenancy.projection-scoped.v1" | "fabric.tenancy.adapter-invocation-read-scoped.v1" | "fabric.tenancy.adapter-invocation-write-scoped.v1";
|
|
1503
1610
|
run(subject: TenantIsolationSubject): Promise<string[]>;
|
|
1504
1611
|
}
|
|
1505
1612
|
interface TenantIsolationResult {
|
|
@@ -1514,15 +1621,16 @@ interface TenantIsolationResult {
|
|
|
1514
1621
|
/**
|
|
1515
1622
|
* The suite any deployment of the host must pass before it claims isolation.
|
|
1516
1623
|
*
|
|
1517
|
-
*
|
|
1624
|
+
* Eight checks: an invocation cannot be read, executed, or completed under
|
|
1518
1625
|
* another tenant's scope; an idempotency key is a tenant's own, so the same
|
|
1519
1626
|
* key in two tenants is two invocations; a tenant's event stream carries no
|
|
1520
|
-
* other tenant's events; a worker scoped to one tenant
|
|
1521
|
-
* work;
|
|
1522
|
-
*
|
|
1627
|
+
* other tenant's events; a worker scoped to one tenant does not claim another's
|
|
1628
|
+
* work; an adapter checkpoint cannot be read or written under another tenant,
|
|
1629
|
+
* space, or owning invocation; and, when the subject lends a read, a viewer in
|
|
1630
|
+
* the other tenant sees nothing of ours.
|
|
1523
1631
|
*/
|
|
1524
1632
|
declare function tenantIsolationChecks(): readonly TenantIsolationCheck[];
|
|
1525
1633
|
/** Run every check, returning each result rather than throwing on the first. */
|
|
1526
1634
|
declare function runTenantIsolationChecks(subject: TenantIsolationSubject): Promise<TenantIsolationResult>;
|
|
1527
1635
|
|
|
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 };
|
|
1636
|
+
export { ActionAdmissionError, type ActionAdmissionRefusal, type ActionApprovalDecision, type ActionAuthorizationInput, type ActionExecutionAuthorizationInput, type ActionExecutionReason, type ActionInvocationPatch, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationScope, 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 ErrorTextRedactionContext, 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 };
|