# Function getLifecycleStatistics

- getLifecycleStatistics(
  options?: {
  corpusSize?: number;
  deadline?: number;
  forceRefresh?: boolean;
  },
  ): Promise<LifecycleStatisticsModel>

  Build (or return cached) lifecycle statistics for the latest N procedures.

  The corpus is cached for CACHE_TTL_MS; subsequent callers within the window receive the same model instance for free. Refreshing is lazy: a stale cache is rebuilt on the next call rather than on a timer, so idle processes pay no background cost. Cache and in-flight builds are keyed by `corpusSize` so distinct sample sizes never share a model.

  #### Parameters

  - options: { corpusSize?: number; deadline?: number; forceRefresh?: boolean } = {}

    Optional overrides

    - ##### `Optional` corpusSize?: number

      Number of procedures to sample (default: CORPUS_SIZE)

    - ##### `Optional` deadline?: number

      Optional wall-clock deadline (epoch ms) for the underlying fetchEventsBounded loop. When set, the rebuild stops queueing additional events fetches once the deadline is reached and builds the model from whatever was gathered (possibly empty). This is how the request path keeps a cold-cache rebuild from starving its own rate-limit budget. Concurrent callers that omit `deadline` still share the same in-flight build, so the budget set by the first caller wins.

    - ##### `Optional` forceRefresh?: boolean

      Ignore cached model and rebuild

  #### Returns Promise<LifecycleStatisticsModel>

  The lifecycle statistics model (possibly partial when `deadline` fires before the full corpus has been fetched)

  #### Security

  The corpus contains only procedure types, event types, and dates — no PII. Bounded concurrency (≤8) prevents API rate-limit exhaustion.

  #### Since

  0.8.0

  - Defined in utils/lifecycleStatistics.ts:391