@fabricorg/platform-host 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
- import { ActorType, ActionId, ActionStatus, AgentActionRoute, AgentActionRiskTier, MutationFootprint, ExecutionPrincipal, PolicyOutcome, AssetEventEnvelope, ExecutionAttestation, ExternalReconciliation, PolicyObligation, PolicyObligationStatus, ActionDefinition, AdapterImplementation, FabricRuntimeServices, AgentActionPolicyEvaluator, MutationGovernanceResolver, RuntimePolicyDefinition } from '@fabricorg/platform';
1
+ import { ActorType, ActionId, ActionStatus, AgentActionRoute, AgentActionRiskTier, MutationFootprint, ExecutionPrincipal, GovernanceRuntimeEvidence, PolicyOutcome, AssetEventEnvelope, ExecutionAttestation, ExternalReconciliation, PolicyObligation, PolicyObligationStatus, ActionDefinition, AdapterImplementation, FabricRuntimeServices, AgentActionPolicyEvaluator, MutationGovernanceResolver, RuntimePolicyDefinition } from '@fabricorg/platform';
2
2
 
3
+ /** Durable Host lifecycle generation, independent from the npm package version. */
4
+ declare const PLATFORM_HOST_CONTRACT_VERSION: 1;
3
5
  interface PendingAssetEvent {
4
6
  eventType: string;
5
7
  subjectType: string;
@@ -31,6 +33,7 @@ interface ActionInvocationRecord {
31
33
  approvalDecision?: PersistedActionApprovalDecision;
32
34
  mutationFootprint?: MutationFootprint;
33
35
  executionPrincipal?: ExecutionPrincipal;
36
+ runtimeEvidence?: GovernanceRuntimeEvidence;
34
37
  error?: string;
35
38
  createdAt: Date;
36
39
  updatedAt: Date;
@@ -280,6 +283,8 @@ interface PlatformHostOptions<TDb> {
280
283
  completedAt: Date;
281
284
  output: Record<string, unknown>;
282
285
  }) => Promise<ExecutionAttestation | undefined> | ExecutionAttestation | undefined;
286
+ /** Package/provider/ruleset generations persisted with every newly created invocation. */
287
+ runtimeEvidence?: Partial<GovernanceRuntimeEvidence>;
283
288
  /** Lease held while an approved invocation resumes; defaults to five minutes. */
284
289
  approvalResumeLeaseDurationMs?: number;
285
290
  /** Remove forbidden/sensitive fields before durable invocation persistence. */
@@ -396,4 +401,4 @@ declare function runPlatformActionWorkerCycle<TDb>(options: PlatformActionWorker
396
401
  /** Poll until aborted. Each iteration is bounded and waits without busy-spinning. */
397
402
  declare function runPlatformActionWorker<TDb>(options: PlatformActionWorkerOptions<TDb>): Promise<void>;
398
403
 
399
- export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
404
+ export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, PLATFORM_HOST_CONTRACT_VERSION, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { ActorType, ActionId, ActionStatus, AgentActionRoute, AgentActionRiskTier, MutationFootprint, ExecutionPrincipal, PolicyOutcome, AssetEventEnvelope, ExecutionAttestation, ExternalReconciliation, PolicyObligation, PolicyObligationStatus, ActionDefinition, AdapterImplementation, FabricRuntimeServices, AgentActionPolicyEvaluator, MutationGovernanceResolver, RuntimePolicyDefinition } from '@fabricorg/platform';
1
+ import { ActorType, ActionId, ActionStatus, AgentActionRoute, AgentActionRiskTier, MutationFootprint, ExecutionPrincipal, GovernanceRuntimeEvidence, PolicyOutcome, AssetEventEnvelope, ExecutionAttestation, ExternalReconciliation, PolicyObligation, PolicyObligationStatus, ActionDefinition, AdapterImplementation, FabricRuntimeServices, AgentActionPolicyEvaluator, MutationGovernanceResolver, RuntimePolicyDefinition } from '@fabricorg/platform';
2
2
 
3
+ /** Durable Host lifecycle generation, independent from the npm package version. */
4
+ declare const PLATFORM_HOST_CONTRACT_VERSION: 1;
3
5
  interface PendingAssetEvent {
4
6
  eventType: string;
5
7
  subjectType: string;
@@ -31,6 +33,7 @@ interface ActionInvocationRecord {
31
33
  approvalDecision?: PersistedActionApprovalDecision;
32
34
  mutationFootprint?: MutationFootprint;
33
35
  executionPrincipal?: ExecutionPrincipal;
36
+ runtimeEvidence?: GovernanceRuntimeEvidence;
34
37
  error?: string;
35
38
  createdAt: Date;
36
39
  updatedAt: Date;
@@ -280,6 +283,8 @@ interface PlatformHostOptions<TDb> {
280
283
  completedAt: Date;
281
284
  output: Record<string, unknown>;
282
285
  }) => Promise<ExecutionAttestation | undefined> | ExecutionAttestation | undefined;
286
+ /** Package/provider/ruleset generations persisted with every newly created invocation. */
287
+ runtimeEvidence?: Partial<GovernanceRuntimeEvidence>;
283
288
  /** Lease held while an approved invocation resumes; defaults to five minutes. */
284
289
  approvalResumeLeaseDurationMs?: number;
285
290
  /** Remove forbidden/sensitive fields before durable invocation persistence. */
@@ -396,4 +401,4 @@ declare function runPlatformActionWorkerCycle<TDb>(options: PlatformActionWorker
396
401
  /** Poll until aborted. Each iteration is bounded and waits without busy-spinning. */
397
402
  declare function runPlatformActionWorker<TDb>(options: PlatformActionWorkerOptions<TDb>): Promise<void>;
398
403
 
399
- export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
404
+ export { type ActionApprovalDecision, type ActionAuthorizationInput, type ActionInvocationRecord, type AdapterInvocationRecord, type AdapterInvocationStatus, type ApprovalDecisionTransitionResult, type ApprovalPlatformHostStore, type BeginApprovalDecisionInput, type ClaimActionInvocationsInput, type CreateActionInvocationInput, type DispatchActionInput, type DispatchActionResult, type ExecuteActionResult, type ExecuteInvocationOptions, type ExecutionAttestationRecord, type ExternalReconciliationRecord, type GovernancePlatformHostStore, type GovernedActionHost, type HitlDecisionEvidence, type ListActionInvocationsInput, MemoryPlatformHostStore, PLATFORM_HOST_CONTRACT_VERSION, type PendingAssetEvent, type PersistedActionApprovalDecision, type PlatformActionDispatcher, type PlatformActionWorkerCycleResult, type PlatformActionWorkerOptions, type PlatformHostAuthorization, type PlatformHostOptions, type PlatformHostSqlClient, type PlatformHostSqlResult, type PlatformHostStore, type PolicyEvaluationRecord, type PolicyObligationRecord, PostgresPlatformHostStore, type RecoverablePlatformHostStore, type SubmitActionInput, type SubmitActionResult, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
package/dist/index.js CHANGED
@@ -1,4 +1,9 @@
1
- import { AdapterRegistry, resolveAction, createFabricId, assertMutationGovernanceContext, evaluatePolicyDefinitions, aggregatePolicyOutcomes, validateTransition, executeWithAdapterRetry, resolveStateMachine } from '@fabricorg/platform';
1
+ import { AdapterRegistry, resolveAction, createFabricId, assertGovernanceRuntimeEvidence, FABRIC_GOVERNANCE_CONTRACT_VERSION, assertMutationGovernanceContext, evaluatePolicyDefinitions, aggregatePolicyOutcomes, validateTransition, executeWithAdapterRetry, resolveStateMachine } from '@fabricorg/platform';
2
+
3
+ // src/host.ts
4
+
5
+ // src/types.ts
6
+ var PLATFORM_HOST_CONTRACT_VERSION = 1;
2
7
 
3
8
  // src/host.ts
4
9
  var DEFAULT_EXTRACT_EVENTS = (data) => {
@@ -25,6 +30,12 @@ function createGovernedActionHost(options) {
25
30
  const actionInvocationId = createFabricId("act");
26
31
  const correlationId = input.correlationId ?? createFabricId("corr");
27
32
  const durableParameters = options.redactActionParameters ? options.redactActionParameters(input.actionId, input.parameters) : input.parameters;
33
+ const runtimeEvidence = {
34
+ governanceContractVersion: FABRIC_GOVERNANCE_CONTRACT_VERSION,
35
+ hostContractVersion: PLATFORM_HOST_CONTRACT_VERSION,
36
+ ...options.runtimeEvidence
37
+ };
38
+ assertGovernanceRuntimeEvidence(runtimeEvidence);
28
39
  const durableInvocation = await options.store.createActionInvocation({
29
40
  id: actionInvocationId,
30
41
  tenantId: input.tenantId,
@@ -36,6 +47,7 @@ function createGovernedActionHost(options) {
36
47
  status: "pending",
37
48
  parameters: durableParameters,
38
49
  result: {},
50
+ runtimeEvidence,
39
51
  correlationId,
40
52
  ...input.causationId ? { causationId: input.causationId } : {},
41
53
  ...input.idempotencyKey ? { idempotencyKey: input.idempotencyKey } : {}
@@ -871,7 +883,7 @@ var PostgresPlatformHostStore = class {
871
883
  attempt_count integer NOT NULL DEFAULT 0, lease_owner text,
872
884
  lease_expires_at timestamptz, hitl_route text, hitl_risk_tier text,
873
885
  hitl_reason text, hitl_policy_version text, approval_decision jsonb,
874
- mutation_footprint jsonb, execution_principal jsonb,
886
+ mutation_footprint jsonb, execution_principal jsonb, runtime_evidence jsonb,
875
887
  created_at timestamptz NOT NULL, updated_at timestamptz NOT NULL
876
888
  );
877
889
  ALTER TABLE fabric_platform.action_invocations
@@ -885,7 +897,8 @@ var PostgresPlatformHostStore = class {
885
897
  ADD COLUMN IF NOT EXISTS hitl_policy_version text,
886
898
  ADD COLUMN IF NOT EXISTS approval_decision jsonb,
887
899
  ADD COLUMN IF NOT EXISTS mutation_footprint jsonb,
888
- ADD COLUMN IF NOT EXISTS execution_principal jsonb;
900
+ ADD COLUMN IF NOT EXISTS execution_principal jsonb,
901
+ ADD COLUMN IF NOT EXISTS runtime_evidence jsonb;
889
902
  CREATE UNIQUE INDEX IF NOT EXISTS action_invocations_idempotency_idx
890
903
  ON fabric_platform.action_invocations
891
904
  (tenant_id, space_id, action_id, idempotency_key)
@@ -949,8 +962,8 @@ var PostgresPlatformHostStore = class {
949
962
  const result = await this.sql.query(
950
963
  `INSERT INTO fabric_platform.action_invocations
951
964
  (id,tenant_id,space_id,action_id,action_version,actor_id,actor_type,status,
952
- parameters,result,correlation_id,causation_id,idempotency_key,error,created_at,updated_at)
953
- VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9::jsonb,$10::jsonb,$11,$12,$13,$14,$15,$15)
965
+ parameters,result,correlation_id,causation_id,idempotency_key,error,runtime_evidence,created_at,updated_at)
966
+ VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9::jsonb,$10::jsonb,$11,$12,$13,$14,$15::jsonb,$16,$16)
954
967
  ON CONFLICT (tenant_id,space_id,action_id,idempotency_key)
955
968
  WHERE idempotency_key IS NOT NULL DO UPDATE SET id=fabric_platform.action_invocations.id
956
969
  RETURNING *`,
@@ -969,6 +982,7 @@ var PostgresPlatformHostStore = class {
969
982
  input.causationId ?? null,
970
983
  input.idempotencyKey ?? null,
971
984
  input.error ?? null,
985
+ input.runtimeEvidence ? JSON.stringify(input.runtimeEvidence) : null,
972
986
  now
973
987
  ]
974
988
  );
@@ -1340,6 +1354,7 @@ function toActionRecord(row) {
1340
1354
  ...row.approval_decision ? { approvalDecision: toApprovalDecision(row.approval_decision) } : {},
1341
1355
  ...row.mutation_footprint ? { mutationFootprint: row.mutation_footprint } : {},
1342
1356
  ...row.execution_principal ? { executionPrincipal: row.execution_principal } : {},
1357
+ ...row.runtime_evidence ? { runtimeEvidence: row.runtime_evidence } : {},
1343
1358
  ...row.error ? { error: String(row.error) } : {},
1344
1359
  createdAt: new Date(row.created_at),
1345
1360
  updatedAt: new Date(row.updated_at)
@@ -1473,6 +1488,6 @@ async function abortableDelay(milliseconds, signal) {
1473
1488
  });
1474
1489
  }
1475
1490
 
1476
- export { MemoryPlatformHostStore, PostgresPlatformHostStore, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
1491
+ export { MemoryPlatformHostStore, PLATFORM_HOST_CONTRACT_VERSION, PostgresPlatformHostStore, createGovernedActionHost, createStoreBackedActionDispatcher, runPlatformActionWorker, runPlatformActionWorkerCycle };
1477
1492
  //# sourceMappingURL=index.js.map
1478
1493
  //# sourceMappingURL=index.js.map