Skip to content

@codesoul-co/hypha-core / modules/runtime/runtime-activity-redispatch-service

Using this module

Use the Runtime activity redispatch service module for executing runtime behavior at this boundary. It exports 1 class, 1 function, 6 interfaces, 1 type.

Import from the package entrypoint

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

import type {
  RuntimeActivityRedispatchAttempt,
  RuntimeActivityRedispatchCommand,
  RuntimeActivityRedispatchPort,
  RuntimeActivityRedispatchResult,
  RuntimeActivityRedispatchServiceOptions,
  RuntimeActivityRevisionValidator,
  RuntimeActivityRedispatchReconciliation,
} from '@codesoul-co/hypha-core';

Usage patterns

  • Use the 7 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The module exposes 1 class as constructable runtime implementations. Each symbol entry lists its constructor and public methods.
  • The module exposes 1 function as direct operation entrypoints. Every overload, required/optional parameter, and return type is documented below.

Public exports

SymbolKindSignatureDescription
RuntimeActivityRedispatchServiceclassnew RuntimeActivityRedispatchService(options: RuntimeActivityRedispatchServiceOptions): RuntimeActivityRedispatchServiceRevalidates approved HumanTask evidence, records redispatch intent, invokes an Owner-provided idempotent Activity dispatcher, and persists acceptance. An intent without a receipt is reconciled before any retry is dispatched.
runtimeActivityRedispatchIdentityfunctionruntimeActivityRedispatchIdentity(command: Pick<RuntimeActivityRedispatchCommand, "scope" | "taskId" | "expectedTaskRevision">): stringRuntime Activity Redispatch Identity function with 1 public call signature; parameters and return types are listed below.
RuntimeActivityRedispatchAttemptinterfaceinterface RuntimeActivityRedispatchAttemptRuntime Activity Redispatch Attempt interface with 9 public fields or methods.
RuntimeActivityRedispatchCommandinterfaceinterface RuntimeActivityRedispatchCommand extends RuntimeActivityDescriptorReferenceRuntime Activity Redispatch Command interface with 12 public fields or methods.
RuntimeActivityRedispatchPortinterfaceinterface RuntimeActivityRedispatchPortRuntime Activity Redispatch Port interface with 2 public fields or methods.
RuntimeActivityRedispatchResultinterfaceinterface RuntimeActivityRedispatchResultRuntime Activity Redispatch Result interface with 8 public fields or methods.
RuntimeActivityRedispatchServiceOptionsinterfaceinterface RuntimeActivityRedispatchServiceOptionsRuntime Activity Redispatch Service Options interface with 12 public fields or methods.
RuntimeActivityRevisionValidatorinterfaceinterface RuntimeActivityRevisionValidatorRuntime Activity Revision Validator interface with 1 public fields or methods.
RuntimeActivityRedispatchReconciliationtypetype RuntimeActivityRedispatchReconciliation = { status: 'accepted'; commandId: string; } | { status: 'safe_to_dispatch'; } | { status: 'unknown'; reason: string; }Public type alias for Runtime Activity Redispatch Reconciliation; the declaration contains its complete type expression.

RuntimeActivityRedispatchService

Revalidates approved HumanTask evidence, records redispatch intent, invokes an Owner-provided idempotent Activity dispatcher, and persists acceptance. An intent without a receipt is reconciled before any retry is dispatched.

Declaration

text
export declare class RuntimeActivityRedispatchService {
    constructor(options: RuntimeActivityRedispatchServiceOptions);
    redispatch(command: RuntimeActivityRedispatchCommand): Promise<RuntimeActivityRedispatchResult>;
}

Public members

MemberKindSignatureDescription
constructorconstructor(options: RuntimeActivityRedispatchServiceOptions): RuntimeActivityRedispatchServiceCreates an instance of this class.
redispatchmethodredispatch(command: RuntimeActivityRedispatchCommand): Promise<RuntimeActivityRedispatchResult>Public method; parameters and return type are shown in the signature.

runtimeActivityRedispatchIdentity

Runtime Activity Redispatch Identity function with 1 public call signature; parameters and return types are listed below.

Declaration

