Skip to content

@codesoul-co/hypha-core / contracts/execution-store

Using this module

Use the Execution store module for declaring and runtime-validating contracts. It exports 14 interfaces, 2 types.

Import from the package entrypoint

ts
import type {
  ExecutionIdempotencyQuery,
  ExecutionLease,
  ExecutionLeaseAcquireRequest,
  ExecutionLeaseGuard,
  ExecutionLeaseReleaseRequest,
  ExecutionLeaseRenewRequest,
  ExecutionRecord,
  ExecutionRecordCompareAndSetRequest,
} from '@codesoul-co/hypha-core';

// The complete export list is documented below.

Usage patterns

  • Use the 16 type/interface exports as static contracts in application code, adapters, or tests. Import them with import type; they do not exist at runtime.

Public exports

SymbolKindSignatureDescription
ExecutionIdempotencyQueryinterfaceinterface ExecutionIdempotencyQueryExecution Idempotency Query interface with 5 public fields or methods.
ExecutionLeaseinterfaceinterface ExecutionLeaseExecution Lease interface with 7 public fields or methods.
ExecutionLeaseAcquireRequestinterfaceinterface ExecutionLeaseAcquireRequestExecution Lease Acquire Request interface with 8 public fields or methods.
ExecutionLeaseGuardinterfaceinterface ExecutionLeaseGuardExecution Lease Guard interface with 3 public fields or methods.
ExecutionLeaseReleaseRequestinterfaceinterface ExecutionLeaseReleaseRequestExecution Lease Release Request interface with 7 public fields or methods.
ExecutionLeaseRenewRequestinterfaceinterface ExecutionLeaseRenewRequestExecution Lease Renew Request interface with 7 public fields or methods.
ExecutionRecordinterfaceinterface ExecutionRecordExecution Record interface with 14 public fields or methods.
ExecutionRecordCompareAndSetRequestinterfaceinterface ExecutionRecordCompareAndSetRequestExecution Record Compare And Set Request interface with 6 public fields or methods.
ExecutionRecordCreateRequestinterfaceinterface ExecutionRecordCreateRequestExecution Record Create Request interface with 3 public fields or methods.
ExecutionRecordPageinterfaceinterface ExecutionRecordPageExecution Record Page interface with 2 public fields or methods.
ExecutionRecordQueryinterfaceinterface ExecutionRecordQueryExecution Record Query interface with 10 public fields or methods.
ExecutionRecoveryAssessmentinterfaceinterface ExecutionRecoveryAssessmentExecution Recovery Assessment interface with 6 public fields or methods.
ExecutionStoreinterfaceinterface ExecutionStoreExecution Store interface with 10 public fields or methods.
ExecutionStoreFactoryinterfaceinterface ExecutionStoreFactoryExecution Store Factory interface with 2 public fields or methods.
ExecutionIdempotencyResolutiontypetype ExecutionIdempotencyResolution = { status: 'miss'; } | { status: 'match'; record: ExecutionRecord; } | { status: 'conflict'; recordId: string; existingFingerprint: string; }Public type alias for Execution Idempotency Resolution; the declaration contains its complete type expression.
ExecutionRecoveryDispositiontypetype ExecutionRecoveryDisposition = 'not_started' | 'provider_queryable' | 'provider_completed_result_missing' | 'provider_state_unknown'Public type alias for Execution Recovery Disposition; the declaration contains its complete type expression.

ExecutionIdempotencyQuery

Execution Idempotency Query interface with 5 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionIdempotencyQuery } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionIdempotencyQuery {
    tenantId?: string;
    userId: string;
    workspaceId: string;
    idempotencyKey: string;
    fingerprint: string;
}

Contract members

MemberKindSignatureDescription
fingerprintpropertyfingerprint: 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.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
workspaceIdpropertyworkspaceId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionLease

Execution Lease interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionLease } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionLease {
    id: string;
    executionId: string;
    ownerId: string;
    fencingToken: number;
    acquiredAt: string;
    expiresAt: string;
    heartbeatAt: string;
}

Contract members

MemberKindSignatureDescription
acquiredAtpropertyacquiredAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expiresAtpropertyexpiresAt: 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.
heartbeatAtpropertyheartbeatAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic 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.

ExecutionLeaseAcquireRequest

Execution Lease Acquire Request interface with 8 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionLeaseAcquireRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionLeaseAcquireRequest {
    operationId: string;
    executionId: string;
    expectedRevision: number;
    requestedLeaseId: string;
    ownerId: string;
    ttlMs: number;
    acquiredAt: string;
    idempotencyKey?: string;
}

Contract members

MemberKindSignatureDescription
acquiredAtpropertyacquiredAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedRevisionpropertyexpectedRevision: 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.
operationIdpropertyoperationId: stringPublic 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.
requestedLeaseIdpropertyrequestedLeaseId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
ttlMspropertyttlMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionLeaseGuard

Execution Lease Guard interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionLeaseGuard } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionLeaseGuard {
    leaseId: string;
    ownerId: string;
    fencingToken: number;
}

Contract members

MemberKindSignatureDescription
fencingTokenpropertyfencingToken: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseIdpropertyleaseId: stringPublic 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.

ExecutionLeaseReleaseRequest

Execution Lease Release Request interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionLeaseReleaseRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionLeaseReleaseRequest {
    operationId: string;
    executionId: string;
    expectedRevision: number;
    leaseGuard: ExecutionLeaseGuard;
    releasedAt: string;
    reason?: string;
    idempotencyKey?: string;
}

Contract members

MemberKindSignatureDescription
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedRevisionpropertyexpectedRevision: 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.
leaseGuardpropertyleaseGuard: ExecutionLeaseGuardPublic property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: 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.
releasedAtpropertyreleasedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionLeaseRenewRequest

Execution Lease Renew Request interface with 7 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionLeaseRenewRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionLeaseRenewRequest {
    operationId: string;
    executionId: string;
    expectedRevision: number;
    leaseGuard: ExecutionLeaseGuard;
    ttlMs: number;
    heartbeatAt: string;
    idempotencyKey?: string;
}

Contract members

MemberKindSignatureDescription
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedRevisionpropertyexpectedRevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
heartbeatAtpropertyheartbeatAt: 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.
leaseGuardpropertyleaseGuard: ExecutionLeaseGuardPublic property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
ttlMspropertyttlMs: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionRecord

Execution Record interface with 14 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionRecord } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionRecord {
    id: string;
    revision: number;
    request: CommandExecutionRequest;
    status: CommandExecutionStatus;
    providerId: string;
    providerExecutionRef?: string;
    sandboxId?: string;
    attempt: number;
    idempotencyFingerprint?: string;
    /**
     * Immutable Provider terminal evidence persisted before Artifact finalization and terminal CAS.
     * Once present, Store implementations must reject removal or replacement.
     */
    terminalReceipt?: ExecutionReceipt;
    result?: CommandExecutionResult;
    lease?: ExecutionLease;
    createdAt: string;
    updatedAt: string;
}

Contract members

MemberKindSignatureDescription
attemptpropertyattempt: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
createdAtpropertycreatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idpropertyid: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
idempotencyFingerprintpropertyidempotencyFingerprint?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
leasepropertylease?: ExecutionLeasePublic property; its type, readonly modifier and optionality are shown in the signature.
providerExecutionRefpropertyproviderExecutionRef?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
requestpropertyrequest: CommandExecutionRequestPublic property; its type, readonly modifier and optionality are shown in the signature.
resultpropertyresult?: CommandExecutionResultPublic property; its type, readonly modifier and optionality are shown in the signature.
revisionpropertyrevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
sandboxIdpropertysandboxId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statuspropertystatus: CommandExecutionStatusPublic property; its type, readonly modifier and optionality are shown in the signature.
terminalReceiptpropertyterminalReceipt?: ExecutionReceiptImmutable Provider terminal evidence persisted before Artifact finalization and terminal CAS. Once present, Store implementations must reject removal or replacement.
updatedAtpropertyupdatedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionRecordCompareAndSetRequest

Execution Record Compare And Set Request interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionRecordCompareAndSetRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionRecordCompareAndSetRequest {
    operationId: string;
    executionId: string;
    expectedRevision: number;
    leaseGuard?: ExecutionLeaseGuard;
    next: ExecutionRecord;
    idempotencyKey?: string;
}

Contract members

MemberKindSignatureDescription
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
expectedRevisionpropertyexpectedRevision: 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.
leaseGuardpropertyleaseGuard?: ExecutionLeaseGuardPublic property; its type, readonly modifier and optionality are shown in the signature.
nextpropertynext: ExecutionRecordPublic property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionRecordCreateRequest

Execution Record Create Request interface with 3 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionRecordCreateRequest } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionRecordCreateRequest {
    operationId: string;
    record: ExecutionRecord;
    idempotencyKey?: string;
}

Contract members

MemberKindSignatureDescription
idempotencyKeypropertyidempotencyKey?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
operationIdpropertyoperationId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
recordpropertyrecord: ExecutionRecordPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionRecordPage

Execution Record Page interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionRecordPage } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionRecordPage {
    records: ExecutionRecord[];
    cursor?: string;
}

Contract members

MemberKindSignatureDescription
cursorpropertycursor?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
recordspropertyrecords: ExecutionRecord[]Public property; its type, readonly modifier and optionality are shown in the signature.

ExecutionRecordQuery

Execution Record Query interface with 10 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionRecordQuery } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionRecordQuery {
    tenantId?: string;
    userId?: string;
    workspaceId?: string;
    runId?: string;
    providerId?: string;
    statuses?: CommandExecutionStatus[];
    leaseExpiresBefore?: string;
    updatedBefore?: string;
    limit?: number;
    cursor?: string;
}

Contract members

MemberKindSignatureDescription
cursorpropertycursor?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
leaseExpiresBeforepropertyleaseExpiresBefore?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
limitpropertylimit?: numberPublic property; its type, readonly modifier and optionality are shown in the signature.
providerIdpropertyproviderId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
runIdpropertyrunId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
statusespropertystatuses?: CommandExecutionStatus[]Public property; its type, readonly modifier and optionality are shown in the signature.
tenantIdpropertytenantId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
updatedBeforepropertyupdatedBefore?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
userIdpropertyuserId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
workspaceIdpropertyworkspaceId?: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionRecoveryAssessment

Execution Recovery Assessment interface with 6 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionRecoveryAssessment } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionRecoveryAssessment {
    executionId: string;
    recordRevision: number;
    disposition: ExecutionRecoveryDisposition;
    assessedAt: string;
    providerStatusRef?: string;
    reason?: string;
}

Contract members

MemberKindSignatureDescription
assessedAtpropertyassessedAt: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
dispositionpropertydisposition: ExecutionRecoveryDispositionPublic property; its type, readonly modifier and optionality are shown in the signature.
executionIdpropertyexecutionId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.
providerStatusRefpropertyproviderStatusRef?: 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.
recordRevisionpropertyrecordRevision: numberPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionStore

Execution Store interface with 10 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionStore } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionStore {
    create(request: ExecutionRecordCreateRequest): Promise<ExecutionRecord>;
    get(executionId: string): Promise<ExecutionRecord | null>;
    list(query?: ExecutionRecordQuery): Promise<ExecutionRecordPage>;
    resolveIdempotency(query: ExecutionIdempotencyQuery): Promise<ExecutionIdempotencyResolution>;
    compareAndSet(request: ExecutionRecordCompareAndSetRequest): Promise<ExecutionRecord>;
    acquireLease(request: ExecutionLeaseAcquireRequest): Promise<ExecutionRecord>;
    renewLease(request: ExecutionLeaseRenewRequest): Promise<ExecutionRecord>;
    releaseLease(request: ExecutionLeaseReleaseRequest): Promise<ExecutionRecord>;
    health(): Promise<ProviderHealth>;
    close?(): Promise<void>;
}

Contract members

MemberKindSignatureDescription
acquireLeasemethodacquireLease(request: ExecutionLeaseAcquireRequest): Promise<ExecutionRecord>Public method; parameters and return type are shown in the signature.
closemethodclose?(): Promise<void>Public method; parameters and return type are shown in the signature.
compareAndSetmethodcompareAndSet(request: ExecutionRecordCompareAndSetRequest): Promise<ExecutionRecord>Public method; parameters and return type are shown in the signature.
createmethodcreate(request: ExecutionRecordCreateRequest): Promise<ExecutionRecord>Public method; parameters and return type are shown in the signature.
getmethodget(executionId: string): Promise<ExecutionRecord | null>Public method; parameters and return type are shown in the signature.
healthmethodhealth(): Promise<ProviderHealth>Public method; parameters and return type are shown in the signature.
listmethodlist(query?: ExecutionRecordQuery): Promise<ExecutionRecordPage>Public method; parameters and return type are shown in the signature.
releaseLeasemethodreleaseLease(request: ExecutionLeaseReleaseRequest): Promise<ExecutionRecord>Public method; parameters and return type are shown in the signature.
renewLeasemethodrenewLease(request: ExecutionLeaseRenewRequest): Promise<ExecutionRecord>Public method; parameters and return type are shown in the signature.
resolveIdempotencymethodresolveIdempotency(query: ExecutionIdempotencyQuery): Promise<ExecutionIdempotencyResolution>Public method; parameters and return type are shown in the signature.

ExecutionStoreFactory

Execution Store Factory interface with 2 public fields or methods.

  • Kind: interface
  • Import: import type { ExecutionStoreFactory } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export interface ExecutionStoreFactory {
    readonly storeId: string;
    create(): Promise<ExecutionStore>;
}

Contract members

MemberKindSignatureDescription
createmethodcreate(): Promise<ExecutionStore>Public method; parameters and return type are shown in the signature.
storeIdpropertyreadonly storeId: stringPublic property; its type, readonly modifier and optionality are shown in the signature.

ExecutionIdempotencyResolution

Public type alias for Execution Idempotency Resolution; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ExecutionIdempotencyResolution } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export type ExecutionIdempotencyResolution = {
    status: 'miss';
} | {
    status: 'match';
    record: ExecutionRecord;
} | {
    status: 'conflict';
    recordId: string;
    existingFingerprint: string;
};

ExecutionRecoveryDisposition

Public type alias for Execution Recovery Disposition; the declaration contains its complete type expression.

  • Kind: type
  • Import: import type { ExecutionRecoveryDisposition } from '@codesoul-co/hypha-core';
  • Source module: contracts/execution-store

Declaration

text
export type ExecutionRecoveryDisposition = 'not_started' | 'provider_queryable' | 'provider_completed_result_missing' | 'provider_state_unknown';