دسکتاپ، Worker و محاسبات محلی · فصل ۳ — Identity، Health، Lease و SQLite Spool · 183

Heartbeat, Inventory, and Health Telemetry

Design a telemetry contract that separates liveness heartbeat, relatively slow-changing inventory, service health and resource observations; binds every report to worker identity/generation and observation time; preserves missing/stale evidence; and computes a bounded health decision without treating heartbeat recency as complete readiness. می‌تواند «Heartbeat, Inventory و Health Telemetry» را برای یک node محلی با identity، state، privilege و recovery boundary مناسب طراحی کند.

Heartbeat, Inventory و Health Telemetry — fa-IR

Lesson summary

Design a telemetry contract that separates liveness heartbeat, relatively slow-changing inventory, service health and resource observations; binds every report to worker identity/generation and observation time; preserves missing/stale evidence; and computes a bounded health decision without treating heartbeat recency as complete readiness.

می‌تواند «Heartbeat, Inventory و Health Telemetry» را برای یک node محلی با identity، state، privilege و recovery boundary مناسب طراحی کند.

This lesson produces

می‌تواند «Heartbeat, Inventory و Health Telemetry» را برای یک node محلی با identity، state، privilege و recovery boundary مناسب طراحی کند.

Who it is for

Foundation

Use a guided lesson-specific evidence matrix and one worked negative case.

Repair

Re-run only the failed owned dimension with a smaller deterministic synthetic fixture.

Experienced

Start from mixed authority/policy/evidence records; require explicit trade-offs and provenance.

Prerequisites

1. The real problem: a fresh heartbeat is not a healthy node

A fresh heartbeat only proves that a sender emitted a signal within a recent time window. The same node may have stale inventory, a NOT_SERVING worker service, low disk headroom, memory pressure, version drift, or telemetry from an obsolete identity generation. This lesson produces Node Heartbeat, Inventory & Health Evidence Matrix v1: a contract that keeps liveness, inventory, service health, and resource observations separate and makes the health decision no stronger than the evidence.

2. LOC-010 owns the telemetry boundary

LOC-010 owns heartbeat evidence, observation/receipt time, inventory snapshot and generation, service instance/version/health, resource observations, freshness, and health synthesis. Enrollment and credential generation belong to LOC-009; leases and work authority belong to LOC-011; durable offline spooling belongs to LOC-012. Telemetry describes observed state and never authorizes a privileged action by itself.

3. Telemetry must bind to the correct identity generation

At minimum record worker_id, identity_generation, heartbeat_sequence, observed_at, and received_at. A recent timestamp does not make an old identity current. If re-enrollment advanced the worker to generation 8, a generation-7 heartbeat must remain stale or quarantined even when its timestamp is fresh.

4. What OpenTelemetry Resource and service identity contribute

OpenTelemetry Resources describe the entity that produced telemetry. Service semantic conventions distinguish the logical service from service.instance.id and record service.version separately. These semantics help correlation and provenance, but they do not define the MAKNOW node-health policy; health still comes from the bounded contract in this lesson.

5. Heartbeat is liveness evidence only

Define a liveness_window and compute heartbeat_age under a declared clock policy. A heartbeat inside the window may yield LIVE; an older or unavailable one yields STALE or UNKNOWN. LIVE never means inventory is current, the service is serving, or resources are safe. Transport keepalive is not service health either.

6. Inventory changes more slowly but has its own freshness

Inventory can include host_id, OS/architecture, CPU and memory capacity, service version, and an inventory generation. Its cadence may be slower than heartbeat cadence, but inventory_age and inventory_generation remain explicit. If local policy says 30 minutes and the snapshot is six hours old, preserve INVENTORY_STALE instead of presenting the old values as current.

7. gRPC Health is a service signal, not a whole-node verdict

gRPC Health defines Check and Watch, while the application updates SERVING or NOT_SERVING. That signal answers whether a service is ready to accept requests. A fresh heartbeat alongside NOT_SERVING must lower the bounded health state; liveness is not allowed to override service health.

8. Resource observations need provenance and missing-signal semantics

CPU, memory, disk free, and process uptime are example observations. Record when each value was observed, from which source, and under which local policy. If disk_free is decisive but absent, do not invent a value. Preserve UNKNOWN or DEGRADED and name the recheck trigger.

