Skip to content

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

模块用法

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

从包入口导入

ts
import {
  RUNTIME_CHECKPOINT_COMPRESSIONS,
  RUNTIME_CHECKPOINT_DISPOSITIONS,
  RUNTIME_CHECKPOINT_MODES,
  RUNTIME_CHECKPOINT_REASONS,
} from '@codesoul-co/hypha-core';

import type {
  RuntimeCheckpointCreateCommand,
  RuntimeCheckpointCreateResult,
  RuntimeCheckpointLoadRequest,
  RuntimeCheckpointLoadResult,
  RuntimeCheckpointPolicySpec,
  RuntimeCheckpointPutResult,
  RuntimeCheckpointRecord,
  RuntimeCheckpointStore,
} from '@codesoul-co/hypha-core';

// 完整导出列表见下方。

使用要点

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

公共导出

Symbol种类签名说明
RUNTIME_CHECKPOINT_COMPRESSIONS常量const RUNTIME_CHECKPOINT_COMPRESSIONS: readonly ["none", "gzip", "zstd"]contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT COMPRESSIONS 常量。
RUNTIME_CHECKPOINT_DISPOSITIONS常量const RUNTIME_CHECKPOINT_DISPOSITIONS: readonly ["applied", "reused", "lease_unavailable"]contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT DISPOSITIONS 常量。
RUNTIME_CHECKPOINT_MODES常量const RUNTIME_CHECKPOINT_MODES: readonly ["none", "state_boundary", "every_n_events", "wait_boundary", "custom"]contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT MODES 常量。
RUNTIME_CHECKPOINT_REASONS常量const RUNTIME_CHECKPOINT_REASONS: readonly ["state_boundary", "human_wait", "signal_wait", "timer_wait", "manual", "failure"]contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT REASONS 常量。
RuntimeCheckpointCreateCommand接口interface RuntimeCheckpointCreateCommandRuntime Checkpoint Create Command 接口,共包含 15 个公开字段或方法。
RuntimeCheckpointCreateResult接口interface RuntimeCheckpointCreateResultRuntime Checkpoint Create Result 接口,共包含 4 个公开字段或方法。
RuntimeCheckpointLoadRequest接口interface RuntimeCheckpointLoadRequestRuntime Checkpoint Load Request 接口,共包含 3 个公开字段或方法。
RuntimeCheckpointLoadResult接口interface RuntimeCheckpointLoadResultRuntime Checkpoint Load Result 接口,共包含 4 个公开字段或方法。
RuntimeCheckpointPolicySpec接口interface RuntimeCheckpointPolicySpecRuntime Checkpoint Policy Spec 接口,共包含 6 个公开字段或方法。
RuntimeCheckpointPutResult接口interface RuntimeCheckpointPutResultRuntime Checkpoint Put Result 接口,共包含 2 个公开字段或方法。
RuntimeCheckpointRecord接口interface RuntimeCheckpointRecordRuntime Checkpoint Record 接口,共包含 20 个公开字段或方法。
RuntimeCheckpointStore接口interface RuntimeCheckpointStoreRuntime Checkpoint Store 接口,共包含 4 个公开字段或方法。
RuntimeCheckpointCompression类型type RuntimeCheckpointCompression = (typeof RUNTIME_CHECKPOINT_COMPRESSIONS)[number]Runtime Checkpoint Compression 公共类型别名;完整类型表达式见声明。
RuntimeCheckpointDisposition类型type RuntimeCheckpointDisposition = (typeof RUNTIME_CHECKPOINT_DISPOSITIONS)[number]Runtime Checkpoint Disposition 公共类型别名;完整类型表达式见声明。
RuntimeCheckpointMode类型type RuntimeCheckpointMode = (typeof RUNTIME_CHECKPOINT_MODES)[number]Runtime Checkpoint Mode 公共类型别名;完整类型表达式见声明。
RuntimeCheckpointReason类型type RuntimeCheckpointReason = (typeof RUNTIME_CHECKPOINT_REASONS)[number]Runtime Checkpoint Reason 公共类型别名;完整类型表达式见声明。

RUNTIME_CHECKPOINT_COMPRESSIONS

contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT COMPRESSIONS 常量。

声明

text
export declare const RUNTIME_CHECKPOINT_COMPRESSIONS: readonly ["none", "gzip", "zstd"];

RUNTIME_CHECKPOINT_DISPOSITIONS

contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT DISPOSITIONS 常量。

声明

text
export declare const RUNTIME_CHECKPOINT_DISPOSITIONS: readonly ["applied", "reused", "lease_unavailable"];

RUNTIME_CHECKPOINT_MODES

contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT MODES 常量。

声明

text
export declare const RUNTIME_CHECKPOINT_MODES: readonly ["none", "state_boundary", "every_n_events", "wait_boundary", "custom"];

RUNTIME_CHECKPOINT_REASONS

contracts/runtime-checkpoint 模块导出的 RUNTIME CHECKPOINT REASONS 常量。

声明

