/**
 * WorkflowRuntimePort — durable workflow execution port (S3 spec).
 *
 * Defines: 9-state machine, journal invariants I-S3-1..8, replay determinism,
 * ctx.* primitives, lease takeover pattern, handler versioning.
 *
 * Default adapter: DBOSWorkflowAdapter (DBOS-TS Apache 2.0, Postgres-native).
 * Swap-able to Temporal/Restate via this port + test contract T-S3-1..12.
 */
// ─── Typed errors ─────────────────────────────────────────────────────────────
export class WorkflowNotFoundError extends Error {
    runId;
    constructor(runId) {
        super(`Workflow run not found: ${runId}`);
        this.runId = runId;
        this.name = "WorkflowNotFoundError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class WorkflowNonDeterminismError extends Error {
    runId;
    stepIndex;
    expected;
    actual;
    constructor(runId, stepIndex, expected, actual) {
        super(`Non-determinism at step ${stepIndex}: expected ${expected}, got ${actual} (run=${runId})`);
        this.runId = runId;
        this.stepIndex = stepIndex;
        this.expected = expected;
        this.actual = actual;
        this.name = "WorkflowNonDeterminismError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class WorkflowSignalTimeoutError extends Error {
    runId;
    signalName;
    timeoutMs;
    constructor(runId, signalName, timeoutMs) {
        super(`Signal '${signalName}' timeout after ${timeoutMs}ms (run=${runId})`);
        this.runId = runId;
        this.signalName = signalName;
        this.timeoutMs = timeoutMs;
        this.name = "WorkflowSignalTimeoutError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class WorkflowLeaseConflictError extends Error {
    runId;
    currentOwner;
    constructor(runId, currentOwner) {
        super(`Cannot acquire lease for run ${runId}: held by ${currentOwner}`);
        this.runId = runId;
        this.currentOwner = currentOwner;
        this.name = "WorkflowLeaseConflictError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
export class WorkflowVersionMismatchError extends Error {
    runId;
    expected;
    actual;
    constructor(runId, expected, actual) {
        super(`Version mismatch for run ${runId}: expected ${expected}, got ${actual}`);
        this.runId = runId;
        this.expected = expected;
        this.actual = actual;
        this.name = "WorkflowVersionMismatchError";
        Object.setPrototypeOf(this, new.target.prototype);
    }
}
//# sourceMappingURL=workflow-runtime.js.map