Liking cljdoc? Tell your friends :D

hive-emacs.daemon-scoring

Pure health-scoring computation for Emacs daemons.

Extracted from daemon-selection to separate pure scoring algorithms from I/O-bound selection and heartbeat orchestration.

Contains:

  • Health classification (health-level, healthy?)
  • EWMA-based health score computation
  • Latency, error, and load penalty calculations
  • Pure heartbeat helpers (metrics, tx-data, report)

DDD: Value Object / Domain Service (pure, no I/O).

Pure health-scoring computation for Emacs daemons.

Extracted from daemon-selection to separate pure scoring algorithms
from I/O-bound selection and heartbeat orchestration.

Contains:
- Health classification (health-level, healthy?)
- EWMA-based health score computation
- Latency, error, and load penalty calculations
- Pure heartbeat helpers (metrics, tx-data, report)

DDD: Value Object / Domain Service (pure, no I/O).
raw docstring

apply-recovery-bonusclj

(apply-recovery-bonus score success? prev-errors)

Pure: add recovery-bonus to score iff ping succeeded after prior errors.

Pure: add recovery-bonus to score iff ping succeeded after prior errors.
sourceraw docstring

capacity-leftclj

(capacity-left capacity used)

Saturating subtraction for bounded daemon capacity.

Saturating subtraction for bounded daemon capacity.
sourceraw docstring

clamp-health-scoreclj

(clamp-health-score score)

Clamp numeric SCORE to the closed health interval 0..100.

Clamp numeric SCORE to the closed health interval 0..100.
sourceraw docstring

compute-health-scoreclj

(compute-health-score prev-score latency-ms consecutive-errors ling-count)

Compute a new health score using EWMA blending of current and previous scores.

The raw score is 100 + penalties from latency, errors, and load. Then blended with the previous score using EWMA for smoothing.

Arguments: prev-score - Previous health score (0-100, nil = 100) latency-ms - Response time of latest heartbeat (nil = failed) consecutive-errors - Number of consecutive heartbeat failures ling-count - Number of lings bound to daemon

Returns: New health score (0-100, integer)

Compute a new health score using EWMA blending of current and previous scores.

The raw score is 100 + penalties from latency, errors, and load.
Then blended with the previous score using EWMA for smoothing.

Arguments:
  prev-score         - Previous health score (0-100, nil = 100)
  latency-ms         - Response time of latest heartbeat (nil = failed)
  consecutive-errors - Number of consecutive heartbeat failures
  ling-count         - Number of lings bound to daemon

Returns:
  New health score (0-100, integer)
sourceraw docstring

default-health-scoreclj

Default health score for daemons without an explicit score. Daemons start healthy until proven otherwise.

Default health score for daemons without an explicit score.
Daemons start healthy until proven otherwise.
sourceraw docstring

error-penaltyclj

Health points deducted per consecutive error (capped at error-penalty-max).

Health points deducted per consecutive error (capped at error-penalty-max).
sourceraw docstring

error-penalty-maxclj

Maximum cumulative error penalty.

Maximum cumulative error penalty.
sourceraw docstring

error-score-deltaclj

(error-score-delta consecutive-errors)

Compute health score delta from consecutive error count.

Arguments: consecutive-errors - Number of consecutive heartbeat failures

Returns: Negative number (penalty) capped at error-penalty-max.

Compute health score delta from consecutive error count.

Arguments:
  consecutive-errors - Number of consecutive heartbeat failures

Returns:
  Negative number (penalty) capped at error-penalty-max.
sourceraw docstring

ewma-alphaclj

EWMA smoothing factor. Higher = more weight on latest measurement. 0.3 means 70% historical, 30% new — smooths transient spikes.

EWMA smoothing factor. Higher = more weight on latest measurement.
0.3 means 70% historical, 30% new — smooths transient spikes.
sourceraw docstring

health-levelclj

(health-level score)

Classify a health score into a health level.

Arguments: score - Health score 0-100 (nil treated as default-health-score)

Returns: :healthy (70-100), :degraded (30-69), or :unhealthy (0-29)

Classify a health score into a health level.

Arguments:
  score - Health score 0-100 (nil treated as default-health-score)

Returns:
  :healthy (70-100), :degraded (30-69), or :unhealthy (0-29)
sourceraw docstring

healthy?clj

(healthy? score)

Is the daemon healthy enough for new ling spawns?

Is the daemon healthy enough for new ling spawns?
sourceraw docstring

heartbeat-reportclj

(heartbeat-report {:keys [success? latency-ms new-errors]}
                  final-score
                  ling-count)

Pure: shape the public result map returned by heartbeat!.

Pure: shape the public result map returned by heartbeat!.
sourceraw docstring

heartbeat-tx-dataclj

(heartbeat-tx-data eid now {:keys [success? new-errors]} final-score)

Pure: build the DataScript tx payload for a heartbeat update.

Pure: build the DataScript tx payload for a heartbeat update.
sourceraw docstring

latency-degraded-msclj

Response time threshold for degraded health. Above this = heavy penalty.

Response time threshold for degraded health. Above this = heavy penalty.
sourceraw docstring

latency-healthy-msclj

Response time threshold for full health. Below this = no penalty.

Response time threshold for full health. Below this = no penalty.
sourceraw docstring

latency-max-penaltyclj

Maximum health points deducted for latency (scales linearly).

Maximum health points deducted for latency (scales linearly).
sourceraw docstring

latency-score-deltaclj

(latency-score-delta latency-ms)

Compute health score delta from response latency.

Arguments: latency-ms - Response time in milliseconds

Returns: Negative number (penalty) or 0 (no penalty). Fast responses (< 500ms): 0 penalty Slow responses (500-2000ms): linear penalty up to -40 Very slow (>2000ms): full -40 penalty

Compute health score delta from response latency.

Arguments:
  latency-ms - Response time in milliseconds

Returns:
  Negative number (penalty) or 0 (no penalty).
  Fast responses (< 500ms): 0 penalty
  Slow responses (500-2000ms): linear penalty up to -40
  Very slow (>2000ms): full -40 penalty
sourceraw docstring

ling-load-deltaclj

(ling-load-delta ling-count)

Compute health score delta from ling count (load pressure).

Arguments: ling-count - Number of lings bound to daemon

Returns: Negative number (penalty). First ling is free.

Compute health score delta from ling count (load pressure).

Arguments:
  ling-count - Number of lings bound to daemon

Returns:
  Negative number (penalty). First ling is free.
sourceraw docstring

ling-load-penalty-perclj

Health points deducted per ling beyond the first. Daemon with 5 lings = 4 * 2 = 8 points penalty.

Health points deducted per ling beyond the first.
Daemon with 5 lings = 4 * 2 = 8 points penalty.
sourceraw docstring

ping-metricsclj

(ping-metrics ping-result prev-errors)

Pure: derive (success?, latency-ms, new-errors) from a ping-result + prev-errors.

Pure: derive (success?, latency-ms, new-errors) from a ping-result + prev-errors.
sourceraw docstring

recovery-bonusclj

Health points recovered per successful heartbeat after errors. Allows gradual recovery from error state.

Health points recovered per successful heartbeat after errors.
Allows gradual recovery from error state.
sourceraw docstring

score-snapshotclj

(score-snapshot {:keys [previous latency-ms errors lings]})

Schema-shaped pure score projection used by generative/proof facets.

Schema-shaped pure score projection used by generative/proof facets.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close