text
export declare const RUNTIME_CHECKPOINT_REASONS: readonly ["state_boundary", "human_wait", "signal_wait", "timer_wait", "manual", "failure"];

RuntimeCheckpointCreateCommand

Runtime Checkpoint Create Command 接口,共包含 15 个公开字段或方法。

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

声明

text
export interface RuntimeCheckpointCreateCommand {
    checkpointId: string;
    scope: RuntimeScope;
    ownerId: string;
    leaseTtlMs: number;
    workflowRevision: string;
    processHash: string;
    variablesHash: string;
    dependencySnapshotRef: string;
    toolContractSnapshotRef?: string;
    workspaceSnapshotRef?: string;
    contextSnapshotRefs?: string[];
    reason: RuntimeCheckpointReason;
    createdAt: string;
    idempotencyKey?: string;
    metadata?: Record<string, RuntimeJsonValue>;
}

契约成员

成员种类签名说明
checkpointId属性checkpointId: string公开属性;类型、只读和可选状态以签名列为准。
contextSnapshotRefs属性contextSnapshotRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
dependencySnapshotRef属性dependencySnapshotRef: string公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey?: string公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, RuntimeJsonValue>公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
processHash属性processHash: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: "manual" | "state_boundary" | "human_wait" | "signal_wait" | "timer_wait" | "failure"公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
toolContractSnapshotRef属性toolContractSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。
variablesHash属性variablesHash: string公开属性;类型、只读和可选状态以签名列为准。
workflowRevision属性workflowRevision: string公开属性;类型、只读和可选状态以签名列为准。
workspaceSnapshotRef属性workspaceSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeCheckpointCreateResult

Runtime Checkpoint Create Result 接口,共包含 4 个公开字段或方法。

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

声明

text
export interface RuntimeCheckpointCreateResult {
    checkpointId: string;
    disposition: RuntimeCheckpointDisposition;
    eventIds: string[];
    record?: RuntimeCheckpointRecord;
}

契约成员

成员种类签名说明
checkpointId属性checkpointId: string公开属性;类型、只读和可选状态以签名列为准。
disposition属性disposition: "applied" | "reused" | "lease_unavailable"公开属性;类型、只读和可选状态以签名列为准。
eventIds属性eventIds: string[]公开属性;类型、只读和可选状态以签名列为准。
record属性record?: RuntimeCheckpointRecord公开属性;类型、只读和可选状态以签名列为准。

RuntimeCheckpointLoadRequest

Runtime Checkpoint Load Request 接口,共包含 3 个公开字段或方法。

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

声明

text
export interface RuntimeCheckpointLoadRequest {
    scope: RuntimeScope;
    checkpointId?: string;
    checkedAt: string;
}

契约成员

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

RuntimeCheckpointLoadResult

Runtime Checkpoint Load Result 接口,共包含 4 个公开字段或方法。

声明

text
export interface RuntimeCheckpointLoadResult {
    record: RuntimeCheckpointRecord;
    currentHeadSequence: number;
    deltaFromSequence: number;
    deltaEventCount: number;
}

契约成员

成员种类签名说明
currentHeadSequence属性currentHeadSequence: number公开属性;类型、只读和可选状态以签名列为准。
deltaEventCount属性deltaEventCount: number公开属性;类型、只读和可选状态以签名列为准。
deltaFromSequence属性deltaFromSequence: number公开属性;类型、只读和可选状态以签名列为准。
record属性record: RuntimeCheckpointRecord公开属性;类型、只读和可选状态以签名列为准。

RuntimeCheckpointPolicySpec

Runtime Checkpoint Policy Spec 接口,共包含 6 个公开字段或方法。

声明

text
export interface RuntimeCheckpointPolicySpec {
    mode: RuntimeCheckpointMode;
    everyNEvents?: number;
    retainLast?: number;
    persistWorkspaceSnapshot?: boolean;
    persistContextRefs?: boolean;
    compression?: RuntimeCheckpointCompression;
}

契约成员

成员种类签名说明
compression属性compression?: "none" | "gzip" | "zstd"公开属性;类型、只读和可选状态以签名列为准。
everyNEvents属性everyNEvents?: number公开属性;类型、只读和可选状态以签名列为准。
mode属性mode: "none" | "custom" | "state_boundary" | "every_n_events" | "wait_boundary"公开属性;类型、只读和可选状态以签名列为准。
persistContextRefs属性persistContextRefs?: boolean公开属性;类型、只读和可选状态以签名列为准。
persistWorkspaceSnapshot属性persistWorkspaceSnapshot?: boolean公开属性;类型、只读和可选状态以签名列为准。
retainLast属性retainLast?: number公开属性;类型、只读和可选状态以签名列为准。

RuntimeCheckpointPutResult

Runtime Checkpoint Put Result 接口,共包含 2 个公开字段或方法。

声明

text
export interface RuntimeCheckpointPutResult {
    record: RuntimeCheckpointRecord;
    reused: boolean;
}

契约成员

成员种类签名说明
record属性record: RuntimeCheckpointRecord公开属性;类型、只读和可选状态以签名列为准。
reused属性reused: boolean公开属性;类型、只读和可选状态以签名列为准。

RuntimeCheckpointRecord

Runtime Checkpoint Record 接口,共包含 20 个公开字段或方法。

声明

text
export interface RuntimeCheckpointRecord {
    id: string;
    scope: RuntimeScope;
    sequence: number;
    workflowRevision: string;
    processHash: string;
    currentState: string;
    variablesHash: string;
    projectionVersion: string;
    projectionSnapshot: RuntimeOrchestrationProjection;
    dependencySnapshotRef: string;
    toolContractSnapshotRef?: string;
    workspaceSnapshotRef?: string;
    contextSnapshotRefs?: string[];
    pendingWaitRef?: string;
    lastEventSequence: number;
    reason: RuntimeCheckpointReason;
    requestHash: string;
    checksum: string;
    createdAt: string;
    metadata?: Record<string, RuntimeJsonValue>;
}

契约成员

成员种类签名说明
checksum属性checksum: string公开属性;类型、只读和可选状态以签名列为准。
contextSnapshotRefs属性contextSnapshotRefs?: string[]公开属性;类型、只读和可选状态以签名列为准。
createdAt属性createdAt: string公开属性;类型、只读和可选状态以签名列为准。
currentState属性currentState: string公开属性;类型、只读和可选状态以签名列为准。
dependencySnapshotRef属性dependencySnapshotRef: string公开属性;类型、只读和可选状态以签名列为准。
id属性id: string公开属性;类型、只读和可选状态以签名列为准。
lastEventSequence属性lastEventSequence: number公开属性;类型、只读和可选状态以签名列为准。
metadata属性metadata?: Record<string, RuntimeJsonValue>公开属性;类型、只读和可选状态以签名列为准。
pendingWaitRef属性pendingWaitRef?: string公开属性;类型、只读和可选状态以签名列为准。
processHash属性processHash: string公开属性;类型、只读和可选状态以签名列为准。
projectionSnapshot属性projectionSnapshot: RuntimeOrchestrationProjection公开属性;类型、只读和可选状态以签名列为准。
projectionVersion属性projectionVersion: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: "manual" | "state_boundary" | "human_wait" | "signal_wait" | "timer_wait" | "failure"公开属性;类型、只读和可选状态以签名列为准。
requestHash属性requestHash: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
sequence属性sequence: number公开属性;类型、只读和可选状态以签名列为准。
toolContractSnapshotRef属性toolContractSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。
variablesHash属性variablesHash: string公开属性;类型、只读和可选状态以签名列为准。
workflowRevision属性workflowRevision: string公开属性;类型、只读和可选状态以签名列为准。
workspaceSnapshotRef属性workspaceSnapshotRef?: string公开属性;类型、只读和可选状态以签名列为准。

RuntimeCheckpointStore

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

声明

text
export interface RuntimeCheckpointStore {
    put(record: RuntimeCheckpointRecord, idempotencyKey: string): Promise<RuntimeCheckpointPutResult>;
    get(scope: RuntimeScope, checkpointId: string): Promise<RuntimeCheckpointRecord | null>;
    latest(scope: RuntimeScope): Promise<RuntimeCheckpointRecord | null>;
    list(scope: RuntimeScope, limit?: number): Promise<RuntimeCheckpointRecord[]>;
}

契约成员

成员种类签名说明
get方法get(scope: RuntimeScope, checkpointId: string): Promise<RuntimeCheckpointRecord | null>公开方法;参数与返回类型以签名列为准。
latest方法latest(scope: RuntimeScope): Promise<RuntimeCheckpointRecord | null>公开方法;参数与返回类型以签名列为准。
list方法list(scope: RuntimeScope, limit?: number): Promise<RuntimeCheckpointRecord[]>公开方法;参数与返回类型以签名列为准。
put方法put(record: RuntimeCheckpointRecord, idempotencyKey: string): Promise<RuntimeCheckpointPutResult>公开方法;参数与返回类型以签名列为准。

RuntimeCheckpointCompression

Runtime Checkpoint Compression 公共类型别名;完整类型表达式见声明。

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

声明

text
export type RuntimeCheckpointCompression = (typeof RUNTIME_CHECKPOINT_COMPRESSIONS)[number];

RuntimeCheckpointDisposition

Runtime Checkpoint Disposition 公共类型别名;完整类型表达式见声明。

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

声明

text
export type RuntimeCheckpointDisposition = (typeof RUNTIME_CHECKPOINT_DISPOSITIONS)[number];

RuntimeCheckpointMode

Runtime Checkpoint Mode 公共类型别名;完整类型表达式见声明。

声明

text
export type RuntimeCheckpointMode = (typeof RUNTIME_CHECKPOINT_MODES)[number];

RuntimeCheckpointReason

Runtime Checkpoint Reason 公共类型别名;完整类型表达式见声明。

声明

text
export type RuntimeCheckpointReason = (typeof RUNTIME_CHECKPOINT_REASONS)[number];