9. Semantic conventions are not an eternal schema

OpenTelemetry system conventions still contain Development-status metrics and process conventions include Release Candidate metrics. Treat those names as evolving reference conventions, not as an immutable MAKNOW schema. Version the MAKNOW telemetry contract so upstream changes do not silently rewrite historical meaning.

10. Version drift is its own evidence dimension

Compare service.version and inventory generation with the local desired/expected version policy. Version drift does not necessarily make the node dead, but it can degrade health or restrict admission. Record it explicitly rather than confusing “the service responds” with “the expected version is running.”

11. Resource pressure is evaluated against local policy

This lesson invents no global CPU, memory, or disk threshold. The fixture or deployment policy supplies the relevant floor/ceiling. If disk free is below the local floor or memory pressure crosses the local ceiling, preserve DEGRADED even when heartbeat and service health are fresh. A number without policy is only an observation.

12. Health synthesis must fail closed or degrade

A bounded decision may be HEALTHY only when identity generation is current, heartbeat is fresh, inventory is current, the service is SERVING, and decisive observations exist and satisfy local policy. A stale, missing, or conflicting decisive dimension yields a typed non-success state such as STALE_REJECTED, INVENTORY_STALE, UNKNOWN, or DEGRADED. Averaging signals must not hide failure.

13. The Evidence Matrix makes the decision reproducible

For each case retain Worker ID, Identity Generation, Heartbeat Sequence, Observed/Received At, Heartbeat Age/Liveness, Inventory Generation/Age, Service Instance/Version/Health, CPU, Memory, Disk Free, Process Uptime, Missing Signal, Version Drift, Resource Pressure, Health Decision, and Reason. A reviewer should be able to reproduce the decision without hidden reasoning.

14. Decisive failure probes

Break four shortcuts: (1) heartbeat fresh + service NOT_SERVING must not be HEALTHY; (2) heartbeat/service fresh + inventory older than its TTL preserves INVENTORY_STALE; (3) a fresh heartbeat from the previous identity generation is rejected or quarantined; (4) all visible signals look good but required disk_free is missing, so the result remains UNKNOWN/DEGRADED rather than imputed. The learner lab does not expose final labels.

15. Transfer from push heartbeat to pull/streaming collection

Change transport without changing the evidence contract. Pull/streaming telemetry must preserve source identity, identity generation, observation time, received time, freshness windows, inventory generation, service health, and missing-signal semantics. A new sampling cadence changes ages, so the health decision must be recomputed from the new evidence instead of copied from the baseline.

Assessment

There is no answer key in this lesson pack; answer it yourself and mark honestly. "Needs review" sends the lesson to your review queue.

Q1 application

Build the Node Heartbeat, Inventory & Health Evidence Matrix from the supplied synthetic fixture without inventing missing observations.

lesson ✗AI ✗notes ✗

Q2 diagnosis

Explain why a fresh heartbeat plus NOT_SERVING service health cannot be HEALTHY.

lesson ✗AI ✗notes ✗

Q3 decision

Issue a typed health decision for stale inventory and name the recheck trigger.

lesson ✗AI ✗notes ✗

Q4 transfer

Recompute the decision after moving from push heartbeat to pull/streaming collection with a different sampling cadence.

lesson ✗AI ✗notes ✗
Assessment rubric
  • Identity binding — critical: worker identity and identity generation are explicit.
  • Freshness separation — critical: heartbeat age and inventory age use separate declared windows.
  • Service/resource evidence — critical: service health and required resource observations remain separate from liveness.
  • Typed non-success — critical: stale, missing, conflict, pressure, or old-generation evidence is not coerced into healthy.
  • Bounded decision — critical: the decision is no stronger than visible evidence and names a recheck trigger.
  • Transfer — critical: the changed transport/cadence causes recomputation rather than copying the baseline verdict.

References & freshness

·
·
·
·
·

Case studies

Lesson visuals

LOC-010-TELEMETRY-DECISION

Lab files

Build a function evaluate_health(case) in starter.py. Preserve identity-generation binding, heartbeat freshness, inventory freshness, service health, resource observations, missing signals and local thresholds as separate evidence dimensions.

The fixtures are synthetic and offline. They intentionally do not include final expected decisions. Run python run_checks.py to confirm only the learner-facing structure.