# `ConduitMcp.Tasks.Janitor`
[🔗](https://github.com/nyo16/conduit_mcp/blob/v0.10.1/lib/conduit_mcp/tasks/janitor.ex#L1)

Periodically prunes terminal-state tasks from `ConduitMcp.Tasks`.

`ConduitMcp.Tasks` stores task state in a named ETS table (`:conduit_mcp_tasks`)
that has no eviction loop of its own — tasks that reach `completed`, `failed`,
or `cancelled` linger in memory until the BEAM restarts. The janitor wakes on
an interval and calls `ConduitMcp.Tasks.cleanup/1` to drop terminal-state
entries older than the configured TTL.

Tasks still in `working` or `input_required` are never evicted by the janitor
regardless of age — long-running tasks remain available.

## Usage

    children = [
      {ConduitMcp.Tasks.Janitor,
       ttl: :timer.hours(1),
       interval: :timer.minutes(5)}
    ]

## Options

- `:ttl` — maximum age in milliseconds for terminal-state tasks
  (default: 1 hour).
- `:interval` — interval between cleanup runs in milliseconds
  (default: 5 minutes).
- `:name` — registered process name (default: module name).

Emits `[:conduit_mcp, :tasks, :cleanup]` telemetry on each run with
measurements `%{removed: count}`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `start_link`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
