Skip to content

@codesoul-co/hypha-core / contracts/runtime-replay

模块用法

用于声明并运行时校验契约。Runtime replay 模块公开 1 常量、6 接口、1 类型。

从包入口导入

ts
import {
  RUNTIME_REPLAY_DIVERGENCE_KINDS,
} from '@codesoul-co/hypha-core';

import type {
  RuntimeReplayDivergence,
  RuntimeReplayRequest,
  RuntimeReplayResult,
  RuntimeReplayServiceContract,
  RuntimeReplayVerificationRequest,
  RuntimeReplayVerificationResult,
  RuntimeReplayDivergenceKind,
} from '@codesoul-co/hypha-core';

使用要点

  • 7 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

公共导出

Symbol种类签名说明
RUNTIME_REPLAY_DIVERGENCE_KINDS常量const RUNTIME_REPLAY_DIVERGENCE_KINDS: readonly ["workflow_revision", "process_hash", "dependency_snapshot", "projection_version", "snapshot_checksum"]contracts/runtime-replay 模块导出的 RUNTIME REPLAY DIVERGENCE KINDS 常量。
RuntimeReplayDivergence接口interface RuntimeReplayDivergenceRuntime Replay Divergence 接口,共包含 4 个公开字段或方法。
RuntimeReplayRequest接口interface RuntimeReplayRequestRuntime Replay Request 接口,共包含 7 个公开字段或方法。
RuntimeReplayResult接口interface RuntimeReplayResultRuntime Replay Result 接口,共包含 16 个公开字段或方法。
RuntimeReplayServiceContract接口interface RuntimeReplayServiceContractRuntime Replay Service Contract 接口,共包含 2 个公开字段或方法。
RuntimeReplayVerificationRequest接口interface RuntimeReplayVerificationRequestRuntime Replay Verification Request 接口,共包含 2 个公开字段或方法。
RuntimeReplayVerificationResult接口interface RuntimeReplayVerificationResultRuntime Replay Verification Result 接口,共包含 3 个公开字段或方法。
RuntimeReplayDivergenceKind类型type RuntimeReplayDivergenceKind = (typeof RUNTIME_REPLAY_DIVERGENCE_KINDS)[number]Runtime Replay Divergence Kind 公共类型别名;完整类型表达式见声明。

RUNTIME_REPLAY_DIVERGENCE_KINDS

contracts/runtime-replay 模块导出的 RUNTIME REPLAY DIVERGENCE KINDS 常量。

  • 种类: 常量
  • 导入: import { RUNTIME_REPLAY_DIVERGENCE_KINDS } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export declare const RUNTIME_REPLAY_DIVERGENCE_KINDS: readonly ["workflow_revision", "process_hash", "dependency_snapshot", "projection_version", "snapshot_checksum"];

RuntimeReplayDivergence

Runtime Replay Divergence 接口,共包含 4 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeReplayDivergence } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export interface RuntimeReplayDivergence {
    kind: RuntimeReplayDivergenceKind;
    expected: string;
    actual: string;
    message: string;
}

契约成员

成员种类签名说明
actual属性actual: string公开属性;类型、只读和可选状态以签名列为准。
expected属性expected: string公开属性;类型、只读和可选状态以签名列为准。
kind属性kind: "workflow_revision" | "process_hash" | "dependency_snapshot" | "projection_version" | "snapshot_checksum"公开属性;类型、只读和可选状态以签名列为准。
message属性message: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeReplayRequest

Runtime Replay Request 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeReplayRequest } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export interface RuntimeReplayRequest {
    scope: RuntimeScope;
    checkpointId?: string;
    expectedWorkflowRevision: string;
    expectedProcessHash: string;
    expectedDependencySnapshotRef: string;
    toSequence?: number;
    requestedAt: string;
}

契约成员

成员种类签名说明
checkpointId属性checkpointId?: string公开属性;类型、只读和可选状态以签名列为准。
expectedDependencySnapshotRef属性expectedDependencySnapshotRef: string公开属性;类型、只读和可选状态以签名列为准。
expectedProcessHash属性expectedProcessHash: string公开属性;类型、只读和可选状态以签名列为准。
expectedWorkflowRevision属性expectedWorkflowRevision: string公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
toSequence属性toSequence?: number公开属性;类型、只读和可选状态以签名列为准。

RuntimeReplayResult

Runtime Replay Result 接口,共包含 16 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeReplayResult } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export interface RuntimeReplayResult {
    sourceRunId: string;
    mode: 'deterministic';
    checkpointId: string;
    baseEventSequence: number;
    targetEventSequence: number;
    replayedEventCount: number;
    appliedEventCount: number;
    eventIds: string[];
    workflowRevision: string;
    processHash: string;
    dependencySnapshotRef: string;
    projectionVersion: string;
    finalSnapshot: RuntimeOrchestrationProjection;
    finalSnapshotChecksum: string;
    divergences: RuntimeReplayDivergence[];
    completedAt: string;
}

契约成员

成员种类签名说明
appliedEventCount属性appliedEventCount: number公开属性;类型、只读和可选状态以签名列为准。
baseEventSequence属性baseEventSequence: number公开属性;类型、只读和可选状态以签名列为准。
checkpointId属性checkpointId: string公开属性;类型、只读和可选状态以签名列为准。
completedAt属性completedAt: string公开属性;类型、只读和可选状态以签名列为准。
dependencySnapshotRef属性dependencySnapshotRef: string公开属性;类型、只读和可选状态以签名列为准。
divergences属性divergences: RuntimeReplayDivergence[]公开属性;类型、只读和可选状态以签名列为准。
eventIds属性eventIds: string[]公开属性;类型、只读和可选状态以签名列为准。
finalSnapshot属性finalSnapshot: RuntimeOrchestrationProjection公开属性;类型、只读和可选状态以签名列为准。
finalSnapshotChecksum属性finalSnapshotChecksum: string公开属性;类型、只读和可选状态以签名列为准。
mode属性mode: "deterministic"公开属性;类型、只读和可选状态以签名列为准。
processHash属性processHash: string公开属性;类型、只读和可选状态以签名列为准。
projectionVersion属性projectionVersion: string公开属性;类型、只读和可选状态以签名列为准。
replayedEventCount属性replayedEventCount: number公开属性;类型、只读和可选状态以签名列为准。
sourceRunId属性sourceRunId: string公开属性;类型、只读和可选状态以签名列为准。
targetEventSequence属性targetEventSequence: number公开属性;类型、只读和可选状态以签名列为准。
workflowRevision属性workflowRevision: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeReplayServiceContract

Runtime Replay Service Contract 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeReplayServiceContract } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export interface RuntimeReplayServiceContract {
    replay(request: RuntimeReplayRequest): Promise<RuntimeReplayResult>;
    verify(request: RuntimeReplayVerificationRequest): Promise<RuntimeReplayVerificationResult>;
}

契约成员

成员种类签名说明
replay方法replay(request: RuntimeReplayRequest): Promise<RuntimeReplayResult>公开方法;参数与返回类型以签名列为准。
verify方法verify(request: RuntimeReplayVerificationRequest): Promise<RuntimeReplayVerificationResult>公开方法;参数与返回类型以签名列为准。

RuntimeReplayVerificationRequest

Runtime Replay Verification Request 接口,共包含 2 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeReplayVerificationRequest } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export interface RuntimeReplayVerificationRequest {
    replay: RuntimeReplayRequest;
    expectedSnapshotChecksum: string;
}

契约成员

成员种类签名说明
expectedSnapshotChecksum属性expectedSnapshotChecksum: string公开属性;类型、只读和可选状态以签名列为准。
replay属性replay: RuntimeReplayRequest公开属性;类型、只读和可选状态以签名列为准。

RuntimeReplayVerificationResult

Runtime Replay Verification Result 接口,共包含 3 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { RuntimeReplayVerificationResult } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export interface RuntimeReplayVerificationResult {
    replay: RuntimeReplayResult;
    matches: boolean;
    divergences: RuntimeReplayDivergence[];
}

契约成员

成员种类签名说明
divergences属性divergences: RuntimeReplayDivergence[]公开属性;类型、只读和可选状态以签名列为准。
matches属性matches: boolean公开属性;类型、只读和可选状态以签名列为准。
replay属性replay: RuntimeReplayResult公开属性;类型、只读和可选状态以签名列为准。

RuntimeReplayDivergenceKind

Runtime Replay Divergence Kind 公共类型别名;完整类型表达式见声明。

  • 种类: 类型
  • 导入: import type { RuntimeReplayDivergenceKind } from '@codesoul-co/hypha-core';
  • 源码模块: contracts/runtime-replay

声明

text
export type RuntimeReplayDivergenceKind = (typeof RUNTIME_REPLAY_DIVERGENCE_KINDS)[number];