Auto-heal orphan cleanup for multi-daemon architecture (W3).
Detects lings bound to dead/unhealthy daemons (orphans) and either:
Integration: Called from daemon_store.clj heartbeat loop on each cycle.
All foreign ling/task state crosses injected runtime ports.
Auto-heal orphan cleanup for multi-daemon architecture (W3). Detects lings bound to dead/unhealthy daemons (orphans) and either: 1. Rebinds them to a healthy daemon (if idle) 2. Marks working lings' tasks as failed and releases claims (graceful termination) Integration: Called from daemon_store.clj heartbeat loop on each cycle. All foreign ling/task state crosses injected runtime ports.
(classify-orphan {:keys [ling-status]})Classify an orphaned ling for healing action.
Arguments: orphan - Map from find-orphaned-lings
Returns: :rebind - Ling is idle, can be rebound to healthy daemon :terminate - Ling is working/blocked, task must be failed and ling terminated :skip - Ling is already terminated or in error, no action needed
Classify an orphaned ling for healing action. Arguments: orphan - Map from find-orphaned-lings Returns: :rebind - Ling is idle, can be rebound to healthy daemon :terminate - Ling is working/blocked, task must be failed and ling terminated :skip - Ling is already terminated or in error, no action needed
(find-orphaned-lings store)Find all lings that are bound to dead/unhealthy daemons.
An orphaned ling is one whose daemon has status in #{:stale :terminated :error}. This indicates the Emacs process has crashed, is unresponsive, or was shut down.
Arguments: store - IEmacsDaemon store instance
Returns: Seq of maps with: :ling-id - The orphaned ling's slave ID :daemon-id - The daemon it was bound to :daemon-status - Why it's orphaned (:stale/:terminated/:error) :ling-status - Current ling status (:idle/:working/:etc) :project-id - Ling's project ID (for rebinding affinity)
Find all lings that are bound to dead/unhealthy daemons.
An orphaned ling is one whose daemon has status in #{:stale :terminated :error}.
This indicates the Emacs process has crashed, is unresponsive, or was shut down.
Arguments:
store - IEmacsDaemon store instance
Returns:
Seq of maps with:
:ling-id - The orphaned ling's slave ID
:daemon-id - The daemon it was bound to
:daemon-status - Why it's orphaned (:stale/:terminated/:error)
:ling-status - Current ling status (:idle/:working/:etc)
:project-id - Ling's project ID (for rebinding affinity)(heal-all-orphans! store)Detect and heal all orphaned lings across all daemons.
This is the main entry point called from the heartbeat loop. Scans all daemons for dead/stale/error status, finds their bound lings, and heals each one.
Arguments: store - IEmacsDaemon store instance
Returns: Map with: :orphans-found - Total orphaned lings detected :healed - Number successfully healed (rebound or terminated) :failed - Number that failed to heal :results - Seq of individual healing results Or nil if no orphans found.
Detect and heal all orphaned lings across all daemons.
This is the main entry point called from the heartbeat loop.
Scans all daemons for dead/stale/error status, finds their bound lings,
and heals each one.
Arguments:
store - IEmacsDaemon store instance
Returns:
Map with:
:orphans-found - Total orphaned lings detected
:healed - Number successfully healed (rebound or terminated)
:failed - Number that failed to heal
:results - Seq of individual healing results
Or nil if no orphans found.(heal-orphan! store orphan)Heal a single orphaned ling based on its classification.
Arguments: store - IEmacsDaemon store instance orphan - Orphan map from find-orphaned-lings
Returns: Map with healing action result
Heal a single orphaned ling based on its classification. Arguments: store - IEmacsDaemon store instance orphan - Orphan map from find-orphaned-lings Returns: Map with healing action result
(orphan-status store)Get current orphan status without healing. Useful for monitoring.
Arguments: store - IEmacsDaemon store instance
Returns: Map with :orphan-count, :orphans (detailed list), or nil if no orphans
Get current orphan status without healing. Useful for monitoring. Arguments: store - IEmacsDaemon store instance Returns: Map with :orphan-count, :orphans (detailed list), or nil if no orphans
Daemon statuses that indicate a daemon is dead or non-functional. Lings bound to daemons in these states are considered orphaned.
Daemon statuses that indicate a daemon is dead or non-functional. Lings bound to daemons in these states are considered orphaned.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |