@fabricorg/platform-host 7.3.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 +80 -0
- package/README.md +236 -15
- package/dist/index.cjs +416 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +135 -17
- package/dist/index.d.ts +135 -17
- package/dist/index.js +413 -79
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
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. */
|
|
@@ -216,13 +217,15 @@ declare class ActionAdmissionError extends Error {
|
|
|
216
217
|
/** The check's own code, present only for `refused`. */
|
|
217
218
|
refusalCode?: string | undefined);
|
|
218
219
|
}
|
|
219
|
-
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";
|
|
220
221
|
/**
|
|
221
222
|
* Why a completion was not applied, typed so a webhook handler can answer
|
|
222
223
|
* the external system correctly: `retryable` means the invocation is still
|
|
223
224
|
* being finalized and the same callback will be accepted once it parks, so
|
|
224
225
|
* answer with something the sender retries; anything else is permanent and
|
|
225
|
-
* 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.
|
|
226
229
|
*/
|
|
227
230
|
declare class ExternalCompletionError extends Error {
|
|
228
231
|
readonly refusal: ExternalCompletionRefusal;
|
|
@@ -431,6 +434,12 @@ interface AdapterInvocationRecord {
|
|
|
431
434
|
}
|
|
432
435
|
interface CreateActionInvocationInput extends Omit<ActionInvocationRecord, "createdAt" | "updatedAt" | "attemptCount" | "leaseOwner" | "leaseExpiresAt" | "leaseToken"> {
|
|
433
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
|
+
}
|
|
434
443
|
interface PlatformHostStore<TDb> {
|
|
435
444
|
readonly db: TDb;
|
|
436
445
|
/**
|
|
@@ -444,10 +453,32 @@ interface PlatformHostStore<TDb> {
|
|
|
444
453
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
445
454
|
appendPolicyEvaluation(record: PolicyEvaluationRecord): Promise<void>;
|
|
446
455
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
447
|
-
|
|
448
|
-
|
|
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>;
|
|
449
470
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
450
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>;
|
|
451
482
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
452
483
|
}
|
|
453
484
|
/**
|
|
@@ -474,6 +505,16 @@ interface PlatformHostMutationTransaction<TDb> {
|
|
|
474
505
|
appendEventWithOutbox?(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
475
506
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
476
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>;
|
|
477
518
|
getEntityState?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
478
519
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
479
520
|
updateLeasedActionInvocation?(input: UpdateLeasedActionInvocationInput): Promise<boolean>;
|
|
@@ -962,6 +1003,21 @@ interface PlatformActionWorkerCycleResult {
|
|
|
962
1003
|
failed: number;
|
|
963
1004
|
/** Present when claimed agent work was durably parked instead of failing. */
|
|
964
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;
|
|
965
1021
|
}
|
|
966
1022
|
interface PlatformHostOptions<TDb> {
|
|
967
1023
|
store: PlatformHostStore<TDb>;
|
|
@@ -971,6 +1027,31 @@ interface PlatformHostOptions<TDb> {
|
|
|
971
1027
|
/** Resolve vertical- or runtime-local actions without mutating the process-wide registry. */
|
|
972
1028
|
resolveAction?: (actionId: ActionId) => ActionDefinition<TDb> | undefined;
|
|
973
1029
|
adapters?: readonly AdapterImplementation[];
|
|
1030
|
+
/**
|
|
1031
|
+
* Supplies the circuit breaker for each adapter call. Defaults to a new
|
|
1032
|
+
* `AdapterCircuitBreakerRegistry` per Host instance, which creates one
|
|
1033
|
+
* in-process breaker per `adapterType:operation` from that adapter's own
|
|
1034
|
+
* `circuitBreaker` config, on first use, and none for adapters without one.
|
|
1035
|
+
* Pass a shared registry or a custom provider to share breakers between
|
|
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.
|
|
1043
|
+
*/
|
|
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;
|
|
974
1055
|
dispatcher?: PlatformActionDispatcher;
|
|
975
1056
|
services?: FabricRuntimeServices;
|
|
976
1057
|
idempotency?: {
|
|
@@ -1019,6 +1100,7 @@ interface PlatformHostOptions<TDb> {
|
|
|
1019
1100
|
input: Record<string, unknown>;
|
|
1020
1101
|
startedAt: Date;
|
|
1021
1102
|
completedAt: Date;
|
|
1103
|
+
/** Adapter output after redactAdapterOutput, when configured. */
|
|
1022
1104
|
output: Record<string, unknown>;
|
|
1023
1105
|
}) => Promise<ExecutionAttestation | undefined> | ExecutionAttestation | undefined;
|
|
1024
1106
|
/** Package/provider/ruleset generations persisted with every newly created invocation. */
|
|
@@ -1066,6 +1148,33 @@ interface PlatformHostOptions<TDb> {
|
|
|
1066
1148
|
/** Handler-result fields consumed by extractEvents and omitted from the durable result. */
|
|
1067
1149
|
eventResultFields?: readonly string[];
|
|
1068
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>;
|
|
1069
1178
|
adapterEventSubject?: (actionId: ActionId, parameters: unknown, handlerResult: Record<string, unknown>) => {
|
|
1070
1179
|
subjectType: string;
|
|
1071
1180
|
subjectId: string;
|
|
@@ -1163,8 +1272,8 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1163
1272
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1164
1273
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1165
1274
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1166
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1167
|
-
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>;
|
|
1168
1277
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1169
1278
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1170
1279
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1198,6 +1307,10 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1198
1307
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1199
1308
|
private requireLeasedOutbox;
|
|
1200
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>;
|
|
1201
1314
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1202
1315
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1203
1316
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1294,8 +1407,8 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1294
1407
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1295
1408
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1296
1409
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1297
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1298
|
-
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>;
|
|
1299
1412
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1300
1413
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1301
1414
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1328,6 +1441,10 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1328
1441
|
outboxId?: string;
|
|
1329
1442
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1330
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>;
|
|
1331
1448
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1332
1449
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1333
1450
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1352,7 +1469,7 @@ interface PostgresMigration {
|
|
|
1352
1469
|
declare function applyPostgresMigrations(client: PlatformHostSqlClient, migrations: readonly PostgresMigration[]): Promise<void>;
|
|
1353
1470
|
|
|
1354
1471
|
declare const PARAMETER_DIGEST_ALGORITHM: "fabric-canonical-json-sha256-v1";
|
|
1355
|
-
|
|
1472
|
+
|
|
1356
1473
|
declare function digestParameters(parameters: unknown): string;
|
|
1357
1474
|
|
|
1358
1475
|
/**
|
|
@@ -1483,13 +1600,13 @@ interface TenantIsolationSubject<TDb = unknown> {
|
|
|
1483
1600
|
}>;
|
|
1484
1601
|
/**
|
|
1485
1602
|
* Optional: put the host and store back to a known state before a check.
|
|
1486
|
-
* The checks tolerate accumulated state, and each
|
|
1603
|
+
* The checks tolerate accumulated state, and each retires any row it
|
|
1487
1604
|
* creates directly, so this exists for subjects whose store is shared.
|
|
1488
1605
|
*/
|
|
1489
1606
|
reset?(): Promise<void> | void;
|
|
1490
1607
|
}
|
|
1491
1608
|
interface TenantIsolationCheck {
|
|
1492
|
-
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";
|
|
1493
1610
|
run(subject: TenantIsolationSubject): Promise<string[]>;
|
|
1494
1611
|
}
|
|
1495
1612
|
interface TenantIsolationResult {
|
|
@@ -1504,15 +1621,16 @@ interface TenantIsolationResult {
|
|
|
1504
1621
|
/**
|
|
1505
1622
|
* The suite any deployment of the host must pass before it claims isolation.
|
|
1506
1623
|
*
|
|
1507
|
-
*
|
|
1624
|
+
* Eight checks: an invocation cannot be read, executed, or completed under
|
|
1508
1625
|
* another tenant's scope; an idempotency key is a tenant's own, so the same
|
|
1509
1626
|
* key in two tenants is two invocations; a tenant's event stream carries no
|
|
1510
|
-
* other tenant's events; a worker scoped to one tenant
|
|
1511
|
-
* work;
|
|
1512
|
-
*
|
|
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.
|
|
1513
1631
|
*/
|
|
1514
1632
|
declare function tenantIsolationChecks(): readonly TenantIsolationCheck[];
|
|
1515
1633
|
/** Run every check, returning each result rather than throwing on the first. */
|
|
1516
1634
|
declare function runTenantIsolationChecks(subject: TenantIsolationSubject): Promise<TenantIsolationResult>;
|
|
1517
1635
|
|
|
1518
|
-
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,
|
|
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
|
@@ -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. */
|
|
@@ -216,13 +217,15 @@ declare class ActionAdmissionError extends Error {
|
|
|
216
217
|
/** The check's own code, present only for `refused`. */
|
|
217
218
|
refusalCode?: string | undefined);
|
|
218
219
|
}
|
|
219
|
-
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";
|
|
220
221
|
/**
|
|
221
222
|
* Why a completion was not applied, typed so a webhook handler can answer
|
|
222
223
|
* the external system correctly: `retryable` means the invocation is still
|
|
223
224
|
* being finalized and the same callback will be accepted once it parks, so
|
|
224
225
|
* answer with something the sender retries; anything else is permanent and
|
|
225
|
-
* 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.
|
|
226
229
|
*/
|
|
227
230
|
declare class ExternalCompletionError extends Error {
|
|
228
231
|
readonly refusal: ExternalCompletionRefusal;
|
|
@@ -431,6 +434,12 @@ interface AdapterInvocationRecord {
|
|
|
431
434
|
}
|
|
432
435
|
interface CreateActionInvocationInput extends Omit<ActionInvocationRecord, "createdAt" | "updatedAt" | "attemptCount" | "leaseOwner" | "leaseExpiresAt" | "leaseToken"> {
|
|
433
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
|
+
}
|
|
434
443
|
interface PlatformHostStore<TDb> {
|
|
435
444
|
readonly db: TDb;
|
|
436
445
|
/**
|
|
@@ -444,10 +453,32 @@ interface PlatformHostStore<TDb> {
|
|
|
444
453
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
445
454
|
appendPolicyEvaluation(record: PolicyEvaluationRecord): Promise<void>;
|
|
446
455
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
447
|
-
|
|
448
|
-
|
|
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>;
|
|
449
470
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
450
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>;
|
|
451
482
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
452
483
|
}
|
|
453
484
|
/**
|
|
@@ -474,6 +505,16 @@ interface PlatformHostMutationTransaction<TDb> {
|
|
|
474
505
|
appendEventWithOutbox?(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
475
506
|
nextEventSequence(tenantId: string, spaceId: string): Promise<number>;
|
|
476
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>;
|
|
477
518
|
getEntityState?(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
478
519
|
updateActionInvocation(id: string, tenantId: string, spaceId: string, patch: ActionInvocationPatch): Promise<void>;
|
|
479
520
|
updateLeasedActionInvocation?(input: UpdateLeasedActionInvocationInput): Promise<boolean>;
|
|
@@ -962,6 +1003,21 @@ interface PlatformActionWorkerCycleResult {
|
|
|
962
1003
|
failed: number;
|
|
963
1004
|
/** Present when claimed agent work was durably parked instead of failing. */
|
|
964
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;
|
|
965
1021
|
}
|
|
966
1022
|
interface PlatformHostOptions<TDb> {
|
|
967
1023
|
store: PlatformHostStore<TDb>;
|
|
@@ -971,6 +1027,31 @@ interface PlatformHostOptions<TDb> {
|
|
|
971
1027
|
/** Resolve vertical- or runtime-local actions without mutating the process-wide registry. */
|
|
972
1028
|
resolveAction?: (actionId: ActionId) => ActionDefinition<TDb> | undefined;
|
|
973
1029
|
adapters?: readonly AdapterImplementation[];
|
|
1030
|
+
/**
|
|
1031
|
+
* Supplies the circuit breaker for each adapter call. Defaults to a new
|
|
1032
|
+
* `AdapterCircuitBreakerRegistry` per Host instance, which creates one
|
|
1033
|
+
* in-process breaker per `adapterType:operation` from that adapter's own
|
|
1034
|
+
* `circuitBreaker` config, on first use, and none for adapters without one.
|
|
1035
|
+
* Pass a shared registry or a custom provider to share breakers between
|
|
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.
|
|
1043
|
+
*/
|
|
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;
|
|
974
1055
|
dispatcher?: PlatformActionDispatcher;
|
|
975
1056
|
services?: FabricRuntimeServices;
|
|
976
1057
|
idempotency?: {
|
|
@@ -1019,6 +1100,7 @@ interface PlatformHostOptions<TDb> {
|
|
|
1019
1100
|
input: Record<string, unknown>;
|
|
1020
1101
|
startedAt: Date;
|
|
1021
1102
|
completedAt: Date;
|
|
1103
|
+
/** Adapter output after redactAdapterOutput, when configured. */
|
|
1022
1104
|
output: Record<string, unknown>;
|
|
1023
1105
|
}) => Promise<ExecutionAttestation | undefined> | ExecutionAttestation | undefined;
|
|
1024
1106
|
/** Package/provider/ruleset generations persisted with every newly created invocation. */
|
|
@@ -1066,6 +1148,33 @@ interface PlatformHostOptions<TDb> {
|
|
|
1066
1148
|
/** Handler-result fields consumed by extractEvents and omitted from the durable result. */
|
|
1067
1149
|
eventResultFields?: readonly string[];
|
|
1068
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>;
|
|
1069
1178
|
adapterEventSubject?: (actionId: ActionId, parameters: unknown, handlerResult: Record<string, unknown>) => {
|
|
1070
1179
|
subjectType: string;
|
|
1071
1180
|
subjectId: string;
|
|
@@ -1163,8 +1272,8 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1163
1272
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1164
1273
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1165
1274
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1166
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1167
|
-
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>;
|
|
1168
1277
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1169
1278
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1170
1279
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1198,6 +1307,10 @@ declare class MemoryPlatformHostStore<TDb> implements RecoverablePlatformHostSto
|
|
|
1198
1307
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1199
1308
|
private requireLeasedOutbox;
|
|
1200
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>;
|
|
1201
1314
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1202
1315
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1203
1316
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1294,8 +1407,8 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1294
1407
|
listExecutionAttestations(actionInvocationId: string, tenantId: string, spaceId: string): Promise<ExecutionAttestationRecord[]>;
|
|
1295
1408
|
appendExternalReconciliation(record: ExternalReconciliationRecord): Promise<void>;
|
|
1296
1409
|
createAdapterInvocation(record: AdapterInvocationRecord): Promise<void>;
|
|
1297
|
-
getAdapterInvocation(id: string): Promise<AdapterInvocationRecord | undefined>;
|
|
1298
|
-
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>;
|
|
1299
1412
|
appendEvent(event: AssetEventEnvelope): Promise<void>;
|
|
1300
1413
|
appendEventWithOutbox(event: AssetEventEnvelope, metadata: OutboxEventMetadata): Promise<void>;
|
|
1301
1414
|
claimOutbox(input: ClaimOutboxInput): Promise<OutboxRecord[]>;
|
|
@@ -1328,6 +1441,10 @@ declare class PostgresPlatformHostStore<TDb> implements RecoverablePlatformHostS
|
|
|
1328
1441
|
outboxId?: string;
|
|
1329
1442
|
}): Promise<OutboxRequeueRecord[]>;
|
|
1330
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>;
|
|
1331
1448
|
getEntityState(tenantId: string, spaceId: string, entityType: string, entityId: string): Promise<string | undefined>;
|
|
1332
1449
|
listActionInvocations(input?: ListActionInvocationsInput): Promise<ActionInvocationRecord[]>;
|
|
1333
1450
|
getHealthCounts(input: PlatformHostHealthQuery): Promise<PlatformHostHealthCounts>;
|
|
@@ -1352,7 +1469,7 @@ interface PostgresMigration {
|
|
|
1352
1469
|
declare function applyPostgresMigrations(client: PlatformHostSqlClient, migrations: readonly PostgresMigration[]): Promise<void>;
|
|
1353
1470
|
|
|
1354
1471
|
declare const PARAMETER_DIGEST_ALGORITHM: "fabric-canonical-json-sha256-v1";
|
|
1355
|
-
|
|
1472
|
+
|
|
1356
1473
|
declare function digestParameters(parameters: unknown): string;
|
|
1357
1474
|
|
|
1358
1475
|
/**
|
|
@@ -1483,13 +1600,13 @@ interface TenantIsolationSubject<TDb = unknown> {
|
|
|
1483
1600
|
}>;
|
|
1484
1601
|
/**
|
|
1485
1602
|
* Optional: put the host and store back to a known state before a check.
|
|
1486
|
-
* The checks tolerate accumulated state, and each
|
|
1603
|
+
* The checks tolerate accumulated state, and each retires any row it
|
|
1487
1604
|
* creates directly, so this exists for subjects whose store is shared.
|
|
1488
1605
|
*/
|
|
1489
1606
|
reset?(): Promise<void> | void;
|
|
1490
1607
|
}
|
|
1491
1608
|
interface TenantIsolationCheck {
|
|
1492
|
-
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";
|
|
1493
1610
|
run(subject: TenantIsolationSubject): Promise<string[]>;
|
|
1494
1611
|
}
|
|
1495
1612
|
interface TenantIsolationResult {
|
|
@@ -1504,15 +1621,16 @@ interface TenantIsolationResult {
|
|
|
1504
1621
|
/**
|
|
1505
1622
|
* The suite any deployment of the host must pass before it claims isolation.
|
|
1506
1623
|
*
|
|
1507
|
-
*
|
|
1624
|
+
* Eight checks: an invocation cannot be read, executed, or completed under
|
|
1508
1625
|
* another tenant's scope; an idempotency key is a tenant's own, so the same
|
|
1509
1626
|
* key in two tenants is two invocations; a tenant's event stream carries no
|
|
1510
|
-
* other tenant's events; a worker scoped to one tenant
|
|
1511
|
-
* work;
|
|
1512
|
-
*
|
|
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.
|
|
1513
1631
|
*/
|
|
1514
1632
|
declare function tenantIsolationChecks(): readonly TenantIsolationCheck[];
|
|
1515
1633
|
/** Run every check, returning each result rather than throwing on the first. */
|
|
1516
1634
|
declare function runTenantIsolationChecks(subject: TenantIsolationSubject): Promise<TenantIsolationResult>;
|
|
1517
1635
|
|
|
1518
|
-
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,
|
|
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 };
|