Skip to content

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

Using this module

Use the Runtime cancellation module for declaring and runtime-validating contracts. It exports 4 constants, 10 interfaces, 4 types.

Import from the package entrypoint

ts
import {
  RUNTIME_CANCELLATION_DISPOSITIONS,
  RUNTIME_CANCELLATION_PROPAGATIONS,
  RUNTIME_CANCELLATION_TARGET_STATUSES,
  RUNTIME_CANCELLATION_TARGET_TYPES,
} from '@codesoul-co/hypha-core';

import type {
  RuntimeActivityCancellationPort,
  RuntimeActivityCancellationRequest,
  RuntimeCancelCommand,
  RuntimeCancellationPolicy,
  RuntimeCancellationTargetResult,
  RuntimeCancelResult,
  RuntimeChildRunCancellationPort,
  RuntimeChildRunCancellationRequest,
} from '@codesoul-co/hypha-core';

// The complete export list is documented below.

Usage patterns

  • Use the 14 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.
  • The 4 constant/enum exports provide stable values, schemas, definitions, or defaults. Reuse these exports instead of copying internal values into an application.

Public exports

SymbolKindSignatureDescription
RUNTIME_CANCELLATION_DISPOSITIONSconstantconst RUNTIME_CANCELLATION_DISPOSITIONS: readonly ["applied", "reused"]RUNTIME CANCELLATION DISPOSITIONS constant exported by the contracts/runtime-cancellation module.
RUNTIME_CANCELLATION_PROPAGATIONSconstantconst RUNTIME_CANCELLATION_PROPAGATIONS: readonly ["none", "children", "all_descendants"]RUNTIME CANCELLATION PROPAGATIONS constant exported by the contracts/runtime-cancellation module.
RUNTIME_CANCELLATION_TARGET_STATUSESconstantconst RUNTIME_CANCELLATION_TARGET_STATUSES: readonly ["cancelled", "already_terminal", "not_found", "failed"]RUNTIME CANCELLATION TARGET STATUSES constant exported by the contracts/runtime-cancellation module.
RUNTIME_CANCELLATION_TARGET_TYPESconstantconst RUNTIME_CANCELLATION_TARGET_TYPES: readonly ["activity", "child_run", "session_command"]RUNTIME CANCELLATION TARGET TYPES constant exported by the contracts/runtime-cancellation module.
RuntimeActivityCancellationPortinterfaceinterface RuntimeActivityCancellationPortRuntime Activity Cancellation Port interface with 1 public fields or methods.
RuntimeActivityCancellationRequestinterfaceinterface RuntimeActivityCancellationRequestRuntime Activity Cancellation Request interface with 7 public fields or methods.
RuntimeCancelCommandinterfaceinterface RuntimeCancelCommandRuntime Cancel Command interface with 9 public fields or methods.
RuntimeCancellationPolicyinterfaceinterface RuntimeCancellationPolicyRuntime Cancellation Policy interface with 3 public fields or methods.
RuntimeCancellationTargetResultinterfaceinterface RuntimeCancellationTargetResultRuntime Cancellation Target Result interface with 4 public fields or methods.
RuntimeCancelResultinterfaceinterface RuntimeCancelResultRuntime Cancel Result interface with 6 public fields or methods.
RuntimeChildRunCancellationPortinterfaceinterface RuntimeChildRunCancellationPortRuntime Child Run Cancellation Port interface with 2 public fields or methods.
RuntimeChildRunCancellationRequestinterfaceinterface RuntimeChildRunCancellationRequestRuntime Child Run Cancellation Request interface with 8 public fields or methods.
RuntimeChildRunListRequestinterfaceinterface RuntimeChildRunListRequestRuntime Child Run List Request interface with 2 public fields or methods.
RuntimeChildRunReferenceinterfaceinterface RuntimeChildRunReferenceRuntime Child Run Reference interface with 1 public fields or methods.
RuntimeCancellationDispositiontypetype RuntimeCancellationDisposition = (typeof RUNTIME_CANCELLATION_DISPOSITIONS)[number]Public type alias for Runtime Cancellation Disposition; the declaration contains its complete type expression.
RuntimeCancellationPropagationtypetype RuntimeCancellationPropagation = (typeof RUNTIME_CANCELLATION_PROPAGATIONS)[number]Public type alias for Runtime Cancellation Propagation; the declaration contains its complete type expression.
RuntimeCancellationTargetStatustypetype RuntimeCancellationTargetStatus = (typeof RUNTIME_CANCELLATION_TARGET_STATUSES)[number]Public type alias for Runtime Cancellation Target Status; the declaration contains its complete type expression.
RuntimeCancellationTargetTypetypetype RuntimeCancellationTargetType = (typeof RUNTIME_CANCELLATION_TARGET_TYPES)[number]Public type alias for Runtime Cancellation Target Type; the declaration contains its complete type expression.

RUNTIME_CANCELLATION_DISPOSITIONS

RUNTIME CANCELLATION DISPOSITIONS constant exported by the contracts/runtime-cancellation module.

Declaration

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

RUNTIME_CANCELLATION_PROPAGATIONS

RUNTIME CANCELLATION PROPAGATIONS constant exported by the contracts/runtime-cancellation module.

Declaration

text
export declare const RUNTIME_CANCELLATION_PROPAGATIONS: readonly ["none", "children", "all_descendants"];

RUNTIME_CANCELLATION_TARGET_STATUSES

RUNTIME CANCELLATION TARGET STATUSES constant exported by the contracts/runtime-cancellation module.

Declaration

text
export declare const RUNTIME_CANCELLATION_TARGET_STATUSES: readonly ["cancelled", "already_terminal", "not_found", "failed"];

RUNTIME_CANCELLATION_TARGET_TYPES

RUNTIME CANCELLATION TARGET TYPES constant exported by the contracts/runtime-cancellation module.

Declaration

text
export declare const RUNTIME_CANCELLATION_TARGET_TYPES: readonly ["activity", "child_run", "session_command"];

RuntimeActivityCancellationPort

Runtime Activity Cancellation Port interface with 1 public fields or methods.

Declaration

text
export interface RuntimeActivityCancellationPort {
    cancel(request: RuntimeActivityCancellationRequest): Promise<RuntimeCancellationTargetResult>;
}

Contract members

MemberKindSignatureDescription
cancelmethodcancel(request: RuntimeActivityCancellationRequest): Promise<RuntimeCancellationTargetResult>Public method; parameters and return type are shown in the signature.

RuntimeActivityCancellationRequest

Runtime Activity Cancellation Request interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeActivityCancellationRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-cancellation

Declaration

text
export interface RuntimeActivityCancellationRequest {
    scope: RuntimeScope;
    activityId: string;
    reason: string;
    requestedAt: string;
    deadlineAt?: string;
    fencingToken: number;
    idempotencyKey: string;
}

Contract members

MemberKindSignatureDescription
activityIdpropertyactivityId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
deadlineAtpropertydeadlineAt?: stringPublic 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.
idempotencyKeypropertyidempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason: 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.

RuntimeCancelCommand

Runtime Cancel Command interface with 9 public fields or methods.

Declaration

text
export interface RuntimeCancelCommand {
    commandId: string;
    scope: RuntimeScope;
    principal: RuntimePrincipal;
    ownerId: string;
    leaseTtlMs: number;
    reason: string;
    policy: RuntimeCancellationPolicy;
    requestedAt: string;
    idempotencyKey?: string;
}

Contract members

MemberKindSignatureDescription
commandIdpropertycommandId: stringPublic 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.
policypropertypolicy: RuntimeCancellationPolicyPublic property; its type, readonly modifier and optionality are shown in the signature.
principalpropertyprincipal: RuntimePrincipalPublic property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason: 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.

RuntimeCancellationPolicy

Runtime Cancellation Policy interface with 3 public fields or methods.

Declaration

text
export interface RuntimeCancellationPolicy {
    propagation: RuntimeCancellationPropagation;
    cancelRunningActivities: boolean;
    waitGraceMs?: number;
}

Contract members

MemberKindSignatureDescription
cancelRunningActivitiespropertycancelRunningActivities: booleanPublic property; its type, readonly modifier and optionality are shown in the signature.
propagationpropertypropagation: "none" | "children" | "all_descendants"Public property; its type, readonly modifier and optionality are shown in the signature.
waitGraceMspropertywaitGraceMs?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCancellationTargetResult

Runtime Cancellation Target Result interface with 4 public fields or methods.

Declaration

text
export interface RuntimeCancellationTargetResult {
    targetType: RuntimeCancellationTargetType;
    targetId: string;
    status: RuntimeCancellationTargetStatus;
    error?: NormalizedRuntimeError;
}

Contract members

MemberKindSignatureDescription
errorpropertyerror?: NormalizedRuntimeErrorPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: "cancelled" | "failed" | "not_found" | "already_terminal"Public property; its type, readonly modifier and optionality are shown in the signature.
targetIdpropertytargetId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
targetTypepropertytargetType: "activity" | "child_run" | "session_command"Public property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCancelResult

Runtime Cancel Result interface with 6 public fields or methods.

Declaration

text
export interface RuntimeCancelResult {
    commandId: string;
    disposition: RuntimeCancellationDisposition;
    eventIds: string[];
    targetResults: RuntimeCancellationTargetResult[];
    unresolvedActivityIds: string[];
    projection: RuntimeOrchestrationProjection;
}

Contract members

MemberKindSignatureDescription
commandIdpropertycommandId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
dispositionpropertydisposition: "applied" | "reused"Public property; its type, readonly modifier and optionality are shown in the signature.
eventIdspropertyeventIds: string[]Public property; its type, readonly modifier and optionality are shown in the signature.
projectionpropertyprojection: RuntimeOrchestrationProjectionPublic property; its type, readonly modifier and optionality are shown in the signature.
targetResultspropertytargetResults: RuntimeCancellationTargetResult[]Public property; its type, readonly modifier and optionality are shown in the signature.
unresolvedActivityIdspropertyunresolvedActivityIds: string[]Public property; its type, readonly modifier and optionality are shown in the signature.

RuntimeChildRunCancellationPort

Runtime Child Run Cancellation Port interface with 2 public fields or methods.

Declaration

text
export interface RuntimeChildRunCancellationPort {
    listChildren(request: RuntimeChildRunListRequest): Promise<RuntimeChildRunReference[]>;
    cancel(request: RuntimeChildRunCancellationRequest): Promise<RuntimeCancellationTargetResult>;
}

Contract members

MemberKindSignatureDescription
cancelmethodcancel(request: RuntimeChildRunCancellationRequest): Promise<RuntimeCancellationTargetResult>Public method; parameters and return type are shown in the signature.
listChildrenmethodlistChildren(request: RuntimeChildRunListRequest): Promise<RuntimeChildRunReference[]>Public method; parameters and return type are shown in the signature.

RuntimeChildRunCancellationRequest

Runtime Child Run Cancellation Request interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { RuntimeChildRunCancellationRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/runtime-cancellation

Declaration

text
export interface RuntimeChildRunCancellationRequest {
    parentScope: RuntimeScope;
    childRunId: string;
    reason: string;
    propagation: Exclude<RuntimeCancellationPropagation, 'none'>;
    requestedAt: string;
    deadlineAt?: string;
    fencingToken: number;
    idempotencyKey: string;
}

Contract members

MemberKindSignatureDescription
childRunIdpropertychildRunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
deadlineAtpropertydeadlineAt?: stringPublic 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.
idempotencyKeypropertyidempotencyKey: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
parentScopepropertyparentScope: RuntimeScopePublic property; its type, readonly modifier and optionality are shown in the signature.
propagationpropertypropagation: "children" | "all_descendants"Public property; its type, readonly modifier and optionality are shown in the signature.
reasonpropertyreason: 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.

RuntimeChildRunListRequest

Runtime Child Run List Request interface with 2 public fields or methods.

Declaration

text
export interface RuntimeChildRunListRequest {
    scope: RuntimeScope;
    requestedAt: string;
}

Contract members

MemberKindSignatureDescription
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.

RuntimeChildRunReference

Runtime Child Run Reference interface with 1 public fields or methods.

Declaration

text
export interface RuntimeChildRunReference {
    runId: string;
}

Contract members

MemberKindSignatureDescription
runIdpropertyrunId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

RuntimeCancellationDisposition

Public type alias for Runtime Cancellation Disposition; the declaration contains its complete type expression.

Declaration

text
export type RuntimeCancellationDisposition = (typeof RUNTIME_CANCELLATION_DISPOSITIONS)[number];

RuntimeCancellationPropagation

Public type alias for Runtime Cancellation Propagation; the declaration contains its complete type expression.

Declaration

text
export type RuntimeCancellationPropagation = (typeof RUNTIME_CANCELLATION_PROPAGATIONS)[number];

RuntimeCancellationTargetStatus

Public type alias for Runtime Cancellation Target Status; the declaration contains its complete type expression.

Declaration

text
export type RuntimeCancellationTargetStatus = (typeof RUNTIME_CANCELLATION_TARGET_STATUSES)[number];

RuntimeCancellationTargetType

Public type alias for Runtime Cancellation Target Type; the declaration contains its complete type expression.

Declaration

text
export type RuntimeCancellationTargetType = (typeof RUNTIME_CANCELLATION_TARGET_TYPES)[number];