Skip to content

@codesoul-co/hypha-harness / manual-fsm-transition

模块用法

用于使用该功能边界的公共契约与操作。Manual FSM transition 模块公开 1 类、1 常量、4 接口。

从包入口导入

ts
import {
  GovernedFSMTransitionService,
  MANUAL_FSM_TRANSITION_PERMISSION,
} from '@codesoul-co/hypha-harness';

import type {
  GovernedFSMTransitionServiceOptions,
  ManualFSMRunView,
  ManualFSMTransitionCommand,
  ManualFSMTransitionResult,
} from '@codesoul-co/hypha-harness';

使用要点

  • 4 个类型/接口用于应用代码、Adapter 或测试中的静态契约;请使用 import type,运行时不应依赖它们。
  • 1 个类提供可实例化的运行时实现;构造参数与公开方法在各自条目中完整列出。
  • 1 个常量/枚举提供稳定值、Schema、Definition 或默认配置;应复用这些导出,避免在应用中复制内部值。

公共导出

Symbol种类签名说明
GovernedFSMTransitionServicenew GovernedFSMTransitionService(options: GovernedFSMTransitionServiceOptions): GovernedFSMTransitionServiceApplies an explicitly requested FSM edge under owner scope, permission, optimistic revision, Run Lease, fencing, Policy, guard, trace, and replay. It never mutates a snapshot or projection directly.
MANUAL_FSM_TRANSITION_PERMISSION常量const MANUAL_FSM_TRANSITION_PERMISSION: "runtime.fsm.transition"manual-fsm-transition 模块导出的 MANUAL FSM TRANSITION PERMISSION 常量。
GovernedFSMTransitionServiceOptions接口interface GovernedFSMTransitionServiceOptionsGoverned FSM Transition Service Options 接口,共包含 7 个公开字段或方法。
ManualFSMRunView接口interface ManualFSMRunViewManual FSM Run View 接口,共包含 10 个公开字段或方法。
ManualFSMTransitionCommand接口interface ManualFSMTransitionCommandManual FSM Transition Command 接口,共包含 15 个公开字段或方法。
ManualFSMTransitionResult接口interface ManualFSMTransitionResultManual FSM Transition Result 接口,共包含 5 个公开字段或方法。

GovernedFSMTransitionService

Applies an explicitly requested FSM edge under owner scope, permission, optimistic revision, Run Lease, fencing, Policy, guard, trace, and replay. It never mutates a snapshot or projection directly.

  • 种类: 类
  • 导入: import { GovernedFSMTransitionService } from '@codesoul-co/hypha-harness';
  • 源码模块: manual-fsm-transition

声明

text
export declare class GovernedFSMTransitionService {
    constructor(options: GovernedFSMTransitionServiceOptions);
    inspect(scope: RuntimeScope, process: FSMProcessSpec): Promise<ManualFSMRunView>;
    transition(process: FSMProcessSpec, input: ManualFSMTransitionCommand): Promise<ManualFSMTransitionResult>;
}

公开成员

成员种类签名说明
constructor构造函数(options: GovernedFSMTransitionServiceOptions): GovernedFSMTransitionService创建该类的实例。
inspect方法inspect(scope: RuntimeScope, process: FSMProcessSpec): Promise<ManualFSMRunView>公开方法;参数与返回类型以签名列为准。
transition方法transition(process: FSMProcessSpec, input: ManualFSMTransitionCommand): Promise<ManualFSMTransitionResult>公开方法;参数与返回类型以签名列为准。

MANUAL_FSM_TRANSITION_PERMISSION

manual-fsm-transition 模块导出的 MANUAL FSM TRANSITION PERMISSION 常量。

  • 种类: 常量
  • 导入: import { MANUAL_FSM_TRANSITION_PERMISSION } from '@codesoul-co/hypha-harness';
  • 源码模块: manual-fsm-transition

声明

text
export declare const MANUAL_FSM_TRANSITION_PERMISSION: "runtime.fsm.transition";

GovernedFSMTransitionServiceOptions

Governed FSM Transition Service Options 接口,共包含 7 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { GovernedFSMTransitionServiceOptions } from '@codesoul-co/hypha-harness';
  • 源码模块: manual-fsm-transition

声明

text
export interface GovernedFSMTransitionServiceOptions {
    events: EventRuntime;
    projections: ProjectionEngine;
    projectionStore: ProjectionStore<RuntimeOrchestrationProjection>;
    runLeases: RunLeaseStore;
    policy?: PolicyEngine;
    now?: () => string;
    nextId?: (namespace: string) => string;
}

契约成员

成员种类签名说明
events属性events: EventRuntime公开属性;类型、只读和可选状态以签名列为准。
nextId方法nextId?(namespace: string): string公开方法;参数与返回类型以签名列为准。
now方法now?(): string公开方法;参数与返回类型以签名列为准。
policy属性policy?: PolicyEngine公开属性;类型、只读和可选状态以签名列为准。
projections属性projections: ProjectionEngine公开属性;类型、只读和可选状态以签名列为准。
projectionStore属性projectionStore: ProjectionStore<RuntimeOrchestrationProjection>公开属性;类型、只读和可选状态以签名列为准。
runLeases属性runLeases: RunLeaseStore公开属性;类型、只读和可选状态以签名列为准。

ManualFSMRunView

Manual FSM Run View 接口,共包含 10 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ManualFSMRunView } from '@codesoul-co/hypha-harness';
  • 源码模块: manual-fsm-transition

声明

text
export interface ManualFSMRunView {
    runId: string;
    processId: string;
    processVersion: string;
    runRevision: number;
    runStatus: RuntimeOrchestrationProjection['runStatus'];
    currentState?: string;
    statePath: string[];
    stateAttempt: number;
    terminalStates: string[];
    allowedTransitions: Array<{
        to: string;
        guard?: string;
        description?: string;
    }>;
}

契约成员

成员种类签名说明
allowedTransitions属性allowedTransitions: { to: string; guard?: string; description?: string; }[]公开属性;类型、只读和可选状态以签名列为准。
currentState属性currentState?: string公开属性;类型、只读和可选状态以签名列为准。
processId属性processId: string公开属性;类型、只读和可选状态以签名列为准。
processVersion属性processVersion: string公开属性;类型、只读和可选状态以签名列为准。
runId属性runId: string公开属性;类型、只读和可选状态以签名列为准。
runRevision属性runRevision: number公开属性;类型、只读和可选状态以签名列为准。
runStatus属性runStatus: import("/Users/erwin/Downloads/codespace/Hypha/packages/core/dist/index").RuntimeOrchestrationRunStatus公开属性;类型、只读和可选状态以签名列为准。
stateAttempt属性stateAttempt: number公开属性;类型、只读和可选状态以签名列为准。
statePath属性statePath: string[]公开属性;类型、只读和可选状态以签名列为准。
terminalStates属性terminalStates: string[]公开属性;类型、只读和可选状态以签名列为准。

ManualFSMTransitionCommand

Manual FSM Transition Command 接口,共包含 15 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ManualFSMTransitionCommand } from '@codesoul-co/hypha-harness';
  • 源码模块: manual-fsm-transition

声明

text
export interface ManualFSMTransitionCommand {
    commandId: string;
    scope: RuntimeScope;
    principal: RuntimePrincipal;
    ownerId: string;
    leaseTtlMs: number;
    processId: string;
    processVersion: string;
    expectedState: string;
    expectedRunRevision: number;
    targetState: string;
    reason: string;
    requestedAt: string;
    guardContext?: FSMGuardContext;
    variablesPatch?: Record<string, RuntimeJsonValue>;
    idempotencyKey: string;
}

契约成员

成员种类签名说明
commandId属性commandId: string公开属性;类型、只读和可选状态以签名列为准。
expectedRunRevision属性expectedRunRevision: number公开属性;类型、只读和可选状态以签名列为准。
expectedState属性expectedState: string公开属性;类型、只读和可选状态以签名列为准。
guardContext属性guardContext?: FSMGuardContext公开属性;类型、只读和可选状态以签名列为准。
idempotencyKey属性idempotencyKey: string公开属性;类型、只读和可选状态以签名列为准。
leaseTtlMs属性leaseTtlMs: number公开属性;类型、只读和可选状态以签名列为准。
ownerId属性ownerId: string公开属性;类型、只读和可选状态以签名列为准。
principal属性principal: RuntimePrincipal公开属性;类型、只读和可选状态以签名列为准。
processId属性processId: string公开属性;类型、只读和可选状态以签名列为准。
processVersion属性processVersion: string公开属性;类型、只读和可选状态以签名列为准。
reason属性reason: string公开属性;类型、只读和可选状态以签名列为准。
requestedAt属性requestedAt: string公开属性;类型、只读和可选状态以签名列为准。
scope属性scope: RuntimeScope公开属性;类型、只读和可选状态以签名列为准。
targetState属性targetState: string公开属性;类型、只读和可选状态以签名列为准。
variablesPatch属性variablesPatch?: Record<string, RuntimeJsonValue>公开属性;类型、只读和可选状态以签名列为准。

ManualFSMTransitionResult

Manual FSM Transition Result 接口,共包含 5 个公开字段或方法。

  • 种类: 接口
  • 导入: import type { ManualFSMTransitionResult } from '@codesoul-co/hypha-harness';
  • 源码模块: manual-fsm-transition

声明

text
export interface ManualFSMTransitionResult {
    commandId: string;
    disposition: 'applied' | 'reused' | 'lease_unavailable';
    eventIds: string[];
    runRevision: number;
    view: ManualFSMRunView;
}

契约成员

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