text
export declare function runtimeActivityRedispatchIdentity(command: Pick<RuntimeActivityRedispatchCommand, 'scope' | 'taskId' | 'expectedTaskRevision'>): string;

Call signature

text
runtimeActivityRedispatchIdentity(command: Pick<RuntimeActivityRedispatchCommand, "scope" | "taskId" | "expectedTaskRevision">): string

Parameters

ParameterTypeRequiredDescription
commandPick<RuntimeActivityRedispatchCommand, "scope" | "taskId" | "expectedTaskRevision">YesRequired parameter; accepted values are defined by the type column.

Returns

  • Type: string
  • Description: The return contract is defined by the type shown above.

RuntimeActivityRedispatchAttempt

Runtime Activity Redispatch Attempt interface with 9 public fields or methods.

Declaration

text
export interface RuntimeActivityRedispatchAttempt {
    scope: Readonly<RuntimeScope>;
    task: Readonly<RuntimeHumanTask>;
    descriptor: Readonly<RuntimeActivityDescriptor>;
    redispatchCommandId: string;
    redispatchIdempotencyKey: string;
    approvalEventId: string;
    requestEventId: string;
    fencingToken: number;
    signal: AbortSignal;
}

Contract members

MemberKindSignatureDescription
approvalEventIdpropertyapprovalEventId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
descriptorpropertydescriptor: Readonly<RuntimeActivityDescriptor>Public property; its type, readonly modifier and optionality are shown in the signature.
fencingTokenpropertyfencingToken: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
redispatchCommandIdpropertyredispatchCommandId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
redispatchIdempotencyKeypropertyredispatchIdempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requestEventIdpropertyrequestEventId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: Readonly<RuntimeScope>Public property; its type, readonly modifier and optionality are shown in the signature.
signalpropertysignal: AbortSignalPublic property; its type, readonly modifier and optionality are shown in the signature.
taskpropertytask: Readonly<RuntimeHumanTask>Public property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityRedispatchCommand

Runtime Activity Redispatch Command interface with 12 public fields or methods.

Declaration

text
export interface RuntimeActivityRedispatchCommand extends RuntimeActivityDescriptorReference {
    commandId: string;
    scope: RuntimeScope;
    ownerId: string;
    leaseTtlMs: number;
    taskId: string;
    expectedTaskRevision: number;
    expectedSubjectHash: string;
    requestedAt: string;
    idempotencyKey?: string;
    signal?: AbortSignal;
}

Contract members

MemberKindSignatureDescription
activityDescriptorHashpropertyactivityDescriptorHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
activityDescriptorRefpropertyactivityDescriptorRef: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
commandIdpropertycommandId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedSubjectHashpropertyexpectedSubjectHash: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedTaskRevisionpropertyexpectedTaskRevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyKeypropertyidempotencyKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseTtlMspropertyleaseTtlMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
ownerIdpropertyownerId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requestedAtpropertyrequestedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
scopepropertyscope: RuntimeScopePublic property; its type, readonly modifier and optionality are shown in the signature.
signalpropertysignal?: AbortSignalPublic property; its type, readonly modifier and optionality are shown in the signature.
taskIdpropertytaskId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityRedispatchPort

Runtime Activity Redispatch Port interface with 2 public fields or methods.

Declaration

text
export interface RuntimeActivityRedispatchPort {
    dispatch(input: RuntimeActivityRedispatchAttempt): Promise<{
        commandId: string;
        reused: boolean;
    }>;
    /**
     * Resolves the crash window between an accepted external dispatch and its
     * durable Runtime receipt. `safe_to_dispatch` is an authoritative absence
     * result; uncertainty must be returned as `unknown`.
     */
    reconcile(input: RuntimeActivityRedispatchAttempt): Promise<RuntimeActivityRedispatchReconciliation>;
}

Contract members

MemberKindSignatureDescription
dispatchmethoddispatch(input: RuntimeActivityRedispatchAttempt): Promise<{ commandId: string; reused: boolean; }>Public method; parameters and return type are shown in the signature.
reconcilemethodreconcile(input: RuntimeActivityRedispatchAttempt): Promise<RuntimeActivityRedispatchReconciliation>Resolves the crash window between an accepted external dispatch and its durable Runtime receipt. safe_to_dispatch is an authoritative absence result; uncertainty must be returned as unknown.

RuntimeActivityRedispatchResult

Runtime Activity Redispatch Result interface with 8 public fields or methods.

Declaration

text
export interface RuntimeActivityRedispatchResult {
    commandId: string;
    requestEventId: string;
    receiptEventId: string;
    activityCommandId: string;
    eventReused: boolean;
    receiptReused: boolean;
    commandReused: boolean;
    reconciled: boolean;
}

Contract members

MemberKindSignatureDescription
activityCommandIdpropertyactivityCommandId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
commandIdpropertycommandId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
commandReusedpropertycommandReused: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
eventReusedpropertyeventReused: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
receiptEventIdpropertyreceiptEventId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
receiptReusedpropertyreceiptReused: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
reconciledpropertyreconciled: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
requestEventIdpropertyrequestEventId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeActivityRedispatchServiceOptions

Runtime Activity Redispatch Service Options interface with 12 public fields or methods.

Declaration

text
export interface RuntimeActivityRedispatchServiceOptions {
    events: EventRuntime;
    runLeases: RunLeaseStore;
    descriptors: RuntimeActivityDescriptorStore;
    revisions: RuntimeActivityRevisionValidator;
    dispatcher: RuntimeActivityRedispatchPort;
    renewalIntervalMs?: number;
    wait?: (delayMs: number, signal: AbortSignal) => Promise<void>;
    onLeaseRenewalFailure?: (error: unknown, commandId: string) => void;
    operationalTelemetry?: RuntimeOperationalTelemetry;
    monotonicNow?: () => number;
    nextId?: (namespace: string) => string;
    now?: () => string;
}

Contract members

MemberKindSignatureDescription
descriptorspropertydescriptors: RuntimeActivityDescriptorStorePublic property; its type, readonly modifier and optionality are shown in the signature.
dispatcherpropertydispatcher: RuntimeActivityRedispatchPortPublic property; its type, readonly modifier and optionality are shown in the signature.
eventspropertyevents: EventRuntimePublic property; its type, readonly modifier and optionality are shown in the signature.
monotonicNowmethodmonotonicNow?(): numberPublic method; parameters and return type are shown in the signature.
nextIdmethodnextId?(namespace: string): stringPublic method; parameters and return type are shown in the signature.
nowmethodnow?(): stringPublic method; parameters and return type are shown in the signature.
onLeaseRenewalFailuremethodonLeaseRenewalFailure?(error: unknown, commandId: string): voidPublic method; parameters and return type are shown in the signature.
operationalTelemetrypropertyoperationalTelemetry?: RuntimeOperationalTelemetryPublic property; its type, readonly modifier and optionality are shown in the signature.
renewalIntervalMspropertyrenewalIntervalMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
revisionspropertyrevisions: RuntimeActivityRevisionValidatorPublic property; its type, readonly modifier and optionality are shown in the signature.
runLeasespropertyrunLeases: RunLeaseStorePublic property; its type, readonly modifier and optionality are shown in the signature.
waitmethodwait?(delayMs: number, signal: AbortSignal): Promise<void>Public method; parameters and return type are shown in the signature.

RuntimeActivityRevisionValidator

Runtime Activity Revision Validator interface with 1 public fields or methods.

Declaration

text
export interface RuntimeActivityRevisionValidator {
    validate(input: {
        task: Readonly<RuntimeHumanTask>;
        descriptor: Readonly<RuntimeActivityDescriptor>;
    }): Promise<void>;
}

Contract members

MemberKindSignatureDescription
validatemethodvalidate(input: { task: Readonly<RuntimeHumanTask>; descriptor: Readonly<RuntimeActivityDescriptor>; }): Promise<void>Public method; parameters and return type are shown in the signature.

RuntimeActivityRedispatchReconciliation

Public type alias for Runtime Activity Redispatch Reconciliation; the declaration contains its complete type expression.

Declaration

text
export type RuntimeActivityRedispatchReconciliation = {
    status: 'accepted';
    commandId: string;
} | {
    status: 'safe_to_dispatch';
} | {
    status: 'unknown';
    reason: string;
};