Interface IEntitlementHook

The product's billing. The library reserves before a run exists (reserve), or for a run written pending (reserveOnce), meters every minute, settles at the end, releases an unbilled run. settle and release are idempotent per reservation: the manager retries them until they resolve, and a repeated call after a success changes nothing.

checkRun, recover and finalize are an optional lifecycle extension for hosts opting into persisted funding.

interface IEntitlementHook {
    forget?(runId): Promise<void>;
    reserve(input): Promise<ReserveResult>;
    reserveOnce?(input): Promise<ReserveResult>;
    revalidate(reservationId): Promise<boolean>;
    revalidateAllowance?(reservationId): Promise<DispatchAllowance>;
    meter(reservationId, seconds): Promise<void>;
    settle(reservationId, billedSeconds): Promise<void>;
    release(reservationId): Promise<void>;
    recordSupplierUsage?(reservationId, usage): Promise<void>;
    checkRun?(runId, phase): Promise<DispatchAllowance>;
    recover?(runId): Promise<void>;
    finalize?(reference, decision): Promise<void>;
}

Hierarchy (view full)

Implemented by

Methods

  • Optional whole-run eviction for in-memory hosts after terminal cleanup and the retention grace. Durable stores omit it to retain their records. Call only after producers have stopped; forgetting removes fences too.

    Parameters

    • runId: string

    Returns Promise<void>

  • Optional; MeetingManager.sendBotPrepared requires it. Reserves at most maxSeconds for a run already written pending, idempotently by its run id: it must return the same committed reservation for a run id even after the caller loses its response, so a creation an interruption cut short and finished later holds one reservation.

    Parameters

    • input: {
          ownerRef: string;
          runId: string;
          platform: MeetingPlatform;
          maxSeconds: number;
      }

    Returns Promise<ReserveResult>

  • A scheduled run, at dispatch: still paid, still has the hours. Not asked when the hook has revalidateAllowance.

    Parameters

    • reservationId: string

    Returns Promise<boolean>

  • Optional. The grant at dispatch, asked before a worker is sent for a run that holds a reservation: a run sent now, a scheduled one, and one whose dispatch is tried again after its bot was found not running. The manager cuts the run's limits.totalMs to the answer's maxSeconds and writes it on the run before the provider sees the run; a refusal, or a grant under the manager's minReservationSeconds, ends the run allowance before any dispatch. When present, revalidate is not asked.

    Parameters

    • reservationId: string

    Returns Promise<DispatchAllowance>

  • The seconds the run has used so far, every minute: a running total, not an increment.

    Parameters

    • reservationId: string
    • seconds: number

    Returns Promise<void>

  • Settles the run at the seconds it is billed.

    Parameters

    • reservationId: string
    • billedSeconds: number

    Returns Promise<void>

  • Frees a reservation nothing is billed against: a run that ends unbilled, or a send refused after its reservation.

    Parameters

    • reservationId: string

    Returns Promise<void>

  • Optional. Records what the run's supplier measured (SupplierUsage), apart from the seconds the owner is billed: the cost the run incurred, settled whatever the owner's bill, an unbilled end included. The manager calls it for every report that carries totals, before its terminal and fence checks, and for the totals a provider's usage answers at reconciliation, so it may be called again with the same or older totals: keep the largest of each. A rejection holds back no run (the report that carried the totals is applied, and a run whose worker is gone still ends): the manager keeps the totals in its stores' supplierUsageInbox, when it has one, and calls again with them at the next reconcile. Absent, nothing is recorded, and meter, settle and release behave as they do without it.

    Parameters

    Returns Promise<void>

  • Resumes a durable terminal settlement intent; never derives a new source from current plans.

    Parameters

    • runId: string

    Returns Promise<void>

  • Optional authoritative finalization; billing policy is distinct from measured duration.

    Parameters

    • reference: string
    • decision: {
          unbilled: boolean;
      }
      • unbilled: boolean

    Returns Promise<void>