Member Junction
    Preparing search index...

    Implemented by long-lived singletons (engines, services) that own background work — timers, intervals, subscriptions, sockets, child processes — so a coordinated shutdown can release them. Without this contract, SIGTERM/SIGINT handlers in the entry point have no way to reach into singleton state to clear timers, leaving the process unable to exit cleanly under load tests, CI runs, or graceful drains.

    Implementers register themselves with ShutdownRegistry.Instance.Register(this) (typically in their constructor) and provide a Shutdown() that releases the resource synchronously or returns a promise. The registry calls each implementer exactly once per ShutdownAll() invocation.

    Implements

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    ShutdownName: "TaskGraphDispatcher" = 'TaskGraphDispatcher'

    Name shown in the shutdown drain log.

    Methods

    • Reclaims expired claims and reports anomalies.

      Also enforces the two schema promises that previously had no enforcer anywhere: agent tasks left In Progress with no claim are surfaced loudly rather than silently corrected, since that shape indicates tampering or a bug and Record Changes already carries the audit trail.

      Returns Promise<void>

    • Begins dispatching.

      Runs reconciliation FIRST, before accepting any new work. On a restart this instance may be looking at tasks its own previous incarnation claimed and never released — reclaiming those up front is what turns a crash from "work stranded forever" into "work resumes".

      Returns Promise<void>

    • Stops accepting new work and waits for everything already started to finish.

      "Everything" includes the timer passes, and that is the fix. This waited only on inFlight — the task executions — while a poll pass is a void-ed promise nothing held. So Stop() returned while a pass was mid-flight, and that pass went on to settle graphs, emit lifecycle frames and CLAIM NEW TASKS afterwards. Three consequences, all of them quiet:

      • a GraphSettled frame arrived after every subscriber had gone, so the settlement was invisible to exactly the viewer watching for it;
      • a process shutting down claimed work it was about to abandon, leaving claims to expire — the orphaned-claim state reconciliation exists to clean up, manufactured by the shutdown;
      • the host reused the connection the moment Stop() resolved, and the still-running pass's statements collided with it (Requests can only be made in the LoggedIn state).

      A pass is bookkeeping for work that already happened, so it is DRAINED rather than cancelled: abandoning one halfway is the crash window the unsettled sweep exists to rescue, and choosing to open it on every clean shutdown would be perverse.

      Deliberately does NOT release claims on the way out: an abandoned claim expires on its own, and releasing eagerly would hand a still-running task to another instance mid-execution. Letting the TTL do it is the safer failure mode.

      Returns Promise<void>