Skip to content
TotalFinance

Workflows · @insiderfinance/totalfinance

@insiderfinance/totalfinance/workflows

import { … } from '@insiderfinance/totalfinance/workflows'
preview (pre-1.0)iface 22const 10type 6fn 50JSON ↗

Functions · 50

Values & facades · 10

Interfaces · 22

Types · 6

iface

ArtifactStore

#

A writable store: put is idempotent by content (the same value yields the same handle).

Signature
import type { ArtifactStore } from '@insiderfinance/totalfinance/workflows';

/** A writable store: `put` is idempotent by content (the same value yields the same handle). */
export interface ArtifactStore extends ArtifactStoreReader {
    put(input: ArtifactStorePutInput): ResourceHandle;
}
Fields, parameters and returned members (22)

Loading 22 members…

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

ArtifactStorePutInput

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { ArtifactStorePutInput } from '@insiderfinance/totalfinance/workflows';

// ── artifact stores ───────────────────────────────────────────────────────────────────────────
export interface ArtifactStorePutInput {
    /** The stored data — an envelope or an operation's structured result; JSON-safe by construction. */
    value: Record<string, unknown>;
    kind: Exclude<ResourceHandleKind, 'job'>;
    /** Epoch ms — the caller's clock, never read by the library. */
    createdTimestampMs: EpochMs;
    /** Epoch ms; must be after `createdTimestampMs`. */
    expiresTimestampMs?: EpochMs;
    provenance?: Provenance;
}
Fields, parameters and returned members (12)
Name · typeMeaning · unitRequired · default
createdTimestampMsnumber

Epoch ms — the caller's clock, never read by the library.

epoch milliseconds (UTC instant)
RequiredNo @default declared
expiresTimestampMsnumber

Epoch ms; must be after createdTimestampMs.

epoch milliseconds (UTC instant)
OptionalNo @default declared
kind'market' | 'portfolio' | 'report' | 'scenario' | 'authorization' | 'journal'—unitless by nameRequiredNo @default declared
provenanceProvenance—unitless by nameOptionalNo @default declared
provenance.asOfnumber—an instant: epoch milliseconds or a YYYY-MM-DD / zoned ISO string (the resolveAsOf convention)OptionalNo @default declared
provenance.datasetstring—unitless by nameOptionalNo @default declared
provenance.providerstring—unitless by nameOptionalNo @default declared
provenance.receivedAtnumber—unitless by nameOptionalNo @default declared
provenance.requestIdstring—unitless by nameOptionalNo @default declared
provenance.sourceVersionstring—unitless by nameOptionalNo @default declared
provenance.warningsimport('@insiderfinance/totalfinance/core').QuantWarning[]—unitless by nameOptionalNo @default declared
valueRecord<string, unknown>

The stored data — an envelope or an operation's structured result; JSON-safe by construction.

unitless by name
RequiredNo @default declared

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

ArtifactStoreReader

#

Read access to the handles an input may reference (Decision 5); null when no store was supplied.

Signature
import type { ArtifactStoreReader } from '@insiderfinance/totalfinance/workflows';

/** Read access to the handles an input may reference (Decision 5); `null` when no store was supplied. */
export interface ArtifactStoreReader {
    get(uri: string): {
        handle: ResourceHandle;
        value: Record<string, unknown>;
    } | null;
    list(filter?: {
        kind?: ResourceHandleKind;
    }): ResourceHandle[];
}
Fields, parameters and returned members (7)
Name · typeMeaning · unitRequired · default
get(uri: string) => { handle: ResourceHandle; value: Record<string, unknown>; } | null—unitless by nameRequiredNo @default declared
get().return.handleResourceHandle—unitless by nameRequiredNo @default declared
get().return.valueRecord<string, unknown>—unitless by nameRequiredNo @default declared
get(uri)string—unitless by nameRequiredNo @default declared
list(filter?: { kind?: ResourceHandleKind; }) => ResourceHandle[]—unitless by nameRequiredNo @default declared
list(filter){ kind?: ResourceHandleKind; } | undefined—unitless by nameOptionalNo @default declared
list(filter).kindResourceHandleKind—unitless by nameOptionalNo @default declared

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

AuthorizationStore

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { AuthorizationStore } from '@insiderfinance/totalfinance/workflows';

export interface AuthorizationStore {
    /** Store a grant under its content hash; idempotent (the first put stands). Returns its handle. */
    put(input: {
        grant: AuthorizationGrant;
        createdTimestampMs: EpochMs;
    }): ResourceHandle;
    /** The grant by content hash (or handle uri) with its consumption (null while unconsumed), or null. */
    get(hashOrUri: string): {
        handle: ResourceHandle;
        grant: AuthorizationGrant;
        consumed: GrantConsumption | null;
    } | null;
    /**
     * Atomically claim the grant with its validated write-ahead batch before journal commit.
     * Idempotent only for the same store, receipt, key and batch; all other claims refuse.
     */
    consume(input: GrantConsumption & {
        hashOrUri: string;
    }): GrantConsumption;
    list(): ResourceHandle[];
}
Fields, parameters and returned members (39)

Loading 39 members…

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

DEFAULT_CAPABILITIES

#

What a caller holds when it names nothing: read, analyze, propose.

Signature
import { DEFAULT_CAPABILITIES } from '@insiderfinance/totalfinance/workflows';

export declare const DEFAULT_CAPABILITIES: readonly string[];

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

EXECUTION_JOURNAL_STORE_CEILING

#

A journal read folds at most this many events; the store refuses to grow a journal beyond it.

Signature
import { EXECUTION_JOURNAL_STORE_CEILING } from '@insiderfinance/totalfinance/workflows';

export declare const EXECUTION_JOURNAL_STORE_CEILING: 100000;

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

ExecutionJournalStore

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { ExecutionJournalStore } from '@insiderfinance/totalfinance/workflows';

export interface ExecutionJournalStore {
    /** Stable opaque storage identity. Fresh stores differ; reopening a file store retains it. */
    readonly storeId: string;
    /**
     * Serialize restoration, idempotency checks, identity allocation and commit for one journal.
     * `execute` is synchronous and receives a detached snapshot. Its events are a newly appended
     * batch (possibly empty), committed before result is returned. Exceptions commit nothing.
     * Do not nest transactions/append on the same journal; read does not acquire another lock.
     */
    transact<T>(input: {
        journalId: string;
        execute: (prior: readonly ExecutionJournalEvent[]) => {
            events: readonly ExecutionJournalEvent[];
            result: T;
        };
    }): T;
    /** Append atomically; identical eventId/body retries are skipped, conflicting bodies refused. */
    append(input: {
        events: readonly ExecutionJournalEvent[];
    }): {
        journalId: string;
        appended: number;
        skipped: number;
        total: number;
    };
    /** Every event of a journal in append order (empty for an unknown journal). */
    read(journalId: string): ExecutionJournalEvent[];
    /** Every journal id, sorted. */
    list(): string[];
}
Fields, parameters and returned members (15)

Loading 15 members…

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

GrantConsumption

#

The one submission a grant licensed, durably prepared before its journal commit.

Signature
import type { GrantConsumption } from '@insiderfinance/totalfinance/workflows';

/** The one submission a grant licensed, durably prepared before its journal commit. */
export interface GrantConsumption {
    /** Opaque identity of the authoritative store, retained across file-store restarts. */
    journalStoreId: string;
    journalId: string;
    receiptId: string;
    idempotencyKey: string;
    consumedTimestampMs: EpochMs;
    /** Write-ahead event batch: recovery replays these exact facts, never the fill engine. */
    journalEvents: readonly ExecutionJournalEvent[];
}
Fields, parameters and returned members (6)
Name · typeMeaning · unitRequired · default
consumedTimestampMsnumber—epoch milliseconds (UTC instant)RequiredNo @default declared
idempotencyKeystring—unitless by nameRequiredNo @default declared
journalEventsreadonly ExecutionJournalEvent[]

Write-ahead event batch: recovery replays these exact facts, never the fill engine.

unitless by name
RequiredNo @default declared
journalIdstring—unitless by nameRequiredNo @default declared
journalStoreIdstring

Opaque identity of the authoritative store, retained across file-store restarts.

unitless by name
RequiredNo @default declared
receiptIdstring—unitless by nameRequiredNo @default declared

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

HANDLE_KINDS

#

The handle kinds, their uri namespaces, and the envelope kind a stored value of that kind carries.

Signature
import { HANDLE_KINDS } from '@insiderfinance/totalfinance/workflows';

export declare const HANDLE_KINDS: Readonly<{ readonly report: Readonly<{ namespace: 'reports'; envelopeKind: null; }>; readonly job: Readonly<{ namespace: 'jobs'; envelopeKind: null; }>; readonly portfolio: Readonly<{ namespace: 'portfolios'; envelopeKind: 'totalfinance.portfolio-ledger'; }>; readonly scenario: Readonly<{ namespace: 'scenarios'; envelopeKind: 'totalfinance.scenario-set'; }>; readonly market: Readonly<{ namespace: 'markets'; envelopeKind: 'totalfinance.market-snapshot'; }>; readonly authorization: Readonly<{ namespace: 'authorizations'; envelopeKind: 'totalfinance.authorization-grant'; }>; readonly journal: Readonly<{ namespace: 'journals'; envelopeKind: null; }>; }>;
Fields, parameters and returned members (21)

Loading 21 members…

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

JOB_STATES

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import { JOB_STATES } from '@insiderfinance/totalfinance/workflows';

export declare const JOB_STATES: readonly JobState[];

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

JobRecord

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { JobRecord } from '@insiderfinance/totalfinance/workflows';

export interface JobRecord {
    id: string;
    operation: {
        id: string;
        version: string;
    };
    state: JobState;
    progress: {
        stage: string;
        fraction: number | null;
    } | null;
    inputsHash: string;
    seed: number | null;
    submittedAt: string;
    startedAt: string | null;
    finishedAt: string | null;
    result: ResourceHandle | null;
    error: OperationError | null;
    usage: {
        elapsedMs: number | null;
    };
}
Fields, parameters and returned members (39)

Loading 39 members…

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

JobState

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { JobState } from '@insiderfinance/totalfinance/workflows';

// ── job stores ────────────────────────────────────────────────────────────────────────────────
export type JobState = 'accepted' | 'queued' | 'running' | 'completed' | 'failed' | 'cancelled';

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

JobStore

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { JobStore } from '@insiderfinance/totalfinance/workflows';

export interface JobStore {
    create(record: JobRecord): JobRecord;
    update(id: string, patch: Partial<Omit<JobRecord, 'id'>>): JobRecord;
    get(id: string): JobRecord | null;
    list(): JobRecord[];
}
Fields, parameters and returned members (167)

Loading 167 members…

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

KNOWN_CAPABILITIES

#

The capabilities this stage names; a runtime may grant others (the registry does not enumerate them).

Signature
import { KNOWN_CAPABILITIES } from '@insiderfinance/totalfinance/workflows';

export declare const KNOWN_CAPABILITIES: readonly string[];

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

MAX_ROWS

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import { MAX_ROWS } from '@insiderfinance/totalfinance/workflows';

export declare const MAX_ROWS: 5000;

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

OPERATION_BUDGETS

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import { OPERATION_BUDGETS } from '@insiderfinance/totalfinance/workflows';

export declare const OPERATION_BUDGETS: Readonly<{ maxInputBytes: Readonly<{ transportDefault: 65536; maximum: 16777216; }>; inlineResultBytes: Readonly<{ default: 262144; maximum: 16777216; }>; }>;
Fields, parameters and returned members (6)
Name · typeMeaning · unitRequired · default
inlineResultBytesReadonly<{ default: 262144; maximum: 16777216; }>

Canonical bytes of a structured result above which, when a WRITABLE artifact store is supplied, the result is stored and the response carries its handle with a bounded preview — never a silent truncation (Decision 5).

unitless by name
RequiredNo @default declared
inlineResultBytes.default262144—unitless by nameRequiredNo @default declared
inlineResultBytes.maximum16777216—unitless by nameRequiredNo @default declared
maxInputBytesReadonly<{ transportDefault: 65536; maximum: 16777216; }>

Serialized input bytes a call may carry (UTF-8, measured on the raw request). A WIRE budget: a transport always passes one (the MCP server's default is 64 KiB); an in-process run that omits it is bounded by the operation's own row caps instead.

unitless by name
RequiredNo @default declared
maxInputBytes.maximum16777216—unitless by nameRequiredNo @default declared
maxInputBytes.transportDefault65536—unitless by nameRequiredNo @default declared

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

const

OPERATION_ID

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import { OPERATION_ID } from '@insiderfinance/totalfinance/workflows';

export declare const OPERATION_ID: RegExp;

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

OperationAnnotations

#

What a transport advertises about an operation's behaviour — DERIVED from its effect metadata, never authored.

Signature
import type { OperationAnnotations } from '@insiderfinance/totalfinance/workflows';

/** What a transport advertises about an operation's behaviour — DERIVED from its effect metadata, never authored. */
export interface OperationAnnotations {
    readOnlyHint: boolean;
    destructiveHint: boolean;
    idempotentHint: boolean;
    openWorldHint: boolean;
}
Fields, parameters and returned members (4)
Name · typeMeaning · unitRequired · default
destructiveHintboolean—unitless by nameRequiredNo @default declared
idempotentHintboolean—unitless by nameRequiredNo @default declared
openWorldHintboolean—unitless by nameRequiredNo @default declared
readOnlyHintboolean—unitless by nameRequiredNo @default declared

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

type

OperationAuthorization

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { OperationAuthorization } from '@insiderfinance/totalfinance/workflows';

export type OperationAuthorization = 'none' | 'policy' | 'human';

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.

iface

OperationContext

#

Public declaration. Read the signature and member contracts below; no additional behaviour is inferred.

Signature
import type { OperationContext } from '@insiderfinance/totalfinance/workflows';

export interface OperationContext {
    /** The resolved seed for a stochastic call (the seed policy injects the default when absent); `null` for a deterministic call. */
    seed: number | null;
    budgets: {
        maxInputBytes: number | null;
        deadlineMs: number | null;
    };
    /** Cooperative cancellation for job-class operations; `null` for an inline run. */
    signal: OperationSignal | null;
    artifacts: ArtifactStoreReader | null;
    /** What the caller holds (Stage 7B.2 Decision 9); the runtime refused the call already when a required one is missing. */
    capabilities: readonly string[];
    /** The trade lifecycle's stores (Decision 10), explicit parameters of the runtime — never session state. */
    stores: {
        authorization: AuthorizationStore | null;
        journal: ExecutionJournalStore | null;
    };
}
Fields, parameters and returned members (73)

Loading 73 members…

Stability: preview (pre-1.0). Units come from declared names; “unitless by name” means the name alone does not establish a unit. See conventions and errors and warnings.