Skip to main content

DrainMarkerPolicy

Defined in the protocols module.
AI Agent Pure predicate deciding whether an external drain marker is actionable. A drain marker is a small JSON object written by an operator / deploy step (via praisonai gateway drain) into a well-known path. A background watcher in the wrapper reads it and asks this policy whether the running gateway should react. The decision is intentionally side-effect free so it is provable in isolation without a live gateway or filesystem. A marker is honoured only when it requests a drain for the current instantiation:
  • a missing marker (None) is never a drain request;
  • a marker carrying no epoch is treated as foreign and ignored, so a hand-rolled or legacy file cannot wedge a process;
  • a marker whose epoch differs from current_epoch is stale — it survived a reboot/restart on a durable volume — and is ignored;
  • a current-epoch marker is honoured (subject to an optional already-handled de-duplication via last_handled_epoch).
Example::

Methods

drain_requested()

Return whether marker is a live drain request for this instance.

Source

View on GitHub

praisonaiagents/gateway/protocols.py at line 4025