@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 RuntimeReplayDivergence | Runtime Replay Divergence 接口,共包含 4 个公开字段或方法。 |
RuntimeReplayRequest | 接口 | interface RuntimeReplayRequest | Runtime Replay Request 接口,共包含 7 个公开字段或方法。 |
RuntimeReplayResult | 接口 | interface RuntimeReplayResult | Runtime Replay Result 接口,共包含 16 个公开字段或方法。 |
RuntimeReplayServiceContract | 接口 | interface RuntimeReplayServiceContract | Runtime Replay Service Contract 接口,共包含 2 个公开字段或方法。 |
RuntimeReplayVerificationRequest | 接口 | interface RuntimeReplayVerificationRequest | Runtime Replay Verification Request 接口,共包含 2 个公开字段或方法。 |
RuntimeReplayVerificationResult | 接口 | interface RuntimeReplayVerificationResult | Runtime